11package io .split .client ;
22
3+ import io .split .client .dtos .ProxyMTLSAuth ;
34import io .split .client .impressions .ImpressionListener ;
45import io .split .client .impressions .ImpressionsManager ;
56import io .split .client .utils .FileTypeEnum ;
@@ -85,6 +86,8 @@ public class SplitClientConfig {
8586 private final HttpHost _proxy ;
8687 private final String _proxyUsername ;
8788 private final String _proxyPassword ;
89+ private final String _proxyToken ;
90+ private final ProxyMTLSAuth _proxyMtlsAuth ;
8891
8992 // To be set during startup
9093 public static String splitSdkVersion ;
@@ -118,6 +121,8 @@ private SplitClientConfig(String endpoint,
118121 HttpHost proxy ,
119122 String proxyUsername ,
120123 String proxyPassword ,
124+ String proxyToken ,
125+ ProxyMTLSAuth proxyMtlsAuth ,
121126 int eventsQueueSize ,
122127 long eventSendIntervalInMillis ,
123128 int maxStringLength ,
@@ -171,6 +176,8 @@ private SplitClientConfig(String endpoint,
171176 _proxy = proxy ;
172177 _proxyUsername = proxyUsername ;
173178 _proxyPassword = proxyPassword ;
179+ _proxyToken = proxyToken ;
180+ _proxyMtlsAuth = proxyMtlsAuth ;
174181 _eventsQueueSize = eventsQueueSize ;
175182 _eventSendIntervalInMillis = eventSendIntervalInMillis ;
176183 _maxStringLength = maxStringLength ;
@@ -302,6 +309,14 @@ public String proxyPassword() {
302309 return _proxyPassword ;
303310 }
304311
312+ public String proxyToken () {
313+ return _proxyToken ;
314+ }
315+
316+ public ProxyMTLSAuth proxyMTLSAuth () {
317+ return _proxyMtlsAuth ;
318+ }
319+
305320 public long eventSendIntervalInMillis () {
306321 return _eventSendIntervalInMillis ;
307322 }
@@ -417,8 +432,8 @@ public boolean isSdkEndpointOverridden() {
417432 }
418433
419434 public CustomHttpModule alternativeHTTPModule () { return _alternativeHTTPModule ; }
420- public static final class Builder {
421435
436+ public static final class Builder {
422437 private String _endpoint = SDK_ENDPOINT ;
423438 private boolean _endpointSet = false ;
424439 private String _eventsEndpoint = EVENTS_ENDPOINT ;
@@ -442,6 +457,8 @@ public static final class Builder {
442457 private int _proxyPort = -1 ;
443458 private String _proxyUsername ;
444459 private String _proxyPassword ;
460+ private String _proxyToken ;
461+ private ProxyMTLSAuth _proxyMtlsAuth ;
445462 private int _eventsQueueSize = 500 ;
446463 private long _eventSendIntervalInMillis = 30 * (long )1000 ;
447464 private int _maxStringLength = 250 ;
@@ -776,6 +793,28 @@ public Builder proxyPassword(String proxyPassword) {
776793 return this ;
777794 }
778795
796+ /**
797+ * Set the token for authentication against the proxy (if proxy settings are enabled). (Optional).
798+ *
799+ * @param proxyToken
800+ * @return this builder
801+ */
802+ public Builder proxyToken (String proxyToken ) {
803+ _proxyToken = proxyToken ;
804+ return this ;
805+ }
806+
807+ /**
808+ * Set the mtls authentication against the proxy (if proxy settings are enabled). (Optional).
809+ *
810+ * @param proxyMtlsAuth
811+ * @return this builder
812+ */
813+ public Builder proxyMtlsAuth (ProxyMTLSAuth proxyMtlsAuth ) {
814+ _proxyMtlsAuth = proxyMtlsAuth ;
815+ return this ;
816+ }
817+
779818 /**
780819 * Disables running destroy() on shutdown by default.
781820 *
@@ -1096,6 +1135,34 @@ private void verifyAlternativeClient() {
10961135 }
10971136 }
10981137
1138+ private void verifyProxy () {
1139+ if (_proxyPort == -1 ) {
1140+ return ;
1141+ }
1142+
1143+ if (_proxyUsername == null && _proxyToken == null && _proxyMtlsAuth == null ) {
1144+ return ;
1145+ }
1146+
1147+ if (_proxyUsername != null && _proxyToken != null ) {
1148+ throw new IllegalArgumentException ("Proxy user and Proxy token params are updated, set only one param." );
1149+ }
1150+
1151+ if (_proxyUsername != null && _proxyMtlsAuth != null ) {
1152+ throw new IllegalArgumentException ("Proxy user and Proxy mTLS params are updated, set only one param." );
1153+ }
1154+
1155+ if (_proxyToken != null && _proxyMtlsAuth != null ) {
1156+ throw new IllegalArgumentException ("Proxy token and Proxy mTLS params are updated, set only one param." );
1157+ }
1158+
1159+ if (_proxyMtlsAuth != null ) {
1160+ if (_proxyMtlsAuth .getP12File () == null || _proxyMtlsAuth .getP12FilePassKey () == null ) {
1161+ throw new IllegalArgumentException ("Proxy mTLS must have p12 file path and name, and pass phrase." );
1162+ }
1163+ }
1164+ }
1165+
10991166 public SplitClientConfig build () {
11001167
11011168 verifyRates ();
@@ -1108,6 +1175,8 @@ public SplitClientConfig build() {
11081175
11091176 verifyAlternativeClient ();
11101177
1178+ verifyProxy ();
1179+
11111180 if (_numThreadsForSegmentFetch <= 0 ) {
11121181 throw new IllegalArgumentException ("Number of threads for fetching segments MUST be greater than zero" );
11131182 }
@@ -1133,6 +1202,8 @@ public SplitClientConfig build() {
11331202 proxy (),
11341203 _proxyUsername ,
11351204 _proxyPassword ,
1205+ _proxyToken ,
1206+ _proxyMtlsAuth ,
11361207 _eventsQueueSize ,
11371208 _eventSendIntervalInMillis ,
11381209 _maxStringLength ,
0 commit comments