@@ -628,34 +628,48 @@ private static SSLContext buildSSLContext(SplitClientConfig config) throws IOExc
628628
629629 private static HttpClientBuilder setupProxy (HttpClientBuilder httpClientbuilder , SplitClientConfig config ) {
630630 _log .info ("Initializing Split SDK with proxy settings" );
631+ if (config .proxyConfiguration () != null ) {
632+ return useProxyConfiguration (httpClientbuilder , config );
633+ } else {
634+ return useLegacyProxyConfiguration (httpClientbuilder , config );
635+ }
636+ }
637+
638+ private static HttpClientBuilder useLegacyProxyConfiguration (HttpClientBuilder httpClientbuilder , SplitClientConfig config ) {
631639 HttpHost proxyHost ;
632640 String userName = null ;
633641 String password = null ;
634- if (config .proxyConfiguration () != null ) {
635- proxyHost = config .proxyConfiguration ().getHost ();
636- if (config .proxyConfiguration ().getProxyCredentialsProvider () != null ) {
637- if (config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BasicCredentialsProvider ) {
638- io .split .client .dtos .BasicCredentialsProvider basicAuth =
639- (io .split .client .dtos .BasicCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ();
640- userName = basicAuth .getUsername ();
641- password = basicAuth .getPassword ();
642- } else if (config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BearerCredentialsProvider ) {
643- _log .debug ("Proxy setup using Bearer token" );
644- httpClientbuilder .setDefaultCredentialsProvider (new HttpClientDynamicCredentials (
645- (BearerCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ()));
646- }
647- }
648- } else {
649- proxyHost = config .proxy ();
650- if (config .proxyUsername () != null && config .proxyPassword () != null ) {
651- userName = config .proxyUsername ();
652- password = config .proxyPassword ();
642+ proxyHost = config .proxy ();
643+ if (config .proxyUsername () != null && config .proxyPassword () != null ) {
644+ userName = config .proxyUsername ();
645+ password = config .proxyPassword ();
646+ }
647+ return addProxyParams (httpClientbuilder , proxyHost , userName , password );
648+ }
649+
650+ private static HttpClientBuilder useProxyConfiguration (HttpClientBuilder httpClientbuilder , SplitClientConfig config ) {
651+ HttpHost proxyHost ;
652+ String userName = null ;
653+ String password = null ;
654+ proxyHost = config .proxyConfiguration ().getHost ();
655+ if (config .proxyConfiguration ().getProxyCredentialsProvider () != null ) {
656+ if (config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BasicCredentialsProvider ) {
657+ io .split .client .dtos .BasicCredentialsProvider basicAuth =
658+ (io .split .client .dtos .BasicCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ();
659+ userName = basicAuth .getUsername ();
660+ password = basicAuth .getPassword ();
661+ } else if (config .proxyConfiguration ().getProxyCredentialsProvider () instanceof io .split .client .dtos .BearerCredentialsProvider ) {
662+ _log .debug ("Proxy setup using Bearer token" );
663+ httpClientbuilder .setDefaultCredentialsProvider (new HttpClientDynamicCredentials (
664+ (BearerCredentialsProvider ) config .proxyConfiguration ().getProxyCredentialsProvider ()));
653665 }
654666 }
667+ return addProxyParams (httpClientbuilder , proxyHost , userName , password );
668+ }
655669
670+ private static HttpClientBuilder addProxyParams (HttpClientBuilder httpClientbuilder , HttpHost proxyHost , String userName , String password ) {
656671 DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner (proxyHost );
657672 httpClientbuilder .setRoutePlanner (routePlanner );
658-
659673 if (userName != null && password != null ) {
660674 _log .debug ("Proxy setup using Basic authentication" );
661675 BasicCredentialsProvider credsProvider = new BasicCredentialsProvider ();
@@ -665,7 +679,6 @@ private static HttpClientBuilder setupProxy(HttpClientBuilder httpClientbuilder,
665679 credsProvider .setCredentials (siteScope , siteCreds );
666680 httpClientbuilder .setDefaultCredentialsProvider (credsProvider );
667681 }
668-
669682 return httpClientbuilder ;
670683 }
671684
0 commit comments