String provider = tlsClientParameters.getJsseProvider();
String protocol = tlsClientParameters.getSecureSocketProtocol() != null ? tlsClientParameters
.getSecureSocketProtocol() : "TLS";
SSLContext ctx = provider == null ? SSLContext.getInstance(protocol) : SSLContext
.getInstance(protocol, provider);
ctx.getClientSessionContext().setSessionTimeout(tlsClientParameters.getSslCacheTimeout());
KeyManager[] keyManagers = tlsClientParameters.getKeyManagers();
if (tlsClientParameters.getCertAlias() != null) {
getKeyManagersWithCertAlias(tlsClientParameters, keyManagers);
}
ctx.init(keyManagers, tlsClientParameters.getTrustManagers(),
tlsClientParameters.getSecureRandom());
// The "false" argument means opposite of exclude.
String[] cipherSuites = SSLUtils.getCiphersuites(tlsClientParameters.getCipherSuites(), SSLUtils
.getSupportedCipherSuites(ctx), tlsClientParameters.getCipherSuitesFilter(), LOG, false);
// The SSLSocketFactoryWrapper enables certain cipher suites
// from the policy.
socketFactory = new SSLSocketFactoryWrapper(ctx.getSocketFactory(), cipherSuites,
tlsClientParameters.getSecureSocketProtocol());
} else {
// ssl socket factory already initialized, reuse it to benefit of keep alive
}