Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2008-11-18 15:16:54 +0000
committerTomasz Zarna2008-11-18 15:16:54 +0000
commit75984d2a8f3182b946997635376af033cd6a1574 (patch)
tree74469db7eddbcb61c33b63020aa0a41175743fb8
parentefd6b84a4cf40a57e88d7c85ce8125e61c1c2f8c (diff)
downloadeclipse.platform.team-75984d2a8f3182b946997635376af033cd6a1574.tar.gz
eclipse.platform.team-75984d2a8f3182b946997635376af033cd6a1574.tar.xz
eclipse.platform.team-75984d2a8f3182b946997635376af033cd6a1574.zip
bug 255616: [Net] Add proxy providers layer on the top of ProxyManager
-rw-r--r--bundles/org.eclipse.core.net/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/AbstractProxyProvider.java6
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java11
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java18
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxySelector.java128
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/WindowsProxyProvider.java8
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java4
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java6
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyProviderUtil.java18
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java19
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyProvider.java82
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/net/proxy/IProxyData.java27
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java42
13 files changed, 353 insertions, 18 deletions
diff --git a/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF
index ac4b7983b..a0814ba49 100644
--- a/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF
@@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)",
org.eclipse.osgi;bundle-version="3.4.0",
org.eclipse.equinox.registry;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.core.internal.net;x-internal:=true,
+Export-Package: org.eclipse.core.internal.net;x-friends:="org.eclipse.ui.net",
org.eclipse.core.net.proxy
Bundle-RequiredExecutionEnvironment: J2SE-1.4,
CDC-1.0/Foundation-1.0,
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/AbstractProxyProvider.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/AbstractProxyProvider.java
index eac0e0f3b..5bd72ea27 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/AbstractProxyProvider.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/AbstractProxyProvider.java
@@ -53,7 +53,7 @@ public abstract class AbstractProxyProvider {
protected abstract IProxyData[] getProxyData(URI uri);
- protected String[] getNonProxiedHosts() {
- return new String[] {};
- }
+ protected abstract IProxyData[] getProxyData();
+
+ protected abstract String[] getNonProxiedHosts();
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java
index c3d523ee7..a142a3772 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java
@@ -21,6 +21,7 @@ public class ProxyData implements IProxyData {
private String password;
private boolean requiresAuthentication;
private String source;
+ private boolean dynamic = false;
public ProxyData(String type, String host, int port,
boolean requiresAuthentication, String source) {
@@ -94,6 +95,14 @@ public class ProxyData implements IProxyData {
this.source = source;
}
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+ public void setDynamic(boolean dynamic) {
+ this.dynamic = dynamic;
+ }
+
public String toString() {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("type: "); //$NON-NLS-1$
@@ -110,6 +119,8 @@ public class ProxyData implements IProxyData {
stringBuffer.append(requiresAuthentication);
stringBuffer.append(" source: "); //$NON-NLS-1$
stringBuffer.append(source);
+ stringBuffer.append(" dynamic: "); //$NON-NLS-1$
+ stringBuffer.append(dynamic);
return stringBuffer.toString();
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
index 79c7616c9..1e172c8bb 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
@@ -40,7 +40,7 @@ import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
public class ProxyManager implements IProxyService, IPreferenceChangeListener {
-
+
private static final String PREF_HAS_MIGRATED = "org.eclipse.core.net.hasMigrated"; //$NON-NLS-1$
/**
@@ -134,6 +134,13 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener {
return result;
}
+ public String[] getNativeNonProxiedHosts() {
+ if (hasSystemProxies()) {
+ return nativeProxyProvider.getNonProxiedHosts();
+ }
+ return new String[0];
+ }
+
/* (non-Javadoc)
* @see org.eclipse.core.net.IProxyManager#setNonProxiedHosts(java.lang.String[])
*/
@@ -169,7 +176,14 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener {
}
return result;
}
-
+
+ public IProxyData[] getNativeProxyData() {
+ if (hasSystemProxies()) {
+ return nativeProxyProvider.getProxyData();
+ }
+ return new IProxyData[0];
+ }
+
public void setProxyData(IProxyData[] proxies) {
checkMigrated();
doSetProxyData(proxies);
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxySelector.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxySelector.java
new file mode 100644
index 000000000..be921f60a
--- /dev/null
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxySelector.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.internal.net;
+
+import org.eclipse.core.net.proxy.IProxyData;
+import org.eclipse.core.net.proxy.IProxyService;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * This class adapts ProxyManager to add additional layer of providers on its
+ * top.
+ */
+public class ProxySelector {
+
+ private static final String DIRECT_PROVIDER = "Direct"; //$NON-NLS-1$
+ private static final String ECLIPSE_PROVIDER = "Eclipse"; //$NON-NLS-1$
+ private static final String NATIVE_PROVIDER = "Native"; //$NON-NLS-1$
+
+ public static String[] getProviders() {
+ return new String[] { DIRECT_PROVIDER, ECLIPSE_PROVIDER,
+ NATIVE_PROVIDER };
+ }
+
+ public static String getDefaultProvider() {
+ IProxyService service = ProxyManager.getProxyManager();
+ if (!service.isProxiesEnabled()) {
+ return DIRECT_PROVIDER;
+ } else if (service.isProxiesEnabled()
+ && !service.isSystemProxiesEnabled()) {
+ return ECLIPSE_PROVIDER;
+ }
+ return NATIVE_PROVIDER;
+ }
+
+ public static void setDefaultProvider(String provider) {
+ IProxyService service = ProxyManager.getProxyManager();
+ if (provider.equals(DIRECT_PROVIDER)) {
+ service.setProxiesEnabled(false);
+ service.setProxiesEnabled(false);
+ } else if (provider.equals(ECLIPSE_PROVIDER)) {
+ service.setProxiesEnabled(true);
+ service.setSystemProxiesEnabled(false);
+ } else if (provider.equals(NATIVE_PROVIDER)) {
+ service.setProxiesEnabled(true);
+ service.setSystemProxiesEnabled(true);
+ }
+ throw new IllegalArgumentException("Provider not supported"); //$NON-NLS-1$
+ }
+
+ public static IProxyData[] getProxyData(String provider) {
+ ProxyManager manager = (ProxyManager) ProxyManager.getProxyManager();
+ if (provider.equals(DIRECT_PROVIDER)) {
+ return new IProxyData[0];
+ } else if (provider.equals(ECLIPSE_PROVIDER)) {
+ return manager.getProxyData();
+ } else if (provider.equals(NATIVE_PROVIDER)) {
+ return manager.getNativeProxyData();
+ }
+ throw new IllegalArgumentException("Provider not supported"); //$NON-NLS-1$
+ }
+
+ public static void setProxyData(String provider, IProxyData proxies[]) {
+ if (provider.equals(ECLIPSE_PROVIDER)) {
+ IProxyService service = ProxyManager.getProxyManager();
+ try {
+ service.setProxyData(proxies);
+ } catch (CoreException e) {
+ // Should never occur since ProxyManager does not
+ // declare CoreException to be thrown
+ throw new RuntimeException(e);
+ }
+ } else {
+ throw new IllegalArgumentException(
+ "Provider does not support setting proxy data"); //$NON-NLS-1$
+ }
+ }
+
+ public static boolean canSetProxyData(String provider) {
+ if (provider.equals(ECLIPSE_PROVIDER)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static String[] getBypassHosts(String provider) {
+ ProxyManager manager = (ProxyManager) ProxyManager.getProxyManager();
+ if (provider.equals(DIRECT_PROVIDER)) {
+ return new String[0];
+ } else if (provider.equals(ECLIPSE_PROVIDER)) {
+ return manager.getNonProxiedHosts();
+ } else if (provider.equals(NATIVE_PROVIDER)) {
+ return manager.getNativeNonProxiedHosts();
+ }
+ throw new IllegalArgumentException("Provider not supported"); //$NON-NLS-1$
+ }
+
+ public static void setBypassHosts(String provider, String hosts[]) {
+ if (provider.equals(ECLIPSE_PROVIDER)) {
+ IProxyService service = ProxyManager.getProxyManager();
+ try {
+ service.setNonProxiedHosts(hosts);
+ } catch (CoreException e) {
+ // Should never occur since ProxyManager does not
+ // declare CoreException to be thrown
+ throw new RuntimeException(e);
+ }
+ } else {
+ throw new IllegalArgumentException(
+ "Provider does not support setting bypass hosts"); //$NON-NLS-1$
+ }
+ }
+
+ public static boolean canSetBypassHosts(String provider) {
+ if (provider.equals(ECLIPSE_PROVIDER)) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/WindowsProxyProvider.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/WindowsProxyProvider.java
index 76611726c..65d226698 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/WindowsProxyProvider.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/WindowsProxyProvider.java
@@ -41,4 +41,12 @@ public class WindowsProxyProvider extends AbstractProxyProvider {
return winHttpProxyProvider.getProxyData(uri);
}
+ protected IProxyData[] getProxyData() {
+ return winHttpProxyProvider.getProxyData();
+ }
+
+ protected String[] getNonProxiedHosts() {
+ return winHttpProxyProvider.getNonProxiedHosts();
+ }
+
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
index 414ed3323..68abaa5ca 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
@@ -52,6 +52,10 @@ public class UnixProxyProvider extends AbstractProxyProvider {
ProxyData pd = getSystemProxyInfo(uri.getScheme());
return pd != null ? new IProxyData[] { pd } : new IProxyData[0];
}
+ return getProxyData();
+ }
+
+ public IProxyData[] getProxyData() {
String[] commonTypes = new String[] { IProxyData.HTTP_PROXY_TYPE,
IProxyData.SOCKS_PROXY_TYPE, IProxyData.HTTPS_PROXY_TYPE };
return getProxyForTypes(commonTypes);
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java
index 3111d1ff6..2d32b2442 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyBypass.java
@@ -7,6 +7,7 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - Add proxy providers layer on the top of ProxyManager (bug 255616)
*******************************************************************************/
package org.eclipse.core.internal.net.proxy.win32.winhttp;
@@ -84,4 +85,9 @@ public class ProxyBypass {
return proxyBypass.indexOf(BYPASS_LOCAL_ADDESSES_TOKEN) != -1;
}
+ public String[] getNonProxiedHosts() {
+ String ret = ProxyProviderUtil.replace(proxyBypass, "|", ";"); //$NON-NLS-1$ //$NON-NLS-2$
+ return ret.split(";"); //$NON-NLS-1$
+ }
+
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyProviderUtil.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyProviderUtil.java
index b1795e6b5..4c44efc66 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyProviderUtil.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/ProxyProviderUtil.java
@@ -7,7 +7,8 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
- * IBM Corporation - bug 246072, adding IProxyData.source support
+ * IBM Corporation - bug 246072 - adding IProxyData.source support
+ * IBM Corporation - Add proxy providers layer on the top of ProxyManager (bug 255616)
*******************************************************************************/
package org.eclipse.core.internal.net.proxy.win32.winhttp;
@@ -138,11 +139,16 @@ public final class ProxyProviderUtil {
}
private static String resolveProxyType(String protocol) {
- if (protocol.equalsIgnoreCase("socks") || protocol.equalsIgnoreCase("socket")) //$NON-NLS-1$ //$NON-NLS-2$
- return IProxyData.SOCKS_PROXY_TYPE;
- if (protocol.equalsIgnoreCase("https")) //$NON-NLS-1$
- return IProxyData.HTTPS_PROXY_TYPE;
- return IProxyData.HTTP_PROXY_TYPE;
+ return protocol;
+ // The behaviour of this method has been changed in order to
+ // avoid mapping multiple schemas to one proxy type. This
+ // could lead to API misuse.
+
+ // if (protocol.equalsIgnoreCase("socks") || protocol.equalsIgnoreCase("socket")) //$NON-NLS-1$ //$NON-NLS-2$
+ // return IProxyData.SOCKS_PROXY_TYPE;
+ // if (protocol.equalsIgnoreCase("https")) //$NON-NLS-1$
+ // return IProxyData.HTTPS_PROXY_TYPE;
+ // return IProxyData.HTTP_PROXY_TYPE;
}
private static IProxyData createProxy(String scheme, String host, int port) {
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java
index d39210ec1..269674efe 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java
@@ -8,6 +8,7 @@
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
* IBM Corporation - handling URI without a scheme by select(URI, List) (bug 246065)
+ * IBM Corporation - Add proxy providers layer on the top of ProxyManager (bug 255616)
*******************************************************************************/
package org.eclipse.core.internal.net.proxy.win32.winhttp;
@@ -18,6 +19,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.net.proxy.IProxyData;
+
/**
* StaticProxyConfig wraps certain information of WinHttpCurrentIEProxyConfig,
* i.e. the Windows specific list of proxies and the proxy bypass list.
@@ -70,4 +73,20 @@ public class StaticProxyConfig {
proxies.addAll(universalProxies);
}
+ public IProxyData[] getProxyData() {
+ List proxies = new ArrayList();
+ Iterator it = protocolSpecificProxies.values().iterator();
+ while (it.hasNext()) {
+ List protocolProxies = (List) it.next();
+ if (protocolProxies != null) {
+ proxies.addAll(protocolProxies);
+ }
+ }
+ return (IProxyData[]) proxies.toArray(new IProxyData[0]);
+ }
+
+ public String[] getNonProxiedHosts() {
+ return proxyBypass.getNonProxiedHosts();
+ }
+
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyProvider.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyProvider.java
index 8165fcc57..50082622e 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyProvider.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/WinHttpProxyProvider.java
@@ -7,6 +7,7 @@
*
* Contributors:
* compeople AG (Stefan Liebig) - initial API and implementation
+ * IBM Corporation - Add proxy providers layer on the top of ProxyManager (bug 255616)
*******************************************************************************/
package org.eclipse.core.internal.net.proxy.win32.winhttp;
@@ -63,8 +64,86 @@ public class WinHttpProxyProvider {
return proxies;
}
+ public IProxyData[] getProxyData() {
+ logMessage = null;
+ IProxyData[] proxies;
+ synchronized (this) {
+ proxies = getProxyDataUnsynchronized();
+ }
+ if (logMessage != null)
+ Activator.logError(logMessage, logThrowable);
+ return proxies;
+ }
+
+ private IProxyData[] getProxyDataUnsynchronized() {
+ WinHttpCurrentUserIEProxyConfig newProxyConfig = new WinHttpCurrentUserIEProxyConfig();
+ if (!WinHttp.getIEProxyConfigForCurrentUser(newProxyConfig)) {
+ logError(
+ "WinHttp.GetIEProxyConfigForCurrentUser failed with error '" + WinHttp.getLastErrorMessage() + "' #" + WinHttp.getLastError() + ".", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return EMPTY_PROXIES;
+ }
+
+ // Explicit proxies defined?
+ if (newProxyConfig.isStaticProxy()) {
+ // Yes, letīs see if we are still up-to-date
+ if (newProxyConfig.staticProxyChanged(proxyConfig))
+ staticProxyConfig = new StaticProxyConfig(newProxyConfig
+ .getProxy(), newProxyConfig.getProxyBypass());
+
+ return staticProxyConfig.getProxyData();
+ }
+
+ // Letīs find out if auto detect has changed.
+ if (newProxyConfig.autoDetectChanged(proxyConfig)) {
+ tryWpadGetUrl = newProxyConfig.isAutoDetect();
+ if (!tryWpadGetUrl)
+ wpadAutoConfigUrl = null;
+ }
+
+ // Letīs find out if pac file url has changed.
+ if (newProxyConfig.autoConfigUrlChanged(proxyConfig))
+ tryPac = newProxyConfig.isAutoConfigUrl();
+
+ if (!tryPac && wpadAutoConfigUrl == null)
+ return new IProxyData[0];
+
+ IProxyData data = new ProxyData(IProxyData.HTTP_PROXY_TYPE, "", -1, //$NON-NLS-1$
+ false, "WINDOWS_IE"); //$NON-NLS-1$
+ data.setDynamic(true);
+ return new IProxyData[] { data };
+ }
+
+ public String[] getNonProxiedHosts() {
+ logMessage = null;
+ String[] hosts;
+ synchronized (this) {
+ hosts = getNonProxiedHostsUnsynchronized();
+ }
+ if (logMessage != null)
+ Activator.logError(logMessage, logThrowable);
+ return hosts;
+ }
+
+ private String[] getNonProxiedHostsUnsynchronized() {
+ WinHttpCurrentUserIEProxyConfig newProxyConfig = new WinHttpCurrentUserIEProxyConfig();
+ if (!WinHttp.getIEProxyConfigForCurrentUser(newProxyConfig)) {
+ logError(
+ "WinHttp.GetIEProxyConfigForCurrentUser failed with error '" + WinHttp.getLastErrorMessage() + "' #" + WinHttp.getLastError() + ".", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new String[0];
+ }
+ if (newProxyConfig.isStaticProxy()) {
+ // Yes, letīs see if we are still up-to-date
+ if (newProxyConfig.staticProxyChanged(proxyConfig))
+ staticProxyConfig = new StaticProxyConfig(newProxyConfig
+ .getProxy(), newProxyConfig.getProxyBypass());
+ return staticProxyConfig.getNonProxiedHosts();
+ }
+ return null;
+ }
+
/**
- * This method is the not synchronized counterpart of <code>getProxyData</code>.
+ * This method is the not synchronized counterpart of
+ * <code>getProxyData</code>.
*
* @param uri
* @return an array of proxies
@@ -205,4 +284,5 @@ public class WinHttpProxyProvider {
private static IProxyData[] toArray(List proxies) {
return (IProxyData[]) proxies.toArray(new IProxyData[proxies.size()]);
}
+
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/net/proxy/IProxyData.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/net/proxy/IProxyData.java
index f98533acb..951bad22d 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/net/proxy/IProxyData.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/net/proxy/IProxyData.java
@@ -164,11 +164,28 @@ public interface IProxyData {
void setSource(String source);
/**
- * Set the values of this data to represent a disabling of its type.
- * Note that the proxy type will not be disabled unless the client
- * calls {@link IProxyService#setProxyData(IProxyData[])} with the
- * disabled data as a parameter. A proxy data can be enabled by setting
- * the host.
+ * Returns if the proxy data is obtained from a dynamic source, a PAC script
+ * for example.
+ *
+ * @return if proxy setting is dynamic
+ * @since 1.2
+ */
+ boolean isDynamic();
+
+ /**
+ * Sets if the proxy data is obtained from a dynamic source, a PAC script
+ * for example.
+ *
+ * @param dynamic if proxy setting is dynamic
+ * @since 1.2
+ */
+ void setDynamic(boolean dynamic);
+
+ /**
+ * Set the values of this data to represent a disabling of its type. Note
+ * that the proxy type will not be disabled unless the client calls
+ * {@link IProxyService#setProxyData(IProxyData[])} with the disabled data
+ * as a parameter. A proxy data can be enabled by setting the host.
*/
void disable();
diff --git a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java
index 024512322..c999841b9 100644
--- a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java
+++ b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java
@@ -18,6 +18,7 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.internal.net.ProxyData;
+import org.eclipse.core.internal.net.ProxySelector;
import org.eclipse.core.net.proxy.IProxyData;
import org.eclipse.core.net.proxy.IProxyService;
@@ -119,6 +120,20 @@ public class SystemProxyTest extends TestCase {
assertEquals(3, typeMap.size());
}
+ private void checkProxySelector() {
+ IProxyData[] proxiesData = ProxySelector.getProxyData("Native");
+ assertNotNull(proxiesData);
+
+ Map typeMap = new HashMap();
+ for (int i = 0; i < proxiesData.length; i++) {
+ assertProxyDataEqual(proxiesData[i], (IProxyData) proxyDataMap
+ .get(proxiesData[i].getType()));
+ typeMap.put(proxiesData[i].getType(), proxiesData[i].getType());
+ }
+
+ assertEquals(3, typeMap.size());
+ }
+
/**
* This test needs system env set. See {@link #initializeTestProxyData()}
* for values.
@@ -129,6 +144,15 @@ public class SystemProxyTest extends TestCase {
}
/**
+ * This test needs system env set. See {@link #initializeTestProxyData()}
+ * for values.
+ */
+ public void testProxySelector_LinuxEnvSettings() {
+ initializeTestProxyData("LINUX_ENV");
+ checkProxySelector();
+ }
+
+ /**
* This test needs Gnome settings set. See
* {@link #initializeTestProxyData()} for values.
*/
@@ -138,6 +162,15 @@ public class SystemProxyTest extends TestCase {
}
/**
+ * This test needs Gnome settings set. See
+ * {@link #initializeTestProxyData()} for values.
+ */
+ public void testProxySelector_LinuxGnomeSettings() {
+ initializeTestProxyData("LINUX_GNOME");
+ checkProxySelector();
+ }
+
+ /**
* This test needs Windows IE settings manually set. See
* {@link #initializeTestProxyData()} for values.
*/
@@ -146,6 +179,15 @@ public class SystemProxyTest extends TestCase {
checkGetProxyDataForHost();
}
+ /**
+ * This test needs Windows IE settings manually set. See
+ * {@link #initializeTestProxyData()} for values.
+ */
+ public void testProxySelector_WindowsIEManualSettings() {
+ initializeTestProxyData("WINDOWS_IE");
+ checkProxySelector();
+ }
+
private void initializeTestProxyData(String proxyDataSource) {
proxyDataMap.put(IProxyData.HTTP_PROXY_TYPE, new ProxyData(
IProxyData.HTTP_PROXY_TYPE, "127.0.0.1", 8081, false,

Back to the top