summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/network/ProxyConfiguration.java
diff options
context:
space:
mode:
authorSimon Rettberg2014-11-18 15:48:30 +0100
committerSimon Rettberg2014-11-18 15:48:30 +0100
commitb1641d24dad8f1d79b282b4bafff9b52c21986b1 (patch)
treedf87724fefa7ccd73965de79eaf30e4c5bab0297 /src/main/java/org/openslx/network/ProxyConfiguration.java
parentPimped thrift compilation script to warn if not using 0.9.1 (diff)
downloadmaster-sync-shared-b1641d24dad8f1d79b282b4bafff9b52c21986b1.tar.gz
master-sync-shared-b1641d24dad8f1d79b282b4bafff9b52c21986b1.tar.xz
master-sync-shared-b1641d24dad8f1d79b282b4bafff9b52c21986b1.zip
Reset proxy settings furst when configuring proxy
Diffstat (limited to 'src/main/java/org/openslx/network/ProxyConfiguration.java')
-rw-r--r--src/main/java/org/openslx/network/ProxyConfiguration.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/java/org/openslx/network/ProxyConfiguration.java b/src/main/java/org/openslx/network/ProxyConfiguration.java
index cfdcdb9..e4956fa 100644
--- a/src/main/java/org/openslx/network/ProxyConfiguration.java
+++ b/src/main/java/org/openslx/network/ProxyConfiguration.java
@@ -22,9 +22,14 @@ public class ProxyConfiguration
public static void configProxy()
{
+ // Reset proxy settings first
+ ProxySelector.setDefault( null );
+ Authenticator.setDefault( null );
+
// Configuring proxy settings. First read options from config file.
String proxyConfiguration = ProxyProperties.getProxyConf();
- if ( ( proxyConfiguration.equals( "AUTO" ) ) || ( proxyConfiguration.equals( "" ) ) ) {
+
+ if ( proxyConfiguration.equals( "AUTO" ) || proxyConfiguration.isEmpty() ) {
log.info( "Configuring proxy settings automatically..." );
// Configuring proxy settings automatically.
WpadProxySearchStrategy wPSS = new WpadProxySearchStrategy();
@@ -34,10 +39,13 @@ public class ProxyConfiguration
} catch ( ProxyException e ) {
log.error( "Setting proxy configuration automatically failed.", e );
}
- } else if ( proxyConfiguration.equals( "YES" ) ) {
+ return;
+ }
+
+ if ( proxyConfiguration.equals( "YES" ) ) {
// Take the proxy settings from config file.
// First check if one of the following necessary options might not be set.
- if ( ProxyProperties.checkProxySettings() ) {
+ if ( ProxyProperties.hasProxyAddress() ) {
String proxyAddress = ProxyProperties.getProxyAddress();
int proxyPort = ProxyProperties.getProxyPort();
@@ -46,7 +54,7 @@ public class ProxyConfiguration
StaticProxySelector sPS = new StaticProxySelector( proxy );
ProxySelector.setDefault( sPS );
- if ( ! ( ProxyProperties.getProxyUsername().equals( "" ) ) && ! ( ProxyProperties.getProxyPassword().equals( "" ) ) ) {
+ if ( !ProxyProperties.hasProxyCredentials() ) {
log.info( "Configuring proxy settings manually WITH authentication..." );
// use Proxy with authentication.
String proxyUname = ProxyProperties.getProxyUsername();
@@ -58,5 +66,7 @@ public class ProxyConfiguration
}
}
}
+
}
+
}