List of usage examples for org.apache.commons.httpclient.contrib.proxy ProxyDetectionException ProxyDetectionException
public ProxyDetectionException(String message, Throwable cause)
From source file:org.apache.commons.httpclient.contrib.proxy.PluginProxyUtil.java
/** * Returns the proxy host information found by inspecting the system * property "javaplugin.proxy.config.list". * * @return ProxyHost the host and port of the proxy that should be used * @throws ProxyDetectionException if an exception is encountered while * parsing the value of * PLUGIN_PROXY_CONFIG_PROP *//*from w w w. ja v a 2 s . co m*/ private static HttpHost getPluginProxyConfigSettings() throws ProxyDetectionException { HttpHost result = null; try { Properties properties = System.getProperties(); String proxyList = properties.getProperty("javaplugin.proxy.config.list"); if (LOG.isDebugEnabled()) { LOG.debug("Plugin Proxy Config List Property:" + proxyList); } boolean useProxy = (proxyList != null); if (useProxy) { proxyList = proxyList.toUpperCase(Locale.getDefault()); // Using HTTP proxy as proxy for HTTP proxy tunnelled SSL // socket (should be listed FIRST).... // 1/14/03 1.3.1_06 appears to omit HTTP portion of // reported proxy list... Mod to accomodate this... // Expecting proxyList of "HTTP=XXX.XXX.XXX.XXX:Port" OR // "XXX.XXX.XXX.XXX:Port" & assuming HTTP... String proxyIP = ""; if (proxyList.indexOf("HTTP=") > -1) { proxyIP = proxyList.substring(proxyList.indexOf("HTTP=") + 5, proxyList.indexOf(":")); } else { proxyIP = proxyList.substring(0, proxyList.indexOf(":")); } int endOfPort = proxyList.indexOf(","); if (endOfPort < 1) { endOfPort = proxyList.length(); } String portString = proxyList.substring(proxyList.indexOf(":") + 1, endOfPort); int proxyPort = Integer.parseInt(portString); if (LOG.isDebugEnabled()) { LOG.debug("proxy " + proxyIP + " port " + proxyPort); } result = new HttpHost(proxyIP, proxyPort); } else { LOG.debug("No configured plugin proxy list"); result = NO_PROXY_HOST; } } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Exception during failover auto proxy detection, " + ", e:" + e); throw new ProxyDetectionException("Encountered unexpected exception while attempting " + "to parse proxy information stored in " + PLUGIN_PROXY_CONFIG_PROP, e); } } return result; }