com.imperva.shcf4j.conn.ssl.DefaultSSLSessionStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shcf4j-api Show documentation
Show all versions of shcf4j-api Show documentation
The Simple HTTP Client Facade for Java (SHCF4J) serves as a simple facade or abstraction for various HTTP client frameworks (e.g. java.net.HttpURLConnection, Apache HttpClient, etc.) allowing the end user to plug in the desired HTTP client framework at deployment time.
The newest version!
package com.imperva.shcf4j.conn.ssl;
import com.imperva.shcf4j.helpers.Util;
import lombok.Builder;
import lombok.Getter;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import java.security.NoSuchAlgorithmException;
/**
* SimpleSSLSessionStrategy
*
*
* A Simple implementation for {@link SSLSessionStrategy}
*
*
*/
@Builder
@Getter
public class DefaultSSLSessionStrategy implements SSLSessionStrategy {
@Builder.Default
private final String[] supportedProtocols = {"TLSv1.1"};
@Builder.Default
private final String[] supportedCipherSuites = loadDefaultSupportedCipherSuites();
private final HostnameVerifier hostnameVerifier;
private final TrustManagerFactory trustManagerFactory;
private final KeyManagerFactory keyManagerFactory;
private static String[] loadDefaultSupportedCipherSuites(){
try{
return SSLContext.getDefault().getSupportedSSLParameters().getCipherSuites();
} catch (NoSuchAlgorithmException noSuchAlgorithmException){
Util.report("Failed to load default SSL protocols & cipher suites", noSuchAlgorithmException);
}
return null;
}
}