Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.ssl

public Class SSLContextConfigurator

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .FileInputStream, .FileNotFoundException, .IOException, .InputStream, java.security.KeyManagementException, .KeyStore, .KeyStoreException, .NoSuchAlgorithmException, .NoSuchProviderException, .UnrecoverableKeyException, java.security.cert.CertificateException, java.util.Properties, java.util.logging.Level, .Logger, javax.net.ssl.KeyManagerFactory, .SSLContext, .TrustManagerFactory, org.glassfish.grizzly.Grizzly

Utility class, which helps to configure SSLContext.
Authors
Alexey Stashok, Hubert Iwaniuk, Bruno Harbulot

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final SSLContextConfigurator
DEFAULT_CONFIG

Default SSL configuration.

public static final String
public static final String
public static final String
public static final String
public static final String
private String
private char[]
private byte[]
private String
private char[]
private String
private String
private static final Logger
LOGGER

Default Logger.

private String
public static final String
public static final String
public static final String
public static final String
public static final String
private String
private byte[]
private String
private char[]
private String
private String

Constructor Summary

AccessConstructor and Description
public
SSLContextConfigurator()

Default constructor.

public
SSLContextConfigurator(boolean
If true populates configuration from System#getProperties(), else you have empty configuration.
readSystemProperties
)

Constructor that allows you creating empty configuration.

Method Summary

Modifier and TypeMethod and Description
public SSLContext

Returns:

a new SSLContext
createSSLContext
()
Deprecated Use createSSLContext(boolean).

Create a new SSLContext.

public SSLContext

Returns:

a new SSLContext
createSSLContext
(final boolean
true if an exception should be raised upon failure.
throwException
)

Create a new SSLContext.

private static void
loadBytes(final byte[] bytes, final String storeFile, final char[] password, final KeyStore store)

public void
public void
setKeyManagerFactoryAlgorithm(String
the key manager factory algorithm.
keyManagerFactoryAlgorithm
)

Sets the key manager factory algorithm.

public void
setKeyPass(String
Password of key to set.
keyPass
)

Password of the key in the key store.

public void
setKeyPass(char[]
Password of key to set.
keyPass
)

Password of the key in the key store.

public void
setKeyStoreBytes(byte[]
key store payload.
keyStoreBytes
)

Sets key store payload as byte array.

