java.lang.Object
org.seppiko.commons.utils.http.TLSUtil
HTTP TLS (SSLContext) util
- Author:
- Leonard Woo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TrustManager[]Default Trust Managers, with trust all certificates.static final SSLContextDisableSSLContext -
Method Summary
Modifier and TypeMethodDescriptionstatic SSLContextgetSSLContext(File certFile, String certPass) HTTP TLS Factory with TLS v1.2 and PKCS 12static SSLContextgetSSLContext(TLSProtocol protocol, KeyManager[] kms, TrustManager[] tms) HTTP TLS Factorystatic SSLContextgetSSLContext(TLSProtocol protocol, KeyManager[] kms, TrustManager[] tms, SecureRandom secRand) HTTP TLS Factorystatic SSLContextgetSSLContext(TLSProtocol protocol, KeyStoreAlgorithms storeAlgorithms, InputStream certIs, String password, TrustManager[] tms) HTTP TLS Factorystatic KeyManagerFactorykeyManagerFactory(String algorithm, Provider provider) Returns aKeyManagerFactoryobject that acts as a factory for key managers.static KeyManagerFactorykeyManagerFactory(Provider provider) Returns aKeyManagerFactoryobject that acts as a factory for key managers.static KeyManager[]keyManagers(KeyStore store, char[] password) KeyManager array util
-
Field Details
-
DEFAULT_TRUST_MANAGERS
Default Trust Managers, with trust all certificates.- See Also:
-
NULL_SSL_CONTEXT
DisableSSLContext
-
-
Method Details
-
keyManagerFactory
public static KeyManagerFactory keyManagerFactory(Provider provider) throws NoSuchAlgorithmException Returns aKeyManagerFactoryobject that acts as a factory for key managers. And use standard name.- Parameters:
provider- an instance of the provider.- Returns:
- KeyManagerFactory instance.
- Throws:
NoSuchAlgorithmException- if noProvidersupports aKeyManagerFactorySpiimplementation for the specified algorithm.- See Also:
-
keyManagerFactory
public static KeyManagerFactory keyManagerFactory(String algorithm, Provider provider) throws NoSuchAlgorithmException Returns aKeyManagerFactoryobject that acts as a factory for key managers. If algorithm is empty or null, use the default KeyManagerFactory algorithm name.- Parameters:
algorithm- the standard name of the requested algorithm.provider- an instance of the provider.- Returns:
- KeyManagerFactory instance.
- Throws:
NoSuchAlgorithmException- if noProvidersupports aKeyManagerFactorySpiimplementation for the specified algorithm.- See Also:
-
keyManagers
public static KeyManager[] keyManagers(KeyStore store, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException KeyManager array util- Parameters:
store- KeyStore instance.password- the password for recovering keys in the KeyStore.- Returns:
- KeyManager array
- Throws:
NoSuchAlgorithmException- if noProvidersupports aKeyManagerFactorySpiimplementation for the specified algorithm. Or the specified algorithm is not available from the specified provider.UnrecoverableKeyException- if the key cannot be recovered (e.g. the given password is wrong).KeyStoreException- if this operation fails.- See Also:
-
getSSLContext
HTTP TLS Factory with TLS v1.2 and PKCS 12- Parameters:
certFile- Certificate file.certPass- Certificate password.- Returns:
- SSLContext instance. if file is null or exception return null.
-
getSSLContext
public static SSLContext getSSLContext(TLSProtocol protocol, KeyStoreAlgorithms storeAlgorithms, InputStream certIs, String password, TrustManager[] tms) throws HttpTLSException, NullPointerException HTTP TLS Factory- Parameters:
protocol- TLS protocol.storeAlgorithms- KeyStore algorithm.certIs- Certificate InputStream.password- Certificate password.tms- the sources of peer authentication trust decisions or null.- Returns:
- SSLContext instance.
- Throws:
HttpTLSException- TLS key, provider, I/O or operation is fails.NullPointerException- some parameter is null.
-
getSSLContext
public static SSLContext getSSLContext(TLSProtocol protocol, KeyManager[] kms, TrustManager[] tms) throws NoSuchAlgorithmException, KeyManagementException HTTP TLS Factory- Parameters:
protocol- TLS protocol.kms- the sources of authentication key or null.tms- the sources of peer authentication trust decisions or null.- Returns:
- SSLContext instance.
- Throws:
NoSuchAlgorithmException- if this operation fails.KeyManagementException- if noProvidersupports aSSLContextSpiimplementation for the specified protocol.
-
getSSLContext
public static SSLContext getSSLContext(TLSProtocol protocol, KeyManager[] kms, TrustManager[] tms, SecureRandom secRand) throws KeyManagementException, NoSuchAlgorithmException HTTP TLS Factory- Parameters:
protocol- TLS protocol.kms- the sources of authentication key or null.tms- the sources of peer authentication trust decisions or null.secRand- the source of randomness for this generator or null.- Returns:
- SSLContext instance.
- Throws:
KeyManagementException- if this operation fails.NoSuchAlgorithmException- if noProvidersupports aSSLContextSpiimplementation for the specified protocol.
-