protected Proxy getProxy ( final Settings settings , final String serverId , final String host ) { if ( settings == null ) return null ; List < Proxy > proxies = settings . getProxies ( ) ; if ( proxies == null || proxies . isEmpty ( ) ) return null ; // search id match first if ( serverId != null && ! serverId . isEmpty ( ) ) { for ( Proxy proxy : proxies ) { if ( proxy . isActive ( ) ) { final String proxyId = proxy . getId ( ) ; if ( proxyId != null && ! proxyId . isEmpty ( ) ) { if ( proxyId . equalsIgnoreCase ( serverId ) ) { if ( ( "http" . equalsIgnoreCase ( proxy . getProtocol ( ) ) || "https" . equalsIgnoreCase ( proxy . getProtocol ( ) ) ) ) { if ( matchNonProxy ( proxy , host ) ) return null ; else return proxy ; } } } } } } // search active proxy for ( Proxy proxy : proxies ) if ( proxy . isActive ( ) && ( "http" . equalsIgnoreCase ( proxy . getProtocol ( ) ) || "https" . equalsIgnoreCase ( proxy . getProtocol ( ) ) ) ) { if ( matchNonProxy ( proxy , host ) ) return null ; else return proxy ; } return null ; }
Get proxy from settings