public void
setKeyStoreFile(String
File name of key store.
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.

public void
setKeyStorePass(String
Password of key store to set.
keyStorePass
)

Password of key store.

public void
setKeyStorePass(char[]
Password of key store to set.
keyStorePass
)

Password of key store.

public void
setKeyStoreProvider(String
Key store provider to set.
keyStoreProvider
)

Sets the key store provider name.

public void
setKeyStoreType(String
Type of key store to set.
keyStoreType
)

Type of key store.

public void
setSecurityProtocol(String securityProtocol)

Sets the SSLContext protocol.

public void
setTrustManagerFactoryAlgorithm(String
the trust manager factory algorithm.
trustManagerFactoryAlgorithm
)

Sets the trust manager factory algorithm.

public void
setTrustStoreBytes(byte[]
trust store payload.
trustStoreBytes
)

Sets trust store payload as byte array.

public void
setTrustStoreFile(String
File name of trust store.
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.

public void
setTrustStorePass(String
Password of trust store to set.
trustStorePass
)

Password of trust store.

public void
setTrustStoreProvider(String
Trust store provider to set.
trustStoreProvider
)

Sets the trust store provider name.

public void
setTrustStoreType(String
Type of trust store to set.
trustStoreType
)

Type of trust store.

public boolean

Returns:

true if configuration is valid, else false.
validateConfiguration
()
Deprecated Use createSSLContext(boolean).

Validates SSLContextConfigurator configuration.

public boolean

Returns:

true if configuration is valid, else false.
validateConfiguration
(boolean
forces failure if no keystore is specified.
needsKeyStore
)
Deprecated Use createSSLContext(boolean).

Validates SSLContextConfigurator configuration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CONFIGback to summary
public static final SSLContextConfigurator DEFAULT_CONFIG

Default SSL configuration. If you have changed any of System#getProperties() of javax.net.ssl family you should refresh this configuration by calling retrieve(java.util.Properties).

KEY_FACTORY_MANAGER_ALGORITHMback to summary
public static final String KEY_FACTORY_MANAGER_ALGORITHM
KEY_STORE_FILEback to summary
public static final String KEY_STORE_FILE
KEY_STORE_PASSWORDback to summary
public static final String KEY_STORE_PASSWORD
KEY_STORE_PROVIDERback to summary
public static final String KEY_STORE_PROVIDER
KEY_STORE_TYPEback to summary
public static final String KEY_STORE_TYPE
keyManagerFactoryAlgorithmback to summary
private String keyManagerFactoryAlgorithm
keyPassback to summary
private char[] keyPass
keyStoreBytesback to summary
private byte[] keyStoreBytes
keyStoreFileback to summary
private String keyStoreFile
keyStorePassback to summary
private char[] keyStorePass
keyStoreProviderback to summary
private String keyStoreProvider
keyStoreTypeback to summary
private String keyStoreType
LOGGERback to summary
private static final Logger LOGGER

Default Logger.

securityProtocolback to summary
private String securityProtocol
TRUST_FACTORY_MANAGER_ALGORITHMback to summary
public static final String TRUST_FACTORY_MANAGER_ALGORITHM
TRUST_STORE_FILEback to summary
public static final String TRUST_STORE_FILE
TRUST_STORE_PASSWORDback to summary
public static final String TRUST_STORE_PASSWORD
TRUST_STORE_PROVIDERback to summary
public static final String TRUST_STORE_PROVIDER
TRUST_STORE_TYPEback to summary
public static final String TRUST_STORE_TYPE
trustManagerFactoryAlgorithmback to summary
private String trustManagerFactoryAlgorithm
trustStoreBytesback to summary
private byte[] trustStoreBytes
trustStoreFileback to summary
private String trustStoreFile
trustStorePassback to summary
private char[] trustStorePass
trustStoreProviderback to summary
private String trustStoreProvider
trustStoreTypeback to summary
private String trustStoreType

Constructor Detail

SSLContextConfiguratorback to summary
public SSLContextConfigurator()

Default constructor. Reads configuration properties from System#getProperties(). Calls SSLContextConfigurator(boolean) with true.

SSLContextConfiguratorback to summary
public SSLContextConfigurator(boolean readSystemProperties)

Constructor that allows you creating empty configuration.

Parameters
readSystemProperties:boolean

If true populates configuration from System#getProperties(), else you have empty configuration.

Method Detail

createSSLContextback to summary
public SSLContext createSSLContext()

Deprecated

Use createSSLContext(boolean).

Create a new SSLContext. Note that if there are any problems with the key or trust stores, that no exception will be thrown.

Returns:SSLContext

a new SSLContext

Annotations
@Deprecated
createSSLContextback to summary
public SSLContext createSSLContext(final boolean throwException)

Create a new SSLContext. If the SSLContext cannot be created for whatever reason, a GenericStoreException will be raised containing the root cause of the failure.

Parameters
throwException:boolean

true if an exception should be raised upon failure.

Returns:SSLContext

a new SSLContext

Exceptions
GenericStoreException:
throwException is true and the SSLContext cannot be created
Since
2.3.28
loadBytesback to summary
private static void loadBytes(final byte[] bytes, final String storeFile, final char[] password, final KeyStore store) throws IOException, CertificateException, NoSuchAlgorithmException
retrieveback to summary
public void retrieve(Properties props)
setKeyManagerFactoryAlgorithmback to summary
public void setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)

Sets the key manager factory algorithm.

Parameters
keyManagerFactoryAlgorithm:String

the key manager factory algorithm.

setKeyPassback to summary
public void setKeyPass(String keyPass)

Password of the key in the key store.

Parameters
keyPass:String

Password of key to set.

setKeyPassback to summary
public void setKeyPass(char[] keyPass)

Password of the key in the key store.

Parameters
keyPass:char[]

Password of key to set.

setKeyStoreBytesback to summary
public void setKeyStoreBytes(byte[] keyStoreBytes)

Sets key store payload as byte array. Method resets key store file if any has been set before via setKeyStoreFile(java.lang.String).

Parameters
keyStoreBytes:byte[]

key store payload.

setKeyStoreFileback to summary
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 via setKeyStoreBytes(byte[]).

Parameters
keyStoreFile:String

File name of key store.

setKeyStorePassback to summary
public void setKeyStorePass(String keyStorePass)

Password of key store.

Parameters
keyStorePass:String

Password of key store to set.

setKeyStorePassback to summary
public void setKeyStorePass(char[] keyStorePass)

Password of key store.

Parameters
keyStorePass:char[]

Password of key store to set.

setKeyStoreProviderback to summary
public void setKeyStoreProvider(String keyStoreProvider)

Sets the key store provider name.

Parameters
keyStoreProvider:String

Key store provider to set.

setKeyStoreTypeback to summary
public void setKeyStoreType(String keyStoreType)

Type of key store.

Parameters
keyStoreType:String

Type of key store to set.

setSecurityProtocolback to summary
public void setSecurityProtocol(String securityProtocol)

Sets the SSLContext protocol. The default value is TLS if this is null.

Parameters
securityProtocol:String

Protocol for javax.net.ssl.SSLContext#getProtocol().

setTrustManagerFactoryAlgorithmback to summary
public void setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)

Sets the trust manager factory algorithm.

Parameters
trustManagerFactoryAlgorithm:String

the trust manager factory algorithm.

setTrustStoreBytesback to summary
public void setTrustStoreBytes(byte[] trustStoreBytes)

Sets trust store payload as byte array. Method resets trust store file if any has been set before via setTrustStoreFile(java.lang.String).

Parameters
trustStoreBytes:byte[]

trust store payload.

setTrustStoreFileback to summary
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 via setTrustStoreBytes(byte[]).

Parameters
trustStoreFile:String

File name of trust store.

setTrustStorePassback to summary
public void setTrustStorePass(String trustStorePass)

Password of trust store.

Parameters
trustStorePass:String

Password of trust store to set.

setTrustStoreProviderback to summary
public void setTrustStoreProvider(String trustStoreProvider)

Sets the trust store provider name.

Parameters
trustStoreProvider:String

Trust store provider to set.

setTrustStoreTypeback to summary
public void setTrustStoreType(String trustStoreType)

Type of trust store.

Parameters
trustStoreType:String

Type of trust store to set.

validateConfigurationback to summary
public boolean validateConfiguration()

Deprecated

Use createSSLContext(boolean).

Validates SSLContextConfigurator configuration.

Returns:boolean

true if configuration is valid, else false.

Annotations
@Deprecated
validateConfigurationback to summary
public boolean validateConfiguration(boolean needsKeyStore)

Deprecated

Use createSSLContext(boolean).

Validates SSLContextConfigurator configuration.

Parameters
needsKeyStore:boolean

forces failure if no keystore is specified.

Returns:boolean

true if configuration is valid, else false.

Annotations
@Deprecated
org.glassfish.grizzly.ssl back to summary

public final Class SSLContextConfigurator.GenericStoreException

extends RuntimeException
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

GenericStoreExceptionback to summary
public GenericStoreException(Throwable cause)