public class SslContextConfigurator
extends java.lang.Object
Used to configure SslEngineConfigurator
, which will be passed to client via configuration properties.
Example:
SslContextConfigurator sslContextConfigurator = new SslContextConfigurator(); sslContextConfigurator.setTrustStoreFile("..."); sslContextConfigurator.setTrustStorePassword("..."); sslContextConfigurator.setTrustStoreType("..."); sslContextConfigurator.setKeyStoreFile("..."); sslContextConfigurator.setKeyStorePassword("..."); sslContextConfigurator.setKeyStoreType("..."); SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(sslContextConfigurator, true, false, false); client.getProperties().put(ClientManager.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator);
Modifier and Type | Field and Description |
---|---|
static SslContextConfigurator |
DEFAULT_CONFIG
Default SSL configuration.
|
static java.lang.String |
KEY_FACTORY_MANAGER_ALGORITHM
Key manager factory algorithm 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). |
static java.lang.String |
TRUST_FACTORY_MANAGER_ALGORITHM
Trust manager factory algorithm 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). |
Constructor and Description |
---|
SslContextConfigurator()
Default constructor.
|
SslContextConfigurator(boolean readSystemProperties)
Constructor that allows you creating empty configuration.
|
Modifier and Type | Method and Description |
---|---|
javax.net.ssl.SSLContext |
createSSLContext()
Create
SSLContext from current configuration. |
SslContextConfigurator |
retrieve(java.util.Properties props)
Retrieve settings from (system) properties.
|
SslContextConfigurator |
setKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm.
|
SslContextConfigurator |
setKeyPassword(char[] keyPassword)
Password of the key in the key store.
|
SslContextConfigurator |
setKeyPassword(java.lang.String keyPassword)
Password of the key in the key store.
|
SslContextConfigurator |
setKeyStoreBytes(byte[] keyStoreBytes)
Sets key store payload as byte array.
|
SslContextConfigurator |
setKeyStoreFile(java.lang.String keyStoreFile)
Sets key store file name, also makes sure that if other key store
configuration parameters are not set to set them to default values.
|
SslContextConfigurator |
setKeyStorePassword(char[] keyStorePassword)
Password of key store.
|
SslContextConfigurator |
setKeyStorePassword(java.lang.String keyStorePassword)
Password of key store.
|
SslContextConfigurator |
setKeyStoreProvider(java.lang.String keyStoreProvider)
Sets the key store provider name.
|
SslContextConfigurator |
setKeyStoreType(java.lang.String keyStoreType)
Type of key store.
|
SslContextConfigurator |
setSecurityProtocol(java.lang.String securityProtocol)
Sets the SSLContext protocol.
|
SslContextConfigurator |
setTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm.
|
SslContextConfigurator |
setTrustStoreBytes(byte[] trustStoreBytes)
Sets trust store payload as byte array.
|
SslContextConfigurator |
setTrustStoreFile(java.lang.String trustStoreFile)
Sets trust store file name, also makes sure that if other trust store
configuration parameters are not set to set them to default values.
|
SslContextConfigurator |
setTrustStorePassword(java.lang.String trustStorePassword)
Password of trust store.
|
SslContextConfigurator |
setTrustStoreProvider(java.lang.String trustStoreProvider)
Sets the trust store provider name.
|
SslContextConfigurator |
setTrustStoreType(java.lang.String trustStoreType)
Type of trust store.
|
boolean |
validateConfiguration()
Validates
SslContextConfigurator configuration. |
boolean |
validateConfiguration(boolean needsKeyStore)
Validates
SslContextConfigurator configuration. |
public static final java.lang.String TRUST_STORE_PROVIDER
The value MUST be a 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
The value MUST be a 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
The value MUST be a 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
The value MUST be a 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
The value MUST be a 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
The value MUST be a 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_FACTORY_MANAGER_ALGORITHM
The value MUST be a 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 TRUST_FACTORY_MANAGER_ALGORITHM
The value MUST be a 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 SslContextConfigurator DEFAULT_CONFIG
System.getProperties()
of javax.net.ssl family you should refresh
this configuration by calling retrieve(java.util.Properties)
.public SslContextConfigurator()
System.getProperties()
. Calls SslContextConfigurator(boolean)
with
true
.public SslContextConfigurator(boolean readSystemProperties)
readSystemProperties
- If true
populates configuration from
System.getProperties()
, else you have empty
configuration.public SslContextConfigurator setTrustStoreProvider(java.lang.String trustStoreProvider)
trustStoreProvider
- Trust store provider to set.SslContextConfigurator
instance.public SslContextConfigurator setKeyStoreProvider(java.lang.String keyStoreProvider)
keyStoreProvider
- Key store provider to set.SslContextConfigurator
instance.public SslContextConfigurator setTrustStoreType(java.lang.String trustStoreType)
trustStoreType
- Type of trust store to set.SslContextConfigurator
instance.public SslContextConfigurator setKeyStoreType(java.lang.String keyStoreType)
keyStoreType
- Type of key store to set.SslContextConfigurator
instance.public SslContextConfigurator setTrustStorePassword(java.lang.String trustStorePassword)
trustStorePassword
- Password of trust store to set.SslContextConfigurator
instance.public SslContextConfigurator setKeyStorePassword(java.lang.String keyStorePassword)
keyStorePassword
- Password of key store to set.SslContextConfigurator
instance.public SslContextConfigurator setKeyStorePassword(char[] keyStorePassword)
keyStorePassword
- Password of key store to set.SslContextConfigurator
instance.public SslContextConfigurator setKeyPassword(java.lang.String keyPassword)
keyPassword
- Password of key to set.SslContextConfigurator
instance.public SslContextConfigurator setKeyPassword(char[] keyPassword)
keyPassword
- Password of key to set.SslContextConfigurator
instance.public SslContextConfigurator setTrustStoreFile(java.lang.String trustStoreFile)
setTrustStoreBytes(byte[])
.trustStoreFile
- File name of trust store.SslContextConfigurator
instance.public SslContextConfigurator setTrustStoreBytes(byte[] trustStoreBytes)
setTrustStoreFile(java.lang.String)
.trustStoreBytes
- trust store payload.SslContextConfigurator
instance.public SslContextConfigurator setKeyStoreFile(java.lang.String keyStoreFile)
setKeyStoreBytes(byte[])
.keyStoreFile
- File name of key store.SslContextConfigurator
instance.public SslContextConfigurator setKeyStoreBytes(byte[] keyStoreBytes)
setKeyStoreFile(java.lang.String)
.keyStoreBytes
- key store payload.SslContextConfigurator
instance.public SslContextConfigurator setTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)
trustManagerFactoryAlgorithm
- the trust manager factory algorithm.SslContextConfigurator
instance.public SslContextConfigurator setKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)
keyManagerFactoryAlgorithm
- the key manager factory algorithm.SslContextConfigurator
instance.public SslContextConfigurator setSecurityProtocol(java.lang.String securityProtocol)
TLS
if
this is null.securityProtocol
- Protocol for SSLContext.getProtocol()
.SslContextConfigurator
instance.public boolean validateConfiguration()
SslContextConfigurator
configuration.true
if configuration is valid, else
false
.public boolean validateConfiguration(boolean needsKeyStore)
SslContextConfigurator
configuration.needsKeyStore
- forces failure if no keystore is specified.true
if configuration is valid, else
false
.public javax.net.ssl.SSLContext createSSLContext()
SSLContext
from current configuration.SSLContext
.public SslContextConfigurator retrieve(java.util.Properties props)
props
- property map (usually taken from System.getProperties()
).SslContextConfigurator
instance.Copyright © 2012–2020 Oracle Corporation. All rights reserved.