Top Description Fields Constructors Methods
org.glassfish.tyrus.container.jdk.client

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

Deprecated

Please use org.glassfish.tyrus.client.SslContextConfigurator.

Utility class, which helps to configure ssl context.

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);
Authors
Alexey Stashok, Hubert Iwaniuk, Bruno Harbulot, Marek Potociar

Field Summary

Modifier and TypeField and Description
public static final SslContextConfigurator
DEFAULT_CONFIG

References Deprecated SslContextConfigurator is deprecated or references (maybe indirectly) at least one deprecated element.
Default SSL configuration.
public static final String
KEY_FACTORY_MANAGER_ALGORITHM

Key manager factory algorithm name.

public static final String
KEY_STORE_FILE

Key store file name.

public static final String
KEY_STORE_PASSWORD

Key store file password - the password used to unlock the trust store file.

public static final String
KEY_STORE_PROVIDER

Key store provider name.

public static final String
KEY_STORE_TYPE

Key store type (see java.security.KeyStore#getType() for more info).

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
TRUST_FACTORY_MANAGER_ALGORITHM

Trust manager factory algorithm name.

public static final String
TRUST_STORE_FILE

Trust store file name.

public static final String
TRUST_STORE_PASSWORD

Trust store file password - the password used to unlock the trust store file.

public static final String
TRUST_STORE_PROVIDER

Trust store provider name.

public static final String
TRUST_STORE_TYPE

Trust store type (see java.security.KeyStore#getType() for more info).

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
public void
public void
setKeyManagerFactoryAlgorithm(String
the key manager factory algorithm.
keyManagerFactoryAlgorithm
)

Sets the key manager factory algorithm.

public void
setKeyPassword(String
Password of key to set.
keyPassword
)

Password of the key in the key store.

public void
setKeyPassword(char[]
Password of key to set.
keyPassword
)

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
setKeyStorePassword(String
Password of key store to set.
keyStorePassword
)

Password of key store.

public void
setKeyStorePassword(char[]
Password of key store to set.
keyStorePassword
)

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
setTrustStorePassword(String
Password of trust store to set.
trustStorePassword
)

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
()

Validates SslContextConfigurator configuration.

public boolean

Returns:

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

Validates SslContextConfigurator configuration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CONFIGback to summary
public static final SslContextConfigurator DEFAULT_CONFIG

References Deprecated

SslContextConfigurator is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

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 manager factory algorithm name.

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 .

KEY_STORE_FILEback to summary
public static final String KEY_STORE_FILE

Key store file name.

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 .

KEY_STORE_PASSWORDback to summary
public static final String KEY_STORE_PASSWORD

Key store file password - the password used to unlock the trust store file.

The value MUST be a String representing the key store file password.

No default value is set.

The name of the configuration property is .

KEY_STORE_PROVIDERback to summary
public static final String KEY_STORE_PROVIDER

Key store provider name.

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 .

KEY_STORE_TYPEback to summary
public static final String KEY_STORE_TYPE

Key store type (see java.security.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 .

keyManagerFactoryAlgorithmback to summary
private String keyManagerFactoryAlgorithm
keyPasswordback to summary
private char[] keyPassword
keyStoreBytesback to summary
private byte[] keyStoreBytes
keyStoreFileback to summary
private String keyStoreFile
keyStorePasswordback to summary
private char[] keyStorePassword
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 manager factory algorithm name.

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 .

TRUST_STORE_FILEback to summary
public static final String TRUST_STORE_FILE

Trust store file name.

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 .

TRUST_STORE_PASSWORDback to summary
public static final String TRUST_STORE_PASSWORD

Trust store file password - the password used to unlock the trust store file.

The value MUST be a String representing the trust store file password.

No default value is set.

The name of the configuration property is .

TRUST_STORE_PROVIDERback to summary
public static final String TRUST_STORE_PROVIDER

Trust store provider name.

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 .

TRUST_STORE_TYPEback to summary
public static final String TRUST_STORE_TYPE

Trust store type (see java.security.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 .

trustManagerFactoryAlgorithmback to summary
private String trustManagerFactoryAlgorithm
trustStoreBytesback to summary
private byte[] trustStoreBytes
trustStoreFileback to summary
private String trustStoreFile
trustStorePasswordback to summary
private char[] trustStorePassword
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()
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.

setKeyPasswordback to summary
public void setKeyPassword(String keyPassword)

Password of the key in the key store.

Parameters
keyPassword:String

Password of key to set.

setKeyPasswordback to summary
public void setKeyPassword(char[] keyPassword)

Password of the key in the key store.

Parameters
keyPassword: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.

setKeyStorePasswordback to summary
public void setKeyStorePassword(String keyStorePassword)

Password of key store.

Parameters
keyStorePassword:String

Password of key store to set.

setKeyStorePasswordback to summary
public void setKeyStorePassword(char[] keyStorePassword)

Password of key store.

Parameters
keyStorePassword: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.

setTrustStorePasswordback to summary
public void setTrustStorePassword(String trustStorePassword)

Password of trust store.

Parameters
trustStorePassword: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()

Validates SslContextConfigurator configuration.

Returns:boolean

true if configuration is valid, else false.

validateConfigurationback to summary
public boolean validateConfiguration(boolean needsKeyStore)

Validates SslContextConfigurator configuration.

Parameters
needsKeyStore:boolean

forces failure if no keystore is specified.

Returns:boolean

true if configuration is valid, else false.