public class SSLContextFactory
extends java.lang.Object
Title: Framework Support Library
Description: SSLContextFactory to manage key/trust store.
SSLContextFactory allows create SSLContext based on provided certificates and key/trust stores.
Use JDK keytool utility to manage cretificates, key/trust stores.
keytool -genkeypair -alias servercertificatekey -keyalg RSA -keystore serverkeystore.jks
keytool -list -v -keystore serverkeystore.jks
keytool -export -alias servercertificatekey -keystore serverkeystore.jks -rfc -file servercertificate.cer
keytool -import -alias servercertificatekey -file servercertificate.cer -keystore servertruststore.jks
Copyright: Copyright (c) 2012
Company: StreamScape Technologies
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CERTIFICATE_FACTORY_DEFAULT |
static java.lang.String |
KEYMANAGER_ALGORITHM_DEFAULT |
static java.lang.String |
KEYSTORE_TYPE_DEFAULT |
static java.lang.String |
TRUSTMANAGER_ALGORITHM_DEFAULT |
Constructor and Description |
---|
SSLContextFactory() |
Modifier and Type | Method and Description |
---|---|
void |
addDefaultTrustStore()
Adds java default trust store.
|
void |
addTrustCertificate(java.lang.String alias,
java.lang.String certificateFile)
Adds trusted certificate.
|
void |
addTrustManagers(javax.net.ssl.TrustManager[] trustmanagers)
Adds trust managers.
|
void |
addTrustStore(byte[] trustStoreFileData,
java.lang.String password)
Adds truststore file data to be used.
|
void |
addTrustStore(java.io.RandomAccessFile trustStoreFile,
java.lang.String password)
Adds truststore file to be used.
|
void |
addTrustStore(java.lang.String trustStoreFile,
java.lang.String password)
Adds truststore file to be used.
|
javax.net.ssl.SSLContext |
createSSLContext()
Creates SSL context and initialize it with configured key/trust managers.
|
void |
setKeyStore(byte[] keyStoreFileData,
java.lang.String password)
Sets keystore file data to be used.
|
void |
setKeyStore(java.io.RandomAccessFile keyStoreFile,
java.lang.String password)
Sets keystore file to be used.
|
void |
setKeyStore(java.lang.String keyStoreFile,
java.lang.String password)
Sets keystore file to be used.
|
void |
setProtocol(java.lang.String protocol)
Sets protocol to be used, TLS by default.
|
void |
setRandom(java.security.SecureRandom random) |
void |
trustAllCertificates()
Sets option - trust to all certificates.
|
public static final java.lang.String CERTIFICATE_FACTORY_DEFAULT
public static final java.lang.String KEYSTORE_TYPE_DEFAULT
public static final java.lang.String KEYMANAGER_ALGORITHM_DEFAULT
public static final java.lang.String TRUSTMANAGER_ALGORITHM_DEFAULT
public javax.net.ssl.SSLContext createSSLContext() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
public void setProtocol(java.lang.String protocol)
protocol
- public void setRandom(java.security.SecureRandom random)
public void setKeyStore(java.lang.String keyStoreFile, java.lang.String password) throws java.lang.Exception
keyStoreFile
- the key store file.password
- the key store password.java.lang.Exception
- if some error occurs during this operation execution.public void setKeyStore(java.io.RandomAccessFile keyStoreFile, java.lang.String password) throws java.lang.Exception
keyStoreFile
- the key store file.password
- the key store password.java.lang.Exception
- if some error occurs during this operation execution.public void setKeyStore(byte[] keyStoreFileData, java.lang.String password) throws java.lang.Exception
keyStoreFileData
- the key store file data.password
- the key store password.java.lang.Exception
- if some error occurs during this operation execution.public void addTrustStore(java.lang.String trustStoreFile, java.lang.String password) throws java.lang.Exception
trustStoreFile
- the trust store file.password
- the trust store password.java.lang.Exception
- if some error occurs during this operation execution.public void addTrustStore(java.io.RandomAccessFile trustStoreFile, java.lang.String password) throws java.lang.Exception
trustStoreFile
- the trust store file.password
- the trust store password.java.lang.Exception
- if some error occurs during this operation execution.public void addTrustStore(byte[] trustStoreFileData, java.lang.String password) throws java.lang.Exception
trustStoreFileData
- the trust store filed data.password
- the trust store password.java.lang.Exception
- if some error occurs during this operation execution.public void addDefaultTrustStore() throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
public void addTrustCertificate(java.lang.String alias, java.lang.String certificateFile) throws java.security.KeyStoreException, java.security.cert.CertificateException, java.security.NoSuchAlgorithmException, java.io.IOException
alias
- - certificate aliascertificateFile
- - file with certificatejava.security.KeyStoreException
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
java.io.IOException
public void trustAllCertificates() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
public void addTrustManagers(javax.net.ssl.TrustManager[] trustmanagers)
trustmanagers
- Copyright © 2015-2024 StreamScape Technologies. All rights reserved.