Package org.glassfish.grizzly.ssl
Class SSLContextConfigurator
- java.lang.Object
-
- org.glassfish.grizzly.ssl.SSLContextConfigurator
-
public class SSLContextConfigurator extends Object
Utility class, which helps to configureSSLContext
.- Author:
- Alexey Stashok, Hubert Iwaniuk, Bruno Harbulot
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SSLContextConfigurator.GenericStoreException
-
Field Summary
Fields Modifier and Type Field Description static SSLContextConfigurator
DEFAULT_CONFIG
Default SSL configuration.static String
KEY_FACTORY_MANAGER_ALGORITHM
static String
KEY_STORE_FILE
static String
KEY_STORE_PASSWORD
static String
KEY_STORE_PROVIDER
static String
KEY_STORE_TYPE
static String
TRUST_FACTORY_MANAGER_ALGORITHM
static String
TRUST_STORE_FILE
static String
TRUST_STORE_PASSWORD
static String
TRUST_STORE_PROVIDER
static String
TRUST_STORE_TYPE
-
Constructor Summary
Constructors Constructor Description SSLContextConfigurator()
Default constructor.SSLContextConfigurator(boolean readSystemProperties)
Constructor that allows you creating empty configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SSLContext
createSSLContext()
Deprecated.SSLContext
createSSLContext(boolean throwException)
Create a newSSLContext
.void
retrieve(Properties props)
void
setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm.void
setKeyPass(char[] keyPass)
Password of the key in the key store.void
setKeyPass(String keyPass)
Password of the key in the key store.void
setKeyStoreBytes(byte[] keyStoreBytes)
Sets key store payload as byte array.void
setKeyStoreFile(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.void
setKeyStorePass(char[] keyStorePass)
Password of key store.void
setKeyStorePass(String keyStorePass)
Password of key store.void
setKeyStoreProvider(String keyStoreProvider)
Sets the key store provider name.void
setKeyStoreType(String keyStoreType)
Type of key store.void
setSecurityProtocol(String securityProtocol)
Sets the SSLContext protocol.void
setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm.void
setTrustStoreBytes(byte[] trustStoreBytes)
Sets trust store payload as byte array.void
setTrustStoreFile(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.void
setTrustStorePass(String trustStorePass)
Password of trust store.void
setTrustStoreProvider(String trustStoreProvider)
Sets the trust store provider name.void
setTrustStoreType(String trustStoreType)
Type of trust store.boolean
validateConfiguration()
Deprecated.boolean
validateConfiguration(boolean needsKeyStore)
Deprecated.
-
-
-
Field Detail
-
TRUST_STORE_PROVIDER
public static final String TRUST_STORE_PROVIDER
- See Also:
- Constant Field Values
-
KEY_STORE_PROVIDER
public static final String KEY_STORE_PROVIDER
- See Also:
- Constant Field Values
-
TRUST_STORE_FILE
public static final String TRUST_STORE_FILE
- See Also:
- Constant Field Values
-
KEY_STORE_FILE
public static final String KEY_STORE_FILE
- See Also:
- Constant Field Values
-
TRUST_STORE_PASSWORD
public static final String TRUST_STORE_PASSWORD
- See Also:
- Constant Field Values
-
KEY_STORE_PASSWORD
public static final String KEY_STORE_PASSWORD
- See Also:
- Constant Field Values
-
TRUST_STORE_TYPE
public static final String TRUST_STORE_TYPE
- See Also:
- Constant Field Values
-
KEY_STORE_TYPE
public static final String KEY_STORE_TYPE
- See Also:
- Constant Field Values
-
KEY_FACTORY_MANAGER_ALGORITHM
public static final String KEY_FACTORY_MANAGER_ALGORITHM
- See Also:
- Constant Field Values
-
TRUST_FACTORY_MANAGER_ALGORITHM
public static final String TRUST_FACTORY_MANAGER_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_CONFIG
public static final SSLContextConfigurator DEFAULT_CONFIG
Default SSL configuration. If you have changed any ofSystem.getProperties()
of javax.net.ssl family you should refresh this configuration by callingretrieve(java.util.Properties)
.
-
-
Constructor Detail
-
SSLContextConfigurator
public SSLContextConfigurator()
Default constructor. Reads configuration properties fromSystem.getProperties()
. CallsSSLContextConfigurator(boolean)
withtrue
.
-
SSLContextConfigurator
public SSLContextConfigurator(boolean readSystemProperties)
Constructor that allows you creating empty configuration.- Parameters:
readSystemProperties
- Iftrue
populates configuration fromSystem.getProperties()
, else you have empty configuration.
-
-
Method Detail
-
setTrustStoreProvider
public void setTrustStoreProvider(String trustStoreProvider)
Sets the trust store provider name.- Parameters:
trustStoreProvider
- Trust store provider to set.
-
setKeyStoreProvider
public void setKeyStoreProvider(String keyStoreProvider)
Sets the key store provider name.- Parameters:
keyStoreProvider
- Key store provider to set.
-
setTrustStoreType
public void setTrustStoreType(String trustStoreType)
Type of trust store.- Parameters:
trustStoreType
- Type of trust store to set.
-
setKeyStoreType
public void setKeyStoreType(String keyStoreType)
Type of key store.- Parameters:
keyStoreType
- Type of key store to set.
-
setTrustStorePass
public void setTrustStorePass(String trustStorePass)
Password of trust store.- Parameters:
trustStorePass
- Password of trust store to set.
-
setKeyStorePass
public void setKeyStorePass(String keyStorePass)
Password of key store.- Parameters:
keyStorePass
- Password of key store to set.
-
setKeyStorePass
public void setKeyStorePass(char[] keyStorePass)
Password of key store.- Parameters:
keyStorePass
- Password of key store to set.
-
setKeyPass
public void setKeyPass(String keyPass)
Password of the key in the key store.- Parameters:
keyPass
- Password of key to set.
-
setKeyPass
public void setKeyPass(char[] keyPass)
Password of the key in the key store.- Parameters:
keyPass
- Password of key to set.
-
setTrustStoreFile
public void setTrustStoreFile(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. Method resets trust store bytes if any have been set before viasetTrustStoreBytes(byte[])
.- Parameters:
trustStoreFile
- File name of trust store.
-
setTrustStoreBytes
public void setTrustStoreBytes(byte[] trustStoreBytes)
Sets trust store payload as byte array. Method resets trust store file if any has been set before viasetTrustStoreFile(java.lang.String)
.- Parameters:
trustStoreBytes
- trust store payload.
-
setKeyStoreFile
public void setKeyStoreFile(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. Method resets key store bytes if any have been set before viasetKeyStoreBytes(byte[])
.- Parameters:
keyStoreFile
- File name of key store.
-
setKeyStoreBytes
public void setKeyStoreBytes(byte[] keyStoreBytes)
Sets key store payload as byte array. Method resets key store file if any has been set before viasetKeyStoreFile(java.lang.String)
.- Parameters:
keyStoreBytes
- key store payload.
-
setTrustManagerFactoryAlgorithm
public void setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm.- Parameters:
trustManagerFactoryAlgorithm
- the trust manager factory algorithm.
-
setKeyManagerFactoryAlgorithm
public void setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm.- Parameters:
keyManagerFactoryAlgorithm
- the key manager factory algorithm.
-
setSecurityProtocol
public void setSecurityProtocol(String securityProtocol)
Sets the SSLContext protocol. The default value isTLS
if this is null.- Parameters:
securityProtocol
- Protocol forSSLContext.getProtocol()
.
-
validateConfiguration
@Deprecated public boolean validateConfiguration()
Deprecated.ValidatesSSLContextConfigurator
configuration.- Returns:
true
if configuration is valid, elsefalse
.
-
validateConfiguration
@Deprecated public boolean validateConfiguration(boolean needsKeyStore)
Deprecated.ValidatesSSLContextConfigurator
configuration.- Parameters:
needsKeyStore
- forces failure if no keystore is specified.- Returns:
true
if configuration is valid, elsefalse
.
-
createSSLContext
@Deprecated public SSLContext createSSLContext()
Deprecated.Create a newSSLContext
. Note that if there are any problems with the key or trust stores, that no exception will be thrown.- Returns:
- a new
SSLContext
-
createSSLContext
public SSLContext createSSLContext(boolean throwException)
Create a newSSLContext
. If theSSLContext
cannot be created for whatever reason, aSSLContextConfigurator.GenericStoreException
will be raised containing the root cause of the failure.- Parameters:
throwException
-true
if an exception should be raised upon failure.- Returns:
- a new
SSLContext
- Throws:
SSLContextConfigurator.GenericStoreException
-throwException
istrue
and the SSLContext cannot be created- Since:
- 2.3.28
-
retrieve
public void retrieve(Properties props)
-
-