Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
fix issue 580: call constructor based on sys prop
Browse files Browse the repository at this point in the history
  • Loading branch information
pheenomenon committed Aug 22, 2017
1 parent 0e1ba52 commit de58c02
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.TextUtils;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -103,6 +104,22 @@ public EwsSSLProtocolSocketFactory(
this.sslcontext = context;
}

/**
* Constructor for EasySSLProtocolSocketFactory.
*
* @param context SSL context
* @param supportedProtocols protocol from sys prop
* @param supportedCipherSuites cipherSuites from sys prop
* @param hostnameVerifier hostname verifier
*/
public EwsSSLProtocolSocketFactory(
SSLContext context,String[] supportedProtocols, String[] supportedCipherSuites,
HostnameVerifier hostnameVerifier
) {
super(context,supportedProtocols,supportedCipherSuites, hostnameVerifier);
this.sslcontext = context;
}


/**
* Create and configure SSL protocol socket factory using default hostname verifier.
Expand All @@ -129,7 +146,22 @@ public static EwsSSLProtocolSocketFactory build(
TrustManager trustManager, HostnameVerifier hostnameVerifier
) throws GeneralSecurityException {
SSLContext sslContext = createSslContext(trustManager);
return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier);

//read system properties
String[] keepAliveStrategyCopy;
keepAliveStrategyCopy = split(System.getProperty("https.protocols"));
String[] targetAuthStrategyCopy;
targetAuthStrategyCopy = split(System.getProperty("https.cipherSuites"));

if (null != keepAliveStrategyCopy || null != targetAuthStrategyCopy) {
return new EwsSSLProtocolSocketFactory(sslContext,keepAliveStrategyCopy,targetAuthStrategyCopy, hostnameVerifier);
} else {
return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier);
}
}

private static String[] split(String s) {
return TextUtils.isBlank(s)?null:s.split(" *, *");
}

/**
Expand Down

0 comments on commit de58c02

Please sign in to comment.