public class SslContextBuilder
extends java.lang.Object
| Constructor and Description |
|---|
SslContextBuilder()
Creates an SSL context builder.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClientKey(byte[] privateKey,
java.io.InputStream certificate)
Adds the given client key and the associated self-signed certificate.
|
void |
addClientKey(byte[] privateKey,
java.io.InputStream certificate,
java.io.InputStream... certificationChain)
Adds the given client key and the associated certificate and certification
chain to the key store.
|
void |
addClientKey(java.io.InputStream privateKey,
java.io.InputStream certificate)
Adds the given client key and the associated self-signed certificate.
|
void |
addClientKey(java.io.InputStream privateKey,
java.io.InputStream certificate,
java.io.InputStream... certificationChain)
Adds the given client key and the associated certificate and certification
chain to the key store.
|
void |
addClientKey(java.lang.String privateKeyPath,
java.lang.String certificatePath,
java.lang.String... certificationChainPaths)
Adds the given client key and the associated certificate and certification
chain to the key store.
|
void |
addServerCertificate(java.io.InputStream certificate)
Adds the given server certificate to the trust store.
|
void |
addServerCertificate(java.lang.String certificatePath)
Adds the given server certificate to the trust store.
|
javax.net.ssl.SSLContext |
build()
Creates an SSL context using the populated trust store and an empty key store.
|
javax.net.ssl.SSLContext |
build(java.lang.String keyStorePassword)
Creates an SSL context using the populated trust store and an the populated key store, using the given key store
password.
|
public SslContextBuilder()
throws java.security.GeneralSecurityException
java.security.GeneralSecurityException - if an exception occurs while initializing the trust store or the key store.public void addServerCertificate(java.io.InputStream certificate)
throws java.security.GeneralSecurityException
certificate - the certificate to add.java.security.GeneralSecurityException - if the certificate could not be loaded or added.public void addServerCertificate(java.lang.String certificatePath)
throws java.security.GeneralSecurityException,
java.io.IOException
Class.getResourceAsStream(String)).certificatePath - the path to the certificate to add.java.security.GeneralSecurityException - if the certificate could not be loaded or added.java.io.IOExceptionpublic void addClientKey(byte[] privateKey,
java.io.InputStream certificate,
java.io.InputStream... certificationChain)
throws java.security.GeneralSecurityException
privateKey - the private key to add.certificate - the associated certificate.certificationChain - the certification chain, ordered, the root certificate at the end.java.security.GeneralSecurityException - if the certificates could not be loaded or the private key could
not be added.public void addClientKey(byte[] privateKey,
java.io.InputStream certificate)
throws java.security.GeneralSecurityException
privateKey - the private key to add.certificate - the associated certificate.java.security.GeneralSecurityException - if the certificates could not be loaded or the private key could
not be added.public void addClientKey(java.io.InputStream privateKey,
java.io.InputStream certificate,
java.io.InputStream... certificationChain)
throws java.io.IOException,
java.security.GeneralSecurityException
privateKey - the private key to add.certificate - the associated certificate.certificationChain - the certification chain, ordered, the root certificate at the end.java.security.GeneralSecurityException - if the certificate could not be loaded or the private key could
not be added.java.io.IOException - if the given privateKey could not be read.public void addClientKey(java.io.InputStream privateKey,
java.io.InputStream certificate)
throws java.io.IOException,
java.security.GeneralSecurityException
privateKey - the private key to add.certificate - the associated certificate.java.security.GeneralSecurityException - if the certificate could not be loaded or the private key could
not be added.java.io.IOException - if the given privateKey could not be read.public void addClientKey(java.lang.String privateKeyPath,
java.lang.String certificatePath,
java.lang.String... certificationChainPaths)
throws java.io.IOException,
java.security.GeneralSecurityException
Class.getResourceAsStream(String)).privateKeyPath - the path to the private key to add.certificatePath - the path to the associated certificate.certificationChainPaths - the paths to the certification chain, ordered, the root
certificate at the end.java.security.GeneralSecurityException - if the certificate could not be loaded or the private key could
not be added.java.io.IOException - if the given privateKey could not be read.public javax.net.ssl.SSLContext build()
throws java.security.GeneralSecurityException
java.security.GeneralSecurityException - if an exception occurred while creating the SSL context.public javax.net.ssl.SSLContext build(java.lang.String keyStorePassword)
throws java.security.GeneralSecurityException
keyStorePassword - the password of the key store.java.security.GeneralSecurityException - if an exception occurred while creating the SSL context.