Class SslConfigurator
SSLContext
instances.
For example:
SslConfigurator sslConfig = SslConfigurator.newInstance() .trustStoreFile("truststore.jks") .trustStorePassword("asdfgh") .trustStoreType("JKS") .trustManagerFactoryAlgorithm("PKIX") .keyStoreFile("keystore.jks") .keyPassword("asdfgh") .keyStoreType("JKS") .keyManagerFactoryAlgorithm("SunX509") .keyStoreProvider("SunJSSE") .securityProtocol("SSL"); SSLContext sslContext = sslConfig.createSSLContext();
- Author:
- Alexey Stashok, Hubert Iwaniuk, Bruno Harbulot, Marek Potociar
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Key manager factory algorithm name.static final String
Key manager factory provider name.static final String
Key store file name.static final String
Key store file password - the password used to unlock the trust store file.static final String
Key store provider name.static final String
Key store type (seeKeyStore.getType()
for more info).static final String
Trust manager factory algorithm name.static final String
Trust manager factory provider name.static final String
Trust store file name.static final String
Trust store file password - the password used to unlock the trust store file.static final String
Trust store provider name.static final String
Trust store type (seeKeyStore.getType()
for more info). -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Create a copy of the current SSL configurator instance.Create new SSL context instance using the current SSL context configuration.boolean
static SSLContext
Get a new instance of aSSLContext
configured using default configuration settings.static SSLContext
getDefaultContext
(boolean readSystemProperties) Get a new instance of aSSLContext
configured using default configuration settings.int
hashCode()
keyManagerFactoryAlgorithm
(String algorithm) Set the key manager factory algorithm.keyManagerFactoryProvider
(String provider) Set the key manager factory provider.keyPassword
(char[] password) Set the password of the key in the key store.keyPassword
(String password) Set the password of the key in the key store.Set the key store instance.keyStoreBytes
(byte[] payload) Set the key store payload as byte array.keyStoreFile
(String fileName) Set the key store file name.keyStorePassword
(char[] password) Set the password of key store.keyStorePassword
(String password) Set the password of key store.keyStoreProvider
(String keyStoreProvider) Set the key store provider name.keyStoreType
(String keyStoreType) Set the type of key store.keyStoreUrl
(URL url) Set the key store url.static SslConfigurator
Get a new & initialized SSL configurator instance.static SslConfigurator
newInstance
(boolean readSystemProperties) Get a new SSL configurator instance.retrieve()
Retrieve the SSL context configuration from the system properties.retrieve
(Properties props) Retrieve the SSL context configuration from the supplied properties.securityProtocol
(String protocol) Set the SSLContext protocol.trustManagerFactoryAlgorithm
(String algorithm) Set the trust manager factory algorithm.trustManagerFactoryProvider
(String provider) Set the trust manager factory provider.trustStore
(KeyStore trustStore) Set the trust store instance.trustStoreBytes
(byte[] payload) Set the trust store payload as byte array.trustStoreFile
(String fileName) Set the trust store file name.trustStorePassword
(String password) Set the password of trust store.trustStoreProvider
(String trustStoreProvider) Set the trust store provider name.trustStoreType
(String trustStoreType) Set the type of trust store.trustStoreUrl
(URL url) Set the trust store file url.
-
Field Details
-
TRUST_STORE_PROVIDER
Trust store provider name. The value MUST be aString
representing the name of a trust store provider.No default value is set.
The name of the configuration property is "javax.net.ssl.trustStoreProvider".
- See Also:
-
KEY_STORE_PROVIDER
Key store provider name. The value MUST be aString
representing the name of a trust store provider.No default value is set.
The name of the configuration property is "javax.net.ssl.keyStoreProvider".
- See Also:
-
TRUST_STORE_FILE
Trust store file name. The value MUST be aString
representing the name of a trust store file.No default value is set.
The name of the configuration property is "javax.net.ssl.trustStore".
- See Also:
-
KEY_STORE_FILE
Key store file name. The value MUST be aString
representing the name of a key store file.No default value is set.
The name of the configuration property is "javax.net.ssl.keyStore".
- See Also:
-
TRUST_STORE_PASSWORD
Trust store file password - the password used to unlock the trust store file. The value MUST be aString
representing the trust store file password.No default value is set.
The name of the configuration property is "javax.net.ssl.trustStorePassword".
- See Also:
-
KEY_STORE_PASSWORD
Key store file password - the password used to unlock the trust store file. The value MUST be aString
representing the key store file password.No default value is set.
The name of the configuration property is "javax.net.ssl.keyStorePassword".
- See Also:
-
TRUST_STORE_TYPE
Trust store type (seeKeyStore.getType()
for more info). The value MUST be aString
representing the trust store type name.No default value is set.
The name of the configuration property is "javax.net.ssl.trustStoreType".
- See Also:
-
KEY_STORE_TYPE
Key store type (seeKeyStore.getType()
for more info). The value MUST be aString
representing the key store type name.No default value is set.
The name of the configuration property is "javax.net.ssl.keyStoreType".
- See Also:
-
KEY_MANAGER_FACTORY_ALGORITHM
Key manager factory algorithm name. The value MUST be aString
representing the key manager factory algorithm name.No default value is set.
The name of the configuration property is "ssl.keyManagerFactory.algorithm".
- See Also:
-
KEY_MANAGER_FACTORY_PROVIDER
Key manager factory provider name. The value MUST be aString
representing the key manager factory provider name.No default value is set.
The name of the configuration property is "ssl.keyManagerFactory.provider".
- See Also:
-
TRUST_MANAGER_FACTORY_ALGORITHM
Trust manager factory algorithm name. The value MUST be aString
representing the trust manager factory algorithm name.No default value is set.
The name of the configuration property is "ssl.trustManagerFactory.algorithm".
- See Also:
-
TRUST_MANAGER_FACTORY_PROVIDER
Trust manager factory provider name. The value MUST be aString
representing the trust manager factory provider name.No default value is set.
The name of the configuration property is "ssl.trustManagerFactory.provider".
- See Also:
-
-
Method Details
-
getDefaultContext
Get a new instance of aSSLContext
configured using default configuration settings. The default SSL configuration is initialized from system properties. This method is a shortcut forgetDefaultContext(true)
.- Returns:
- new instance of a default SSL context initialized from system properties.
-
getDefaultContext
Get a new instance of aSSLContext
configured using default configuration settings. IfreadSystemProperties
parameter is set totrue
, the default SSL configuration is initialized from system properties.- Parameters:
readSystemProperties
- iftrue
, the default SSL context will be initialized using system properties.- Returns:
- new instance of a default SSL context initialized from system properties.
-
newInstance
Get a new & initialized SSL configurator instance. The the instantiated configurator will be empty.- Returns:
- new & initialized SSL configurator instance.
-
newInstance
Get a new SSL configurator instance.- Parameters:
readSystemProperties
- iftrue
,Retrieves
the initial configuration fromSystem.getProperty(String)
}, otherwise the instantiated configurator will be empty.- Returns:
- new SSL configurator instance.
-
copy
Create a copy of the current SSL configurator instance.- Returns:
- copy of the current SSL configurator instance
-
trustStoreProvider
Set the trust store provider name.- Parameters:
trustStoreProvider
- trust store provider to set.- Returns:
- updated SSL configurator instance.
-
keyStoreProvider
Set the key store provider name.- Parameters:
keyStoreProvider
- key store provider to set.- Returns:
- updated SSL configurator instance.
-
trustStoreType
Set the type of trust store.- Parameters:
trustStoreType
- type of trust store to set.- Returns:
- updated SSL configurator instance.
-
keyStoreType
Set the type of key store.- Parameters:
keyStoreType
- type of key store to set.- Returns:
- updated SSL configurator instance.
-
trustStorePassword
Set the password of trust store.- Parameters:
password
- password of trust store to set.- Returns:
- updated SSL configurator instance.
-
keyStorePassword
Set the password of key store.- Parameters:
password
- password of key store to set.- Returns:
- updated SSL configurator instance.
-
keyStorePassword
Set the password of key store.- Parameters:
password
- password of key store to set.- Returns:
- updated SSL configurator instance.
-
keyPassword
Set the password of the key in the key store.- Parameters:
password
- password of key to set.- Returns:
- updated SSL configurator instance.
-
keyPassword
Set the password of the key in the key store.- Parameters:
password
- password of key to set.- Returns:
- updated SSL configurator instance.
-
trustStoreFile
Set the trust store file name.Setting a trust store instance resets any
trust store instance
,trust store payload
ortrust store url
value previously set.- Parameters:
fileName
-file
name of the trust store.- Returns:
- updated SSL configurator instance.
-
trustStoreUrl
Set the trust store file url.Setting a trust store instance resets any
trust store instance
,trust store payload
ortrust store url
value previously set.- Parameters:
url
-url
link of the trust store.- Returns:
- updated SSL configurator instance.
-
trustStoreBytes
Set the trust store payload as byte array.Setting a trust store instance resets any
trust store file
,trust store instance
ortrust store url
value previously set.- Parameters:
payload
- trust store payload.- Returns:
- updated SSL configurator instance.
-
keyStoreFile
Set the key store file name.Setting a key store instance resets any
key store instance
,key store payload
orkey store url
value previously set.- Parameters:
fileName
-file
name of the key store.- Returns:
- updated SSL configurator instance.
-
keyStoreUrl
Set the key store url.Setting a key store instance resets any
key store instance
,key store payload
orkey store file
value previously set.- Parameters:
url
-url
of the key store.- Returns:
- updated SSL configurator instance.
-
keyStoreBytes
Set the key store payload as byte array.Setting a key store instance resets any
key store file
,key store instance
orkey store url
value previously set.- Parameters:
payload
- key store payload.- Returns:
- updated SSL configurator instance.
-
trustManagerFactoryAlgorithm
Set the trust manager factory algorithm.- Parameters:
algorithm
- the trust manager factory algorithm.- Returns:
- updated SSL configurator instance.
-
keyManagerFactoryAlgorithm
Set the key manager factory algorithm.- Parameters:
algorithm
- the key manager factory algorithm.- Returns:
- updated SSL configurator instance.
-
trustManagerFactoryProvider
Set the trust manager factory provider.- Parameters:
provider
- the trust manager factory provider.- Returns:
- updated SSL configurator instance.
-
keyManagerFactoryProvider
Set the key manager factory provider.- Parameters:
provider
- the key manager factory provider.- Returns:
- updated SSL configurator instance.
-
securityProtocol
Set the SSLContext protocol. The default value isTLS
if this isnull
.- Parameters:
protocol
- protocol forSSLContext.getProtocol()
.- Returns:
- updated SSL configurator instance.
-
keyStore
Set the key store instance.Setting a key store instance resets any
key store file
,key store payload
orkey store url
value previously set.- Parameters:
keyStore
- key store instance.- Returns:
- updated SSL configurator instance.
-
trustStore
Set the trust store instance.Setting a trust store instance resets any
trust store file
,trust store payload
ortrust store url
value previously set.- Parameters:
trustStore
- trust store instance.- Returns:
- updated SSL configurator instance.
-
createSSLContext
Create new SSL context instance using the current SSL context configuration.- Returns:
- newly configured SSL context instance.
-
retrieve
Retrieve the SSL context configuration from the supplied properties.- Parameters:
props
- properties containing the SSL context configuration.- Returns:
- updated SSL configurator instance.
-
retrieve
Retrieve the SSL context configuration from the system properties.- Returns:
- updated SSL configurator instance.
-
equals
-
hashCode
public int hashCode()
-