/** * ********************************************************************** Loads the proxy settings * from environment variables. * * @return a configured ProxySelector, null if none is found. * ********************************************************************** */ public ProxySelector getProxySelector() { log.debug("Inspecting environment variables."); // Check if http_proxy var is set. ProxySelector httpPS = ProxyUtil.parseProxySettings(this.httpProxy); if (httpPS == null) { return null; } log.debug("Http Proxy is {}", this.httpProxy); ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); ps.setSelector("http", httpPS); ProxySelector httpsPS = ProxyUtil.parseProxySettings(this.httpsProxy); log.debug("Https Proxy is {}", httpsPS == null ? this.httpsProxy : httpsPS); ps.setSelector("https", httpsPS != null ? httpsPS : httpPS); ProxySelector ftpPS = ProxyUtil.parseProxySettings(this.ftpProxy); if (ftpPS != null) { log.debug(String.format("Ftp Proxy is %s", this.ftpProxy)); ps.setSelector("ftp", ftpPS); } // Wrap with white list support ProxySelector result = ps; if (this.noProxy != null && this.noProxy.trim().length() > 0) { log.debug(String.format("Using proxy bypass list: %s", this.noProxy)); result = new ProxyBypassListSelector(this.noProxy, ps); } return result; }