public final class SslConfigurator
extends java.lang.Object
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();
Modifier and Type | Field and Description |
---|---|
private static SslConfigurator |
DEFAULT_CONFIG_NO_PROPS
Default SSL configuration that is used to create default SSL context instances that do not take into
account system properties.
|
static java.lang.String |
KEY_MANAGER_FACTORY_ALGORITHM
Key manager factory algorithm name.
|
static java.lang.String |
KEY_MANAGER_FACTORY_PROVIDER
Key manager factory provider name.
|
static java.lang.String |
KEY_STORE_FILE
Key store file name.
|
static java.lang.String |
KEY_STORE_PASSWORD
Key store file password - the password used to unlock the trust store file.
|
static java.lang.String |
KEY_STORE_PROVIDER
Key store provider name.
|
static java.lang.String |
KEY_STORE_TYPE
Key store type (see
KeyStore.getType() for more info). |
private java.lang.String |
keyManagerFactoryAlgorithm |
private java.lang.String |
keyManagerFactoryProvider |
private char[] |
keyPass |
private java.security.KeyStore |
keyStore |
private byte[] |
keyStoreBytes |
private java.lang.String |
keyStoreFile |
private char[] |
keyStorePass |
private java.lang.String |
keyStoreProvider |
private java.lang.String |
keyStoreType |
private static java.util.logging.Logger |
LOGGER
Logger.
|
private java.lang.String |
securityProtocol |
static java.lang.String |
TRUST_MANAGER_FACTORY_ALGORITHM
Trust manager factory algorithm name.
|
static java.lang.String |
TRUST_MANAGER_FACTORY_PROVIDER
Trust manager factory provider name.
|
static java.lang.String |
TRUST_STORE_FILE
Trust store file name.
|
static java.lang.String |
TRUST_STORE_PASSWORD
Trust store file password - the password used to unlock the trust store file.
|
static java.lang.String |
TRUST_STORE_PROVIDER
Trust store provider name.
|
static java.lang.String |
TRUST_STORE_TYPE
Trust store type (see
KeyStore.getType() for more info). |
private java.lang.String |
trustManagerFactoryAlgorithm |
private java.lang.String |
trustManagerFactoryProvider |
private java.security.KeyStore |
trustStore |
private byte[] |
trustStoreBytes |
private java.lang.String |
trustStoreFile |
private char[] |
trustStorePass |
private java.lang.String |
trustStoreProvider |
private java.lang.String |
trustStoreType |
Modifier | Constructor and Description |
---|---|
private |
SslConfigurator(boolean readSystemProperties) |
private |
SslConfigurator(SslConfigurator that) |
Modifier and Type | Method and Description |
---|---|
SslConfigurator |
copy()
Create a copy of the current SSL configurator instance.
|
javax.net.ssl.SSLContext |
createSSLContext()
Create new SSL context instance using the current SSL context configuration.
|
boolean |
equals(java.lang.Object o) |
static javax.net.ssl.SSLContext |
getDefaultContext()
Get a new instance of a
SSLContext configured using default configuration settings. |
static javax.net.ssl.SSLContext |
getDefaultContext(boolean readSystemProperties)
Get a new instance of a
SSLContext configured using default configuration settings. |
(package private) java.security.KeyStore |
getKeyStore()
Get the key store instance.
|
(package private) java.security.KeyStore |
getTrustStore()
Get the trust store instance.
|
int |
hashCode() |
SslConfigurator |
keyManagerFactoryAlgorithm(java.lang.String algorithm)
Set the key manager factory algorithm.
|
SslConfigurator |
keyManagerFactoryProvider(java.lang.String provider)
Set the key manager factory provider.
|
SslConfigurator |
keyPassword(char[] password)
Set the password of the key in the key store.
|
SslConfigurator |
keyPassword(java.lang.String password)
Set the password of the key in the key store.
|
SslConfigurator |
keyStore(java.security.KeyStore keyStore)
Set the key store instance.
|
SslConfigurator |
keyStoreBytes(byte[] payload)
Set the key store payload as byte array.
|
SslConfigurator |
keyStoreFile(java.lang.String fileName)
Set the key store file name.
|
SslConfigurator |
keyStorePassword(char[] password)
Set the password of key store.
|
SslConfigurator |
keyStorePassword(java.lang.String password)
Set the password of key store.
|
SslConfigurator |
keyStoreProvider(java.lang.String keyStoreProvider)
Set the key store provider name.
|
SslConfigurator |
keyStoreType(java.lang.String keyStoreType)
Set the type of key store.
|
static SslConfigurator |
newInstance()
Get a new & initialized SSL configurator instance.
|
static SslConfigurator |
newInstance(boolean readSystemProperties)
Get a new SSL configurator instance.
|
SslConfigurator |
retrieve(java.util.Properties props)
Retrieve the SSL context configuration from the supplied properties.
|
SslConfigurator |
securityProtocol(java.lang.String protocol)
Set the SSLContext protocol.
|
SslConfigurator |
trustManagerFactoryAlgorithm(java.lang.String algorithm)
Set the trust manager factory algorithm.
|
SslConfigurator |
trustManagerFactoryProvider(java.lang.String provider)
Set the trust manager factory provider.
|
SslConfigurator |
trustStore(java.security.KeyStore trustStore)
Set the trust store instance.
|
SslConfigurator |
trustStoreBytes(byte[] payload)
Set the trust store payload as byte array.
|
SslConfigurator |
trustStoreFile(java.lang.String fileName)
Set the trust store file name.
|
SslConfigurator |
trustStorePassword(java.lang.String password)
Set the password of trust store.
|
SslConfigurator |
trustStoreProvider(java.lang.String trustStoreProvider)
Set the trust store provider name.
|
SslConfigurator |
trustStoreType(java.lang.String trustStoreType)
Set the type of trust store.
|
public static final java.lang.String TRUST_STORE_PROVIDER
String
representing the name of a trust store provider.
No default value is set.
The name of the configuration property is "javax.net.ssl.trustStoreProvider".
public static final java.lang.String KEY_STORE_PROVIDER
String
representing the name of a trust store provider.
No default value is set.
The name of the configuration property is "javax.net.ssl.keyStoreProvider".
public static final java.lang.String TRUST_STORE_FILE
String
representing the name of a trust store file.
No default value is set.
The name of the configuration property is "javax.net.ssl.trustStore".
public static final java.lang.String KEY_STORE_FILE
String
representing the name of a key store file.
No default value is set.
The name of the configuration property is "javax.net.ssl.keyStore".
public static final java.lang.String TRUST_STORE_PASSWORD
String
representing the trust store file password.
No default value is set.
The name of the configuration property is "javax.net.ssl.trustStorePassword".
public static final java.lang.String KEY_STORE_PASSWORD
String
representing the key store file password.
No default value is set.
The name of the configuration property is "javax.net.ssl.keyStorePassword".
public static final java.lang.String TRUST_STORE_TYPE
KeyStore.getType()
for more info).
The value MUST be a String
representing the trust store type name.
No default value is set.
The name of the configuration property is "javax.net.ssl.trustStoreType".
public static final java.lang.String KEY_STORE_TYPE
KeyStore.getType()
for more info).
The value MUST be a String
representing the key store type name.
No default value is set.
The name of the configuration property is "javax.net.ssl.keyStoreType".
public static final java.lang.String KEY_MANAGER_FACTORY_ALGORITHM
String
representing the key manager factory algorithm name.
No default value is set.
The name of the configuration property is "ssl.keyManagerFactory.algorithm".
public static final java.lang.String KEY_MANAGER_FACTORY_PROVIDER
String
representing the key manager factory provider name.
No default value is set.
The name of the configuration property is "ssl.keyManagerFactory.provider".
public static final java.lang.String TRUST_MANAGER_FACTORY_ALGORITHM
String
representing the trust manager factory algorithm name.
No default value is set.
The name of the configuration property is "ssl.trustManagerFactory.algorithm".
public static final java.lang.String TRUST_MANAGER_FACTORY_PROVIDER
String
representing the trust manager factory provider name.
No default value is set.
The name of the configuration property is "ssl.trustManagerFactory.provider".
private static final SslConfigurator DEFAULT_CONFIG_NO_PROPS
private static final java.util.logging.Logger LOGGER
private java.security.KeyStore keyStore
private java.security.KeyStore trustStore
private java.lang.String trustStoreProvider
private java.lang.String keyStoreProvider
private java.lang.String trustStoreType
private java.lang.String keyStoreType
private char[] trustStorePass
private char[] keyStorePass
private char[] keyPass
private java.lang.String trustStoreFile
private java.lang.String keyStoreFile
private byte[] trustStoreBytes
private byte[] keyStoreBytes
private java.lang.String trustManagerFactoryAlgorithm
private java.lang.String keyManagerFactoryAlgorithm
private java.lang.String trustManagerFactoryProvider
private java.lang.String keyManagerFactoryProvider
private java.lang.String securityProtocol
private SslConfigurator(boolean readSystemProperties)
private SslConfigurator(SslConfigurator that)
public static javax.net.ssl.SSLContext getDefaultContext()
SSLContext
configured using default configuration settings.
The default SSL configuration is initialized from system properties. This method is a shortcut
for getDefaultContext(true)
.public static javax.net.ssl.SSLContext getDefaultContext(boolean readSystemProperties)
SSLContext
configured using default configuration settings.
If readSystemProperties
parameter is set to true
, the default SSL configuration
is initialized from system properties.readSystemProperties
- if true
, the default SSL context will be initialized using
system properties.public static SslConfigurator newInstance()
retrieves
the initial configuration from
system properties
.public static SslConfigurator newInstance(boolean readSystemProperties)
readSystemProperties
- if true
, Retrieves
the initial configuration from System.getProperties()
,
otherwise the instantiated configurator will be empty.public SslConfigurator copy()
public SslConfigurator trustStoreProvider(java.lang.String trustStoreProvider)
trustStoreProvider
- trust store provider to set.public SslConfigurator keyStoreProvider(java.lang.String keyStoreProvider)
keyStoreProvider
- key store provider to set.public SslConfigurator trustStoreType(java.lang.String trustStoreType)
trustStoreType
- type of trust store to set.public SslConfigurator keyStoreType(java.lang.String keyStoreType)
keyStoreType
- type of key store to set.public SslConfigurator trustStorePassword(java.lang.String password)
password
- password of trust store to set.public SslConfigurator keyStorePassword(java.lang.String password)
password
- password of key store to set.public SslConfigurator keyStorePassword(char[] password)
password
- password of key store to set.public SslConfigurator keyPassword(java.lang.String password)
password
- password of key to set.public SslConfigurator keyPassword(char[] password)
password
- password of key to set.public SslConfigurator trustStoreFile(java.lang.String fileName)
Setting a trust store instance resets any trust store instance
or trust store payload
value previously set.
fileName
- file
name of the trust store.public SslConfigurator trustStoreBytes(byte[] payload)
Setting a trust store instance resets any trust store file
or trust store instance
value previously set.
payload
- trust store payload.public SslConfigurator keyStoreFile(java.lang.String fileName)
Setting a key store instance resets any key store instance
or key store payload
value previously set.
fileName
- file
name of the key store.public SslConfigurator keyStoreBytes(byte[] payload)
Setting a key store instance resets any key store file
or key store instance
value previously set.
payload
- key store payload.public SslConfigurator trustManagerFactoryAlgorithm(java.lang.String algorithm)
algorithm
- the trust manager factory algorithm.public SslConfigurator keyManagerFactoryAlgorithm(java.lang.String algorithm)
algorithm
- the key manager factory algorithm.public SslConfigurator trustManagerFactoryProvider(java.lang.String provider)
provider
- the trust manager factory provider.public SslConfigurator keyManagerFactoryProvider(java.lang.String provider)
provider
- the key manager factory provider.public SslConfigurator securityProtocol(java.lang.String protocol)
TLS
if this is null
.protocol
- protocol for SSLContext.getProtocol()
.java.security.KeyStore getKeyStore()
null
if not explicitly set.public SslConfigurator keyStore(java.security.KeyStore keyStore)
Setting a key store instance resets any key store file
or key store payload
value previously set.
keyStore
- key store instance.java.security.KeyStore getTrustStore()
Setting a trust store instance resets any trust store file
or trust store payload
value previously set.
null
if not explicitly set.public SslConfigurator trustStore(java.security.KeyStore trustStore)
trustStore
- trust store instance.public javax.net.ssl.SSLContext createSSLContext()
public SslConfigurator retrieve(java.util.Properties props)
props
- properties containing the SSL context configuration.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object