private void configureProxyServers() throws Exception {
getBootProgressMonitor().updateMessage("Configuring proxy servers");
getBootProgressMonitor().updateProgress(5);
String httpProxyHost = contextConfiguration.retrieveProperty(new ContextKey("proxies.http.proxyHost"));
if (!httpProxyHost.equals("")) {
if (log.isInfoEnabled())
log.info("Configuring outgoing HTTP connections to use a proxy server.");
System.setProperty("http.proxyHost", httpProxyHost);
System.setProperty("com.maverick.ssl.https.HTTPProxyHostname", httpProxyHost);
String httpProxyPort = contextConfiguration.retrieveProperty(new ContextKey("proxies.http.proxyPort"));
String httpProxyUsername = contextConfiguration.retrieveProperty(new ContextKey("proxies.http.proxyUser"));
String httpProxyPassword = contextConfiguration.retrieveProperty(new ContextKey("proxies.http.proxyPassword"));
System.setProperty("http.proxyPort", httpProxyPort);
System.setProperty("com.maverick.ssl.https.HTTPProxyPort", httpProxyPort);
if (!httpProxyUsername.trim().equals(""))
System.setProperty("com.maverick.ssl.https.HTTPProxyUsername", httpProxyUsername.trim());
if (!httpProxyPassword.trim().equals(""))
System.setProperty("com.maverick.ssl.https.HTTPProxyPassword", httpProxyPassword.trim());
System.setProperty("com.maverick.ssl.https.HTTPProxySecure", "false");
PropertyList list = contextConfiguration.retrievePropertyList(new ContextKey("proxies.http.nonProxyHosts"));
StringBuffer hosts = new StringBuffer();
for (Iterator i = list.iterator(); i.hasNext();) {
if (hosts.length() != 0) {
hosts.append("|");
}
hosts.append(i.next());
}
System.setProperty("http.nonProxyHosts", hosts.toString());
System.setProperty("com.maverick.ssl.https.HTTPProxyNonProxyHosts", hosts.toString());
}
String socksProxyHost = contextConfiguration.retrieveProperty(new ContextKey("proxies.socksProxyHost"));
if (!socksProxyHost.equals("")) {
if (log.isInfoEnabled())
log.info("Configuring outgoing TCP/IP connections to use a SOCKS proxy server.");
System.setProperty("socksProxyHost", httpProxyHost);
System.setProperty("socksProxyPort", contextConfiguration.retrieveProperty(new ContextKey("proxies.socksProxyPort")));
}
if (!socksProxyHost.equals("") || !httpProxyHost.equals("")) {
Authenticator.setDefault(new ProxyAuthenticator());
}
}