View | Details | Raw Unified | Return to bug 247408 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/net/ProxyData.java (+57 lines)
Lines 128-131 Link Here
128
		return stringBuffer.toString();
128
		return stringBuffer.toString();
129
	}
129
	}
130
130
131
	public int hashCode() {
132
		final int prime = 31;
133
		int result = 1;
134
		result = prime * result + (dynamic ? 1231 : 1237);
135
		result = prime * result + ((host == null) ? 0 : host.hashCode());
136
		result = prime * result
137
				+ ((password == null) ? 0 : password.hashCode());
138
		result = prime * result + port;
139
		result = prime * result + (requiresAuthentication ? 1231 : 1237);
140
		result = prime * result + ((source == null) ? 0 : source.hashCode());
141
		result = prime * result + ((type == null) ? 0 : type.hashCode());
142
		result = prime * result + ((user == null) ? 0 : user.hashCode());
143
		return result;
144
	}
145
146
	public boolean equals(Object obj) {
147
		if (this == obj)
148
			return true;
149
		if (obj == null)
150
			return false;
151
		if (getClass() != obj.getClass())
152
			return false;
153
		ProxyData other = (ProxyData) obj;
154
		if (dynamic != other.dynamic)
155
			return false;
156
		if (host == null) {
157
			if (other.host != null)
158
				return false;
159
		} else if (!host.equals(other.host))
160
			return false;
161
		if (password == null) {
162
			if (other.password != null)
163
				return false;
164
		} else if (!password.equals(other.password))
165
			return false;
166
		if (port != other.port)
167
			return false;
168
		if (requiresAuthentication != other.requiresAuthentication)
169
			return false;
170
		if (source == null) {
171
			if (other.source != null)
172
				return false;
173
		} else if (!source.equals(other.source))
174
			return false;
175
		if (type == null) {
176
			if (other.type != null)
177
				return false;
178
		} else if (!type.equals(other.type))
179
			return false;
180
		if (user == null) {
181
			if (other.user != null)
182
				return false;
183
		} else if (!user.equals(other.user))
184
			return false;
185
		return true;
186
	}
187
131
}
188
}
(-)src/org/eclipse/core/internal/net/ProxyManager.java (+9 lines)
Lines 549-552 Link Here
549
		// (see preferenceChange)
549
		// (see preferenceChange)
550
		Activator.getInstance().getPreferences().putBoolean(PREF_OS, enabled);
550
		Activator.getInstance().getPreferences().putBoolean(PREF_OS, enabled);
551
	}
551
	}
552
553
	public IProxyData[] select(URI uri) {
554
		IProxyData data = getProxyDataForHost(uri.getHost(), uri.getScheme());
555
		if (data != null) {
556
			return new IProxyData[] { data };
557
		}
558
		return new IProxyData[0];
559
	}
560
552
}
561
}
(-)src/org/eclipse/core/net/proxy/IProxyService.java (-1 / +19 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.net.proxy;
11
package org.eclipse.core.net.proxy;
12
12
13
import java.net.URI;
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
16
15
/**
17
/**
Lines 105-111 Link Here
105
	 * @return the list of know proxy types and their settings
107
	 * @return the list of know proxy types and their settings
106
	 */
108
	 */
107
	IProxyData[] getProxyData();
109
	IProxyData[] getProxyData();
108
	
110
111
	/**
112
	 * Returns all the applicable proxy data to access the specified URI.
113
	 * 
114
	 * @param uri
115
	 *            the URI for which proxies are returned
116
	 * @return list of all applicable proxy data, if no proxy is applicable then
117
	 *         an empty array is returned
118
	 * 
119
	 * @since 1.2
120
	 */
121
	IProxyData[] select(URI uri);
122
109
	/**
123
	/**
110
	 * Returns the list of known proxy types and their settings for the
124
	 * Returns the list of known proxy types and their settings for the
111
	 * given host. If proxies are disabled
125
	 * given host. If proxies are disabled
Lines 117-122 Link Here
117
	 * Clients that wish to make a connection and need to determine whether to
131
	 * Clients that wish to make a connection and need to determine whether to
118
	 * use a proxy should use this method.
132
	 * use a proxy should use this method.
119
	 * </p>
133
	 * </p>
134
	 * @deprecated This method is deprecated because of its ambiguity. See
135
	 * {@link #select(URI)} insted.
120
	 * 
136
	 * 
121
	 * @param host the host for which a connection is desired
137
	 * @param host the host for which a connection is desired
122
	 * @return the list of known proxy types and their settings for the
138
	 * @return the list of known proxy types and their settings for the
Lines 159-164 Link Here
159
	 * Clients that wish to make a connection and need to determine whether to
175
	 * Clients that wish to make a connection and need to determine whether to
160
	 * use a proxy should use this method.
176
	 * use a proxy should use this method.
161
	 * </p>
177
	 * </p>
178
	 *  @deprecated This method is deprecated because of its ambiguity. See
179
	 * {@link #select(URI)} insted.
162
	 * 
180
	 * 
163
	 * @param host
181
	 * @param host
164
	 *            the host for which a connection is desired
182
	 *            the host for which a connection is desired
(-)src/org/eclipse/core/tests/net/NetTest.java (+22 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.tests.net;
11
package org.eclipse.core.tests.net;
12
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
13
import java.util.*;
15
import java.util.*;
14
16
15
import junit.framework.*;
17
import junit.framework.*;
Lines 343-346 Link Here
343
		this.getProxyManager().setNonProxiedHosts(oldHosts);
345
		this.getProxyManager().setNonProxiedHosts(oldHosts);
344
	}
346
	}
345
347
348
	public void testBug247408() throws CoreException, URISyntaxException {
349
		setDataTest(IProxyData.HTTP_PROXY_TYPE);
350
		setDataTest(IProxyData.HTTPS_PROXY_TYPE);
351
		setDataTest(IProxyData.SOCKS_PROXY_TYPE);
352
353
		IProxyData data1 = this.getProxyManager().getProxyDataForHost(
354
				"randomhost.com", IProxyData.HTTP_PROXY_TYPE);
355
		IProxyData[] data2 = this.getProxyManager().select(
356
				new URI("http://randomhost.com"));
357
		assertEquals(data2.length, 1);
358
		assertEquals(data1, data2[0]);
359
360
		IProxyData data3 = this.getProxyManager().getProxyDataForHost(
361
				"randomhost.com", null);
362
		IProxyData[] data4 = this.getProxyManager().select(
363
				new URI(null, "randomhost.com", null, null));
364
		assertNull(data3);
365
		assertEquals(data4.length, 0);
366
	}
367
346
}
368
}

Return to bug 247408