Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java6
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java61
-rw-r--r--bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java4
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java40
4 files changed, 87 insertions, 24 deletions
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 87b604600..06a75d4a3 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 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
@@ -268,7 +268,7 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener {
private void updateSystemProperties() {
for (int i = 0; i < proxies.length; i++) {
ProxyType type = proxies[i];
- type.updateSystemProperties(internalGetProxyData(type.getName(), ProxyType.DO_NOT_VERIFY), internalIsProxiesEnabled());
+ type.updateSystemProperties(internalGetProxyData(type.getName(), ProxyType.DO_NOT_VERIFY));
}
}
@@ -278,7 +278,7 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener {
// Now initialize each proxy type
for (int i = 0; i < proxies.length; i++) {
ProxyType type = proxies[i];
- type.initialize(internalIsProxiesEnabled());
+ type.initialize();
}
registerAuthenticator();
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java
index eb2c7d187..b544efba2 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 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
@@ -168,7 +168,7 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
} finally {
updatingPreferences = false;
}
- updateSystemProperties(proxyData, proxiesEnabled);
+ updateSystemProperties(proxyData);
return true;
}
@@ -205,14 +205,14 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
}
}
- /* package */void updateSystemProperties(IProxyData proxyData, boolean proxiesEnabled) {
+ /* package */void updateSystemProperties(IProxyData proxyData) {
try {
if (proxyData.getType().equals(IProxyData.HTTP_PROXY_TYPE)) {
- updateHttpSystemProperties(proxyData, proxiesEnabled);
+ updateHttpSystemProperties();
} else if (proxyData.getType().equals(IProxyData.HTTPS_PROXY_TYPE)) {
- updateHttpsSystemProperties(proxyData, proxiesEnabled);
+ updateHttpsSystemProperties();
} else if (proxyData.getType().equals(IProxyData.SOCKS_PROXY_TYPE)) {
- updateSocksSystemProperties(proxyData, proxiesEnabled);
+ updateSocksSystemProperties();
}
} catch (SecurityException e) {
Activator.logError("A security exception occurred while trying to put the proxy data into the system properties", e); //$NON-NLS-1$
@@ -378,10 +378,12 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
return name;
}
- private void updateHttpSystemProperties(IProxyData data, boolean proxiesEnabled) {
+ private void updateHttpSystemProperties() {
+ IProxyData data = getProxyData(IProxyData.HTTP_PROXY_TYPE);
+ boolean proxiesEnabled = isProxyEnabled();
Assert.isTrue(data.getType().equals(IProxyData.HTTP_PROXY_TYPE));
Properties sysProps = System.getProperties();
- if (!proxiesEnabled || data.getHost() == null) {
+ if (!proxiesEnabled || data.getHost() == null || data.getHost().equals("")) { //$NON-NLS-1$
sysProps.remove("http.proxySet"); //$NON-NLS-1$
sysProps.remove("http.proxyHost"); //$NON-NLS-1$
sysProps.remove("http.proxyPort"); //$NON-NLS-1$
@@ -399,7 +401,7 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
sysProps.put("http.proxyPort", String.valueOf(port)); //$NON-NLS-1$
}
sysProps.put("http.nonProxyHosts", //$NON-NLS-1$
- convertHostsToPropertyString(ProxyManager.getProxyManager().getNonProxiedHosts()));
+ convertHostsToPropertyString(getNonProxiedHosts()));
String userid = data.getUserId();
String password = data.getPassword();
@@ -415,11 +417,32 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
}
}
}
-
- private void updateHttpsSystemProperties(IProxyData data, boolean proxiesEnabled) {
+
+ private boolean isProxyEnabled() {
+ return !ProxySelector.getDefaultProvider().equalsIgnoreCase("DIRECT"); //$NON-NLS-1$
+ }
+
+ private IProxyData getProxyData(String type) {
+ IProxyData data[] = ProxySelector.getProxyData(ProxySelector
+ .getDefaultProvider());
+ for (int i = 0; i < data.length; i++) {
+ if (data[i].getType().equalsIgnoreCase(type)) {
+ return data[i];
+ }
+ }
+ return new ProxyData(type, null, -1, false, null);
+ }
+
+ private String[] getNonProxiedHosts() {
+ return ProxySelector.getBypassHosts(ProxySelector.getDefaultProvider());
+ }
+
+ private void updateHttpsSystemProperties() {
+ IProxyData data = getProxyData(IProxyData.HTTPS_PROXY_TYPE);
+ boolean proxiesEnabled = isProxyEnabled();
Assert.isTrue(data.getType().equals(IProxyData.HTTPS_PROXY_TYPE));
Properties sysProps = System.getProperties();
- if (!proxiesEnabled || data.getHost() == null) {
+ if (!proxiesEnabled || data.getHost() == null || data.getHost().equals("")) { //$NON-NLS-1$
sysProps.remove("https.proxySet"); //$NON-NLS-1$
sysProps.remove("https.proxyHost"); //$NON-NLS-1$
sysProps.remove("https.proxyPort"); //$NON-NLS-1$
@@ -437,7 +460,7 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
sysProps.put("https.proxyPort", String.valueOf(port)); //$NON-NLS-1$
}
sysProps.put("https.nonProxyHosts", //$NON-NLS-1$
- convertHostsToPropertyString(ProxyManager.getProxyManager().getNonProxiedHosts()));
+ convertHostsToPropertyString(getNonProxiedHosts()));
String userid = data.getUserId();
String password = data.getPassword();
@@ -454,10 +477,12 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
}
}
- private void updateSocksSystemProperties(IProxyData data, boolean proxiesEnabled) {
+ private void updateSocksSystemProperties() {
+ IProxyData data = getProxyData(IProxyData.SOCKS_PROXY_TYPE);
+ boolean proxiesEnabled = isProxyEnabled();
Assert.isTrue(data.getType().equals(IProxyData.SOCKS_PROXY_TYPE));
Properties sysProps = System.getProperties();
- if (!proxiesEnabled || data.getHost() == null) {
+ if (!proxiesEnabled || data.getHost() == null || data.getHost().equals("")) { //$NON-NLS-1$
sysProps.remove("socksProxyHost"); //$NON-NLS-1$
sysProps.remove("socksProxyPort"); //$NON-NLS-1$
} else {
@@ -480,8 +505,8 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
}
}
- public void initialize(boolean proxiesEnabled) {
- updateSystemProperties(getProxyData(VERIFY_EMPTY), proxiesEnabled);
+ public void initialize() {
+ updateSystemProperties(getProxyData(VERIFY_EMPTY));
((IEclipsePreferences)getParentPreferences()).addNodeChangeListener(this);
((IEclipsePreferences)getPreferenceNode()).addPreferenceChangeListener(this);
}
@@ -559,7 +584,7 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener
public void preferenceChange(PreferenceChangeEvent event) {
if (updatingPreferences)
return;
- updateSystemProperties(getProxyData(DO_NOT_VERIFY), ProxyManager.getProxyManager().isProxiesEnabled());
+ updateSystemProperties(getProxyData(DO_NOT_VERIFY));
}
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java
index e9b0a37a6..1b38c2aa5 100644
--- a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java
+++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 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
@@ -95,9 +95,9 @@ public class ProxyPreferencePage extends PreferencePage implements
protected void performApply() {
int sel = providerCombo.getSelectionIndex();
- ProxySelector.setDefaultProvider(providerCombo.getItem(sel));
proxyEntriesComposite.performApply();
nonProxyHostsComposite.performApply();
+ ProxySelector.setDefaultProvider(providerCombo.getItem(sel));
}
protected void performDefaults() {
diff --git a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
index e48208d74..0928feaec 100644
--- a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
+++ b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 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
@@ -388,4 +388,42 @@ public class NetTest extends TestCase {
assertEquals(data3.length, 0);
}
+ public void testBug257503() throws CoreException {
+ setDataTest(IProxyData.HTTP_PROXY_TYPE);
+ setDataTest(IProxyData.HTTPS_PROXY_TYPE);
+ setDataTest(IProxyData.SOCKS_PROXY_TYPE);
+
+ validateSystemProperties(true);
+ setSystemProxiesEnabled(true);
+ validateSystemProperties(false);
+ setSystemProxiesEnabled(false);
+ validateSystemProperties(true);
+
+ }
+
+ private void validateSystemProperties(boolean present) {
+ validateProperty("http.proxySet", "true", present);
+ validateProperty("http.proxyHost", "www.eclipse.org", present);
+ validateProperty("http.proxyPort", "1024", present);
+ validateProperty("http.proxyUser", "me", present);
+ validateProperty("http.proxyUserName", "me", present);
+ validateProperty("http.proxyPassword", "passw0rd", present);
+
+ validateProperty("https.proxySet", "true", present);
+ validateProperty("https.proxyHost", "www.eclipse.org", present);
+ validateProperty("https.proxyPort", "1024", present);
+ validateProperty("https.proxyUser", "me", present);
+ validateProperty("https.proxyUserName", "me", present);
+ validateProperty("https.proxyPassword", "passw0rd", present);
+
+ validateProperty("socksProxyHost", "www.eclipse.org", present);
+ validateProperty("socksProxyPort", "1024", present);
+ }
+
+ private void validateProperty(String key, String expected, boolean equals) {
+ String actual = System.getProperties().getProperty(key);
+ assertTrue((equals && expected.equals(actual))
+ || (!equals && !expected.equals(actual)));
+ }
+
}

Back to the top