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

public Class SSLEngineConfigurator

extends Object
implements SSLEngineFactory
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.ssl.SSLEngineFactory
Imports
java.util.ArrayList, .Arrays, java.util.logging.Logger, javax.net.ssl.SSLContext, .SSLEngine, .SSLParameters, org.glassfish.grizzly.Grizzly

Utility class, which helps to configure SSLEngine.
Author
Alexey Stashok

Field Summary

Modifier and TypeField and Description
protected boolean
clientMode

Client mode when handshaking.

private static final Logger
protected volatile SSLContext
protected volatile SSLContextConfigurator
private SSLParameters
sslParameters

Parameters to configure SSLEngine.

private final Object

Constructor Summary

AccessConstructor and Description
public
SSLEngineConfigurator(SSLContext sslContext)

Create SSL Engine configuration basing on passed SSLContext.

public
SSLEngineConfigurator(final SSLContext sslContext, final boolean clientMode, final boolean needClientAuth, final boolean wantClientAuth)

Create SSL Engine configuration basing on passed SSLContext, using passed client mode, need/want client auth parameters.

public
SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration)

Create SSL Engine configuration basing on passed SSLContextConfigurator.

public
SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)

Create SSL Engine configuration basing on passed SSLContextConfigurator.

public
protected

Method Summary

Modifier and TypeMethod and Description
public SSLEngine

Returns:

configured SSLEngine.
configure
(final SSLEngine
SSLEngine to configure.
sslEngine
)

Configure passed SSLEngine, using current configurator settings

private static String[]

Returns:

Array of SSL cipher suites to be enabled, or null if none of the requested ciphers are supported
configureEnabledCiphers
(SSLEngine sslEngine, String[] requestedCiphers)

Determines the SSL cipher suites to be enabled.

private static String[]

Returns:

String[] an array of supported protocols.
configureEnabledProtocols
(SSLEngine sslEngine, String[] requestedProtocols)

Return the list of allowed protocol.

public SSLEngineConfigurator
copy()

private SSLParameters
public SSLEngine

Returns:

SSLEngine.
createSSLEngine
()

Create and configure SSLEngine using this context configuration.

public SSLEngine

Returns:

SSLEngine.
createSSLEngine
(final String
the non-authoritative name of the host
peerHost
,
final int
the non-authoritative port
peerPort
)

Implements org.glassfish.grizzly.ssl.SSLEngineFactory.createSSLEngine.

Create and configure SSLEngine using this context configuration using advisory peer information.

public String[]
getEnabledCipherSuites()

Returns: an array of enabled cipher suites.

public String[]
getEnabledProtocols()

Returns: an array of enabled protocols.

public SSLContext
public boolean

Returns:

true, if SSLEngine will be configured to work in client mode, or false for server mode.
isClientMode
()

Will SSLEngine be configured to work in client mode.

public boolean
public boolean
public SSLEngineConfigurator

Returns:

this SSLEngineConfigurator
setClientMode
(boolean
true, if SSLEngine will be configured to work in client mode, or false for server mode.
clientMode
)

Set SSLEngine to be configured to work in client mode.

public SSLEngineConfigurator

Returns:

this SSLEngineConfigurator
setEnabledCipherSuites
(final String[]
list of enabled cipher suites
enabledCipherSuites
)

Sets a list of enabled cipher suites.

public SSLEngineConfigurator

Returns:

this SSLEngineConfigurator
setEnabledProtocols
(final String[]
list of enabled protocols
enabledProtocols
)

Sets a list of enabled protocols.

public SSLEngineConfigurator
setNeedClientAuth(boolean needClientAuth)

public SSLEngineConfigurator

Returns:

this SSLEngineConfigurator
setSSLParameters
(SSLParameters sslParameters)

Apply SSLParameters to this SSLEngineConfigurator.

public SSLEngineConfigurator
setWantClientAuth(boolean wantClientAuth)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

clientModeback to summary
protected boolean clientMode

Client mode when handshaking.

LOGGERback to summary
private static final Logger LOGGER
sslContextback to summary
protected volatile SSLContext sslContext
sslContextConfigurationback to summary
protected volatile SSLContextConfigurator sslContextConfiguration
sslParametersback to summary
private SSLParameters sslParameters

Parameters to configure SSLEngine.

syncback to summary
private final Object sync

Constructor Detail

SSLEngineConfiguratorback to summary
public SSLEngineConfigurator(SSLContext sslContext)

Create SSL Engine configuration basing on passed SSLContext.

Parameters
sslContext:SSLContext

SSLContext.

SSLEngineConfiguratorback to summary
public SSLEngineConfigurator(final SSLContext sslContext, final boolean clientMode, final boolean needClientAuth, final boolean wantClientAuth)

Create SSL Engine configuration basing on passed SSLContext, using passed client mode, need/want client auth parameters.

Parameters
sslContext:SSLContext

SSLContext.

SSLEngineConfiguratorback to summary
public SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration)

Create SSL Engine configuration basing on passed SSLContextConfigurator. This constructor makes possible to initialize SSLEngine and SSLContext in lazy fashion on first createSSLEngine() call.

Parameters
sslContextConfiguration:SSLContextConfigurator

SSLContextConfigurator.

SSLEngineConfiguratorback to summary
public SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)

Create SSL Engine configuration basing on passed SSLContextConfigurator. This constructor makes possible to initialize SSLEngine and SSLContext in lazy fashion on first createSSLEngine() call.

Parameters
sslContextConfiguration:SSLContextConfigurator

SSLContextConfigurator.

SSLEngineConfiguratorback to summary
public SSLEngineConfigurator(SSLEngineConfigurator pattern)
SSLEngineConfiguratorback to summary
protected SSLEngineConfigurator()

Method Detail

configureback to summary
public SSLEngine configure(final SSLEngine sslEngine)

Configure passed SSLEngine, using current configurator settings

Parameters
sslEngine:SSLEngine

SSLEngine to configure.

Returns:SSLEngine

configured SSLEngine.

configureEnabledCiphersback to summary
private static String[] configureEnabledCiphers(SSLEngine sslEngine, String[] requestedCiphers)

Determines the SSL cipher suites to be enabled.

Returns:String[]

Array of SSL cipher suites to be enabled, or null if none of the requested ciphers are supported

configureEnabledProtocolsback to summary
private static String[] configureEnabledProtocols(SSLEngine sslEngine, String[] requestedProtocols)

Return the list of allowed protocol.

Returns:String[]

String[] an array of supported protocols.

copyback to summary
public SSLEngineConfigurator copy()
copyback to summary
private SSLParameters copy(SSLParameters src)
createSSLEngineback to summary
public SSLEngine createSSLEngine()

Create and configure SSLEngine using this context configuration.

Returns:SSLEngine

SSLEngine.

createSSLEngineback to summary
public SSLEngine createSSLEngine(final String peerHost, final int peerPort)

Implements org.glassfish.grizzly.ssl.SSLEngineFactory.createSSLEngine.

Create and configure SSLEngine using this context configuration using advisory peer information.

Applications using this factory method are providing hints for an internal session reuse strategy.

Some cipher suites (such as Kerberos) require remote hostname information, in which case peerHost needs to be specified.

Parameters
peerHost:String

the non-authoritative name of the host

peerPort:int

the non-authoritative port

Returns:SSLEngine

SSLEngine.

Annotations
@Override
getEnabledCipherSuitesback to summary
public String[] getEnabledCipherSuites()
Returns:String[]

an array of enabled cipher suites. Modifications made on the array content won't be propagated to SSLEngineConfigurator

getEnabledProtocolsback to summary
public String[] getEnabledProtocols()
Returns:String[]

an array of enabled protocols. Modifications made on the array content won't be propagated to SSLEngineConfigurator

getSslContextback to summary
public SSLContext getSslContext()
isClientModeback to summary
public boolean isClientMode()

Will SSLEngine be configured to work in client mode.

Returns:boolean

true, if SSLEngine will be configured to work in client mode, or false for server mode.

isNeedClientAuthback to summary
public boolean isNeedClientAuth()
isWantClientAuthback to summary
public boolean isWantClientAuth()
setClientModeback to summary
public SSLEngineConfigurator setClientMode(boolean clientMode)

Set SSLEngine to be configured to work in client mode.

Parameters
clientMode:boolean

true, if SSLEngine will be configured to work in client mode, or false for server mode.

Returns:SSLEngineConfigurator

this SSLEngineConfigurator

setEnabledCipherSuitesback to summary
public SSLEngineConfigurator setEnabledCipherSuites(final String[] enabledCipherSuites)

Sets a list of enabled cipher suites.

Note

further modifications made on the passed array won't be propagated to SSLEngineConfigurator.

Parameters
enabledCipherSuites:String[]

list of enabled cipher suites

Returns:SSLEngineConfigurator

this SSLEngineConfigurator

setEnabledProtocolsback to summary
public SSLEngineConfigurator setEnabledProtocols(final String[] enabledProtocols)

Sets a list of enabled protocols.

Note

further modifications made on the passed array won't be propagated to SSLEngineConfigurator.

Parameters
enabledProtocols:String[]

list of enabled protocols

Returns:SSLEngineConfigurator

this SSLEngineConfigurator

setNeedClientAuthback to summary
public SSLEngineConfigurator setNeedClientAuth(boolean needClientAuth)
setSSLParametersback to summary
public SSLEngineConfigurator setSSLParameters(SSLParameters sslParameters)

Apply SSLParameters to this SSLEngineConfigurator.

Returns:SSLEngineConfigurator

this SSLEngineConfigurator

setWantClientAuthback to summary
public SSLEngineConfigurator setWantClientAuth(boolean wantClientAuth)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override