11package io .split .client ;
22
3- import io .split .client .dtos .ProxyMTLSAuth ;
3+ import io .split .client .dtos .ProxyConfiguration ;
44import io .split .client .impressions .ImpressionListener ;
55import io .split .client .impressions .ImpressionsManager ;
66import io .split .client .utils .FileTypeEnum ;
@@ -91,11 +91,10 @@ private HttpScheme() {
9191 private final ThreadFactory _threadFactory ;
9292
9393 // Proxy configs
94+ private final ProxyConfiguration _proxyConfiguration ;
9495 private final HttpHost _proxy ;
9596 private final String _proxyUsername ;
9697 private final String _proxyPassword ;
97- private final ProxyCredentialsProvider _proxyCredentialsProvider ;
98- private final ProxyMTLSAuth _proxyMtlsAuth ;
9998
10099 // To be set during startup
101100 public static String splitSdkVersion ;
@@ -129,8 +128,7 @@ private SplitClientConfig(String endpoint,
129128 HttpHost proxy ,
130129 String proxyUsername ,
131130 String proxyPassword ,
132- ProxyCredentialsProvider proxyCredentialsProvider ,
133- ProxyMTLSAuth proxyMtlsAuth ,
131+ ProxyConfiguration proxyConfiguration ,
134132 int eventsQueueSize ,
135133 long eventSendIntervalInMillis ,
136134 int maxStringLength ,
@@ -184,8 +182,7 @@ private SplitClientConfig(String endpoint,
184182 _proxy = proxy ;
185183 _proxyUsername = proxyUsername ;
186184 _proxyPassword = proxyPassword ;
187- _proxyCredentialsProvider = proxyCredentialsProvider ;
188- _proxyMtlsAuth = proxyMtlsAuth ;
185+ _proxyConfiguration = proxyConfiguration ;
189186 _eventsQueueSize = eventsQueueSize ;
190187 _eventSendIntervalInMillis = eventSendIntervalInMillis ;
191188 _maxStringLength = maxStringLength ;
@@ -317,12 +314,8 @@ public String proxyPassword() {
317314 return _proxyPassword ;
318315 }
319316
320- public ProxyCredentialsProvider proxyCredentialsProvider () {
321- return _proxyCredentialsProvider ;
322- }
323-
324- public ProxyMTLSAuth proxyMTLSAuth () {
325- return _proxyMtlsAuth ;
317+ public ProxyConfiguration proxyConfiguration () {
318+ return _proxyConfiguration ;
326319 }
327320
328321 public long eventSendIntervalInMillis () {
@@ -463,11 +456,9 @@ public static final class Builder {
463456 private int _waitBeforeShutdown = 5000 ;
464457 private String _proxyHost = "localhost" ;
465458 private int _proxyPort = -1 ;
466- private String _proxyScheme = HttpScheme .HTTP ;
467459 private String _proxyUsername ;
468460 private String _proxyPassword ;
469- private ProxyCredentialsProvider _proxyCredentialsProvider ;
470- private ProxyMTLSAuth _proxyMtlsAuth ;
461+ private ProxyConfiguration _proxyConfiguration ;
471462 private int _eventsQueueSize = 500 ;
472463 private long _eventSendIntervalInMillis = 30 * (long )1000 ;
473464 private int _maxStringLength = 250 ;
@@ -760,43 +751,44 @@ public Builder waitBeforeShutdown(int waitTime) {
760751
761752 /**
762753 * The host location of the proxy. Default is localhost.
754+ * @deprecated
755+ * This method is deprecated.
756+ * <p> Use {@link ProxyConfiguration)} instead.
763757 *
764758 * @param proxyHost location of the proxy
765759 * @return this builder
766760 */
761+ @ Deprecated
767762 public Builder proxyHost (String proxyHost ) {
768763 _proxyHost = proxyHost ;
769764 return this ;
770765 }
771766
772767 /**
773768 * The port of the proxy. Default is -1.
769+ * @deprecated
770+ * This method is deprecated.
771+ * <p> Use {@link ProxyConfiguration)} instead.
774772 *
775773 * @param proxyPort port for the proxy
776774 * @return this builder
777775 */
776+ @ Deprecated
778777 public Builder proxyPort (int proxyPort ) {
779778 _proxyPort = proxyPort ;
780779 return this ;
781780 }
782781
783- /**
784- * The http scheme of the proxy. Default is http.
785- *
786- * @param proxyScheme protocol for the proxy
787- * @return this builder
788- */
789- public Builder proxyScheme (String proxyScheme ) {
790- _proxyScheme = proxyScheme ;
791- return this ;
792- }
793-
794782 /**
795783 * Set the username for authentication against the proxy (if proxy settings are enabled). (Optional).
784+ * @deprecated
785+ * This method is deprecated.
786+ * <p> Use {@link ProxyConfiguration)} instead.
796787 *
797788 * @param proxyUsername
798789 * @return this builder
799790 */
791+ @ Deprecated
800792 public Builder proxyUsername (String proxyUsername ) {
801793 _proxyUsername = proxyUsername ;
802794 return this ;
@@ -813,25 +805,14 @@ public Builder proxyPassword(String proxyPassword) {
813805 return this ;
814806 }
815807
816- /**
817- * Set the token for authentication against the proxy (if proxy settings are enabled). (Optional).
818- *
819- * @param proxyCredentialsProvider
820- * @return this builder
821- */
822- public Builder proxyCredentialsProvider (ProxyCredentialsProvider proxyCredentialsProvider ) {
823- _proxyCredentialsProvider = proxyCredentialsProvider ;
824- return this ;
825- }
826-
827808 /**
828809 * Set the mtls authentication against the proxy (if proxy settings are enabled). (Optional).
829810 *
830- * @param proxyMtlsAuth
811+ * @param proxyConfiguration
831812 * @return this builder
832813 */
833- public Builder proxyMtlsAuth ( ProxyMTLSAuth proxyMtlsAuth ) {
834- _proxyMtlsAuth = proxyMtlsAuth ;
814+ public Builder proxyConfiguration ( ProxyConfiguration proxyConfiguration ) {
815+ _proxyConfiguration = proxyConfiguration ;
835816 return this ;
836817 }
837818
@@ -847,7 +828,7 @@ public Builder disableDestroyOnShutDown() {
847828
848829 HttpHost proxy () {
849830 if (_proxyPort != -1 ) {
850- return new HttpHost (_proxyScheme , _proxyHost , _proxyPort );
831+ return new HttpHost (_proxyHost , _proxyPort );
851832 }
852833 // Default is no proxy.
853834 return null ;
@@ -986,7 +967,7 @@ public Builder operationMode(OperationMode mode) {
986967
987968 /**
988969 *
989- * @param storage mode
970+ * @param mode
990971 * @return this builder
991972 */
992973 public Builder storageMode (StorageMode mode ) {
@@ -1156,31 +1137,16 @@ private void verifyAlternativeClient() {
11561137 }
11571138
11581139 private void verifyProxy () {
1159- if (_proxyPort == - 1 ) {
1140+ if (_proxyConfiguration == null )
11601141 return ;
1161- }
11621142
1163- if (!(_proxyScheme .equals (HttpScheme .HTTP ) || _proxyScheme .equals (HttpScheme .HTTPS ))) {
1143+ if (!(_proxyConfiguration .getHost ().getSchemeName ().equals (HttpScheme .HTTP ) ||
1144+ _proxyConfiguration .getHost ().getSchemeName ().equals (HttpScheme .HTTPS ))) {
11641145 throw new IllegalArgumentException ("Proxy scheme must be either http or https." );
11651146 }
11661147
1167- if (_proxyUsername == null && _proxyCredentialsProvider == null && _proxyMtlsAuth == null ) {
1168- return ;
1169- }
1170-
1171- if (_proxyUsername != null && _proxyCredentialsProvider != null ) {
1172- throw new IllegalArgumentException ("Proxy user and Proxy token params are updated, set only one param." );
1173- }
1174-
1175- if (_proxyUsername != null && _proxyMtlsAuth != null ) {
1176- throw new IllegalArgumentException ("Proxy user and Proxy mTLS params are updated, set only one param." );
1177- }
1178-
1179- if (_proxyCredentialsProvider != null && _proxyMtlsAuth != null ) {
1180- throw new IllegalArgumentException ("Proxy token and Proxy mTLS params are updated, set only one param." );
1181- }
1182-
1183- if (_proxyMtlsAuth != null && (_proxyMtlsAuth .getP12File () == null || _proxyMtlsAuth .getP12FilePassKey () == null )) {
1148+ if ((_proxyConfiguration .getP12File () != null && _proxyConfiguration .getPassKey () == null ) ||
1149+ (_proxyConfiguration .getP12File () == null && _proxyConfiguration .getPassKey () != null )) {
11841150 throw new IllegalArgumentException ("Proxy mTLS must have p12 file path and name, and pass phrase." );
11851151 }
11861152 }
@@ -1224,8 +1190,7 @@ public SplitClientConfig build() {
12241190 proxy (),
12251191 _proxyUsername ,
12261192 _proxyPassword ,
1227- _proxyCredentialsProvider ,
1228- _proxyMtlsAuth ,
1193+ _proxyConfiguration ,
12291194 _eventsQueueSize ,
12301195 _eventSendIntervalInMillis ,
12311196 _maxStringLength ,
0 commit comments