Package org.xipki.util.http
Class SslContextBuilder
- java.lang.Object
-
- org.xipki.util.http.SslContextBuilder
-
public class SslContextBuilder extends java.lang.ObjectBuilder forSSLContextinstances.Please note: the default Oracle JSSE implementation of
SSLContext.init(KeyManager[], TrustManager[], SecureRandom)accepts multiple key and trust managers, however only first matching type is ever used. See for example: SSLContext.html#init- Since:
- 4.4
-
-
Constructor Summary
Constructors Constructor Description SslContextBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.net.ssl.SSLContextbuild()static SslContextBuildercreate()protected voidinitSSLContext(javax.net.ssl.SSLContext sslContext, java.util.Collection<javax.net.ssl.KeyManager> keyManagers, java.util.Collection<javax.net.ssl.TrustManager> trustManagers, java.security.SecureRandom secureRandom)SslContextBuilderloadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword)SslContextBuilderloadKeyMaterial(java.io.InputStream instream, char[] storePassword, char[] keyPassword)SslContextBuilderloadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword)SslContextBuilderloadTrustMaterial()SslContextBuilderloadTrustMaterial(java.io.File file, char[] storePassword)SslContextBuilderloadTrustMaterial(java.io.InputStream instream, char[] storePassword)Load trust material from keystore in input stream.SslContextBuilderloadTrustMaterial(java.security.KeyStore truststore)SslContextBuildersetKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)Sets the key manager factory algorithm name.SslContextBuildersetKeyStoreType(java.lang.String keyStoreType)Sets the key store type.SslContextBuildersetProtocol(java.lang.String protocol)Sets the SSLContext protocol algorithm name.SslContextBuildersetProvider(java.lang.String name)SslContextBuildersetProvider(java.security.Provider provider)SslContextBuildersetSecureRandom(java.security.SecureRandom secureRandom)SslContextBuildersetTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)Sets the trust manager factory algorithm name.java.lang.StringtoString()
-
-
-
Method Detail
-
create
public static SslContextBuilder create()
-
setProtocol
public SslContextBuilder setProtocol(java.lang.String protocol)
Sets the SSLContext protocol algorithm name.- Parameters:
protocol- the SSLContext protocol algorithm name of the requested protocol. See the SSLContext section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setSecureRandom
public SslContextBuilder setSecureRandom(java.security.SecureRandom secureRandom)
-
setProvider
public SslContextBuilder setProvider(java.security.Provider provider)
-
setProvider
public SslContextBuilder setProvider(java.lang.String name)
-
setKeyStoreType
public SslContextBuilder setKeyStoreType(java.lang.String keyStoreType)
Sets the key store type.- Parameters:
keyStoreType- the SSLkey store type. See the KeyStore section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setKeyManagerFactoryAlgorithm
public SslContextBuilder setKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm name.- Parameters:
keyManagerFactoryAlgorithm- the key manager factory algorithm name of the requested protocol. See the KeyManagerFactory section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setTrustManagerFactoryAlgorithm
public SslContextBuilder setTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm name.- Parameters:
trustManagerFactoryAlgorithm- the trust manager algorithm name of the requested protocol. See the TrustManagerFactory section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
loadTrustMaterial
public SslContextBuilder loadTrustMaterial(java.security.KeyStore truststore) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreException
-
loadTrustMaterial
public SslContextBuilder loadTrustMaterial() throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreException
-
loadTrustMaterial
public SslContextBuilder loadTrustMaterial(java.io.File file, char[] storePassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.cert.CertificateExceptionjava.io.IOException
-
loadTrustMaterial
public SslContextBuilder loadTrustMaterial(java.io.InputStream instream, char[] storePassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
Load trust material from keystore in input stream. The specified stream remains open after this method returns.- Parameters:
instream- input stream that contains the keystore.storePassword- Keystore password.- Returns:
- an SslContextbuilder which trusts the certificates in the keystore.
- Throws:
java.security.NoSuchAlgorithmException- If th keystore type or other algorithms is not supported.java.security.KeyStoreException- if error occurs when parsing the keystore.java.security.cert.CertificateException- if error occurs when parsing the certificates.java.io.IOException- if error occurs when reading keystore from the input stream.
-
loadKeyMaterial
public SslContextBuilder loadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyException
-
loadKeyMaterial
public SslContextBuilder loadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyExceptionjava.security.cert.CertificateExceptionjava.io.IOException
-
loadKeyMaterial
public SslContextBuilder loadKeyMaterial(java.io.InputStream instream, char[] storePassword, char[] keyPassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyExceptionjava.security.cert.CertificateExceptionjava.io.IOException
-
initSSLContext
protected void initSSLContext(javax.net.ssl.SSLContext sslContext, java.util.Collection<javax.net.ssl.KeyManager> keyManagers, java.util.Collection<javax.net.ssl.TrustManager> trustManagers, java.security.SecureRandom secureRandom) throws java.security.KeyManagementException- Throws:
java.security.KeyManagementException
-
build
public javax.net.ssl.SSLContext build() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyManagementException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-