@@ -629,47 +629,43 @@ private static SSLContext buildSSLContext(SplitClientConfig config) throws IOExc
629629 private static HttpClientBuilder setupProxy (HttpClientBuilder httpClientbuilder , SplitClientConfig config ) {
630630 _log .info ("Initializing Split SDK with proxy settings" );
631631 HttpHost proxyHost ;
632- if (config .proxyConfiguration () != null && config .proxyConfiguration ().getHost () != null ) {
632+ String userName = null ;
633+ String password = null ;
634+ if (config .proxyConfiguration () != null ) {
633635 proxyHost = config .proxyConfiguration ().getHost ();
634- } else {
635- _log .warn ("`proxyHost`, `proxyPort` configuration methods are deprecated. Please use `ProxyConfiguration` builder instead." );
636- proxyHost = config .proxy ();
637- }
638- DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner (proxyHost );
639- httpClientbuilder .setRoutePlanner (routePlanner );
640-
641- if ((config .proxyUsername () != null && config .proxyPassword () != null ) ||
642- (config .proxyConfiguration () != null && config .proxyConfiguration ().getProxyCredentialsProvider () != null &&
643- config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BasicCredentialsProvider )) {
644- _log .debug ("Proxy setup using credentials" );
645- String userName ;
646- String password ;
647- if (config .proxyUsername () == null && config .proxyPassword () == null ) {
636+ if (config .proxyConfiguration ().getProxyCredentialsProvider () != null &&
637+ config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BasicCredentialsProvider ) {
648638 io .split .client .dtos .BasicCredentialsProvider basicAuth =
649639 (io .split .client .dtos .BasicCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ();
650640 userName = basicAuth .getUsername ();
651641 password = basicAuth .getPassword ();
652- } else {
653- _log .warn ("`proxyUsername` and `proxyPassword` configuration methods are deprecated. " +
654- "Please use `ProxyConfiguration` builder instead." );
642+ }
643+ if (config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BearerCredentialsProvider ) {
644+ _log .debug ("Proxy setup using Bearer token" );
645+ httpClientbuilder .setDefaultCredentialsProvider (new HttpClientDynamicCredentials (
646+ (BearerCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ()));
647+ }
648+ } else {
649+ proxyHost = config .proxy ();
650+ if (config .proxyUsername () != null && config .proxyPassword () != null ) {
655651 userName = config .proxyUsername ();
656652 password = config .proxyPassword ();
657653 }
654+ }
655+
656+ DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner (proxyHost );
657+ httpClientbuilder .setRoutePlanner (routePlanner );
658+
659+ if (userName != null && password != null ) {
660+ _log .debug ("Proxy setup using credentials" );
658661 BasicCredentialsProvider credsProvider = new BasicCredentialsProvider ();
659662 AuthScope siteScope = new AuthScope (proxyHost .getHostName (), proxyHost .getPort ());
660663 Credentials siteCreds = new UsernamePasswordCredentials (userName ,
661664 password .toCharArray ());
662665 credsProvider .setCredentials (siteScope , siteCreds );
663666 httpClientbuilder .setDefaultCredentialsProvider (credsProvider );
664667 }
665-
666- if (config .proxyConfiguration () != null &&
667- config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BearerCredentialsProvider ) {
668- _log .debug ("Proxy setup using Bearer token" );
669- httpClientbuilder .setDefaultCredentialsProvider (new HttpClientDynamicCredentials (
670- (BearerCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ()));
671- }
672-
668+
673669 return httpClientbuilder ;
674670 }
675671
0 commit comments