Fixed proxy authentication: previous type wasn't discarded (so http didn't work).

This commit is contained in:
magenoxx 2011-05-19 13:56:53 +04:00
parent 67ec4bf3bd
commit 2efe38b96b

View file

@ -102,6 +102,13 @@ public class Session {
System.setSecurityManager(null); System.setSecurityManager(null);
System.setProperty("http.nonProxyHosts", "code.google.com"); System.setProperty("http.nonProxyHosts", "code.google.com");
System.setProperty("socksNonProxyHosts", "code.google.com"); System.setProperty("socksNonProxyHosts", "code.google.com");
// clear previous values
System.clearProperty("socksProxyHost");
System.clearProperty("socksProxyPort");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
switch (connection.getProxyType()) { switch (connection.getProxyType()) {
case SOCKS: case SOCKS:
System.setProperty("socksProxyHost", connection.getProxyHost()); System.setProperty("socksProxyHost", connection.getProxyHost());
@ -112,12 +119,6 @@ public class Session {
System.setProperty("http.proxyPort", Integer.toString(connection.getProxyPort())); System.setProperty("http.proxyPort", Integer.toString(connection.getProxyPort()));
Authenticator.setDefault(new MageAuthenticator(connection.getProxyUsername(), connection.getProxyPassword())); Authenticator.setDefault(new MageAuthenticator(connection.getProxyUsername(), connection.getProxyPassword()));
break; break;
default:
System.clearProperty("socksProxyHost");
System.clearProperty("socksProxyPort");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
break;
} }
Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort()); Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort());
this.server = (Server) reg.lookup(Config.remoteServer); this.server = (Server) reg.lookup(Config.remoteServer);