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