26
26
import org .apache .http .conn .ssl .DefaultHostnameVerifier ;
27
27
import org .apache .http .conn .ssl .SSLConnectionSocketFactory ;
28
28
import org .apache .http .ssl .SSLContexts ;
29
+ import org .apache .http .util .TextUtils ;
29
30
30
31
import javax .net .ssl .HostnameVerifier ;
31
32
import javax .net .ssl .SSLContext ;
@@ -103,6 +104,22 @@ public EwsSSLProtocolSocketFactory(
103
104
this .sslcontext = context ;
104
105
}
105
106
107
+ /**
108
+ * Constructor for EasySSLProtocolSocketFactory.
109
+ *
110
+ * @param context SSL context
111
+ * @param supportedProtocols protocol from sys prop
112
+ * @param supportedCipherSuites cipherSuites from sys prop
113
+ * @param hostnameVerifier hostname verifier
114
+ */
115
+ public EwsSSLProtocolSocketFactory (
116
+ SSLContext context ,String [] supportedProtocols , String [] supportedCipherSuites ,
117
+ HostnameVerifier hostnameVerifier
118
+ ) {
119
+ super (context ,supportedProtocols ,supportedCipherSuites , hostnameVerifier );
120
+ this .sslcontext = context ;
121
+ }
122
+
106
123
107
124
/**
108
125
* Create and configure SSL protocol socket factory using default hostname verifier.
@@ -129,7 +146,22 @@ public static EwsSSLProtocolSocketFactory build(
129
146
TrustManager trustManager , HostnameVerifier hostnameVerifier
130
147
) throws GeneralSecurityException {
131
148
SSLContext sslContext = createSslContext (trustManager );
132
- return new EwsSSLProtocolSocketFactory (sslContext , hostnameVerifier );
149
+
150
+ //read system properties
151
+ String [] keepAliveStrategyCopy ;
152
+ keepAliveStrategyCopy = split (System .getProperty ("https.protocols" ));
153
+ String [] targetAuthStrategyCopy ;
154
+ targetAuthStrategyCopy = split (System .getProperty ("https.cipherSuites" ));
155
+
156
+ if (null != keepAliveStrategyCopy || null != targetAuthStrategyCopy ) {
157
+ return new EwsSSLProtocolSocketFactory (sslContext ,keepAliveStrategyCopy ,targetAuthStrategyCopy , hostnameVerifier );
158
+ } else {
159
+ return new EwsSSLProtocolSocketFactory (sslContext , hostnameVerifier );
160
+ }
161
+ }
162
+
163
+ private static String [] split (String s ) {
164
+ return TextUtils .isBlank (s )?null :s .split (" *, *" );
133
165
}
134
166
135
167
/**
0 commit comments