Package org.glassfish.grizzly.ssl
Class SSLEngineConfigurator
- java.lang.Object
-
- org.glassfish.grizzly.ssl.SSLEngineConfigurator
-
- All Implemented Interfaces:
SSLEngineFactory
public class SSLEngineConfigurator extends Object implements SSLEngineFactory
Utility class, which helps to configureSSLEngine.- Author:
- Alexey Stashok
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanclientModeClient mode when handshaking.protected String[]enabledCipherSuitesThe list of cipher suiteprotected String[]enabledProtocolsthe list of protocolsprotected booleanneedClientAuthRequire client Authentication.protected SSLContextsslContextprotected SSLContextConfiguratorsslContextConfigurationprotected booleanwantClientAuthTrue when requesting authentication.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSSLEngineConfigurator()SSLEngineConfigurator(SSLContext sslContext)Create SSL Engine configuration basing on passedSSLContext.SSLEngineConfigurator(SSLContext sslContext, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)Create SSL Engine configuration basing on passedSSLContext, using passed client mode, need/want client auth parameters.SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration)Create SSL Engine configuration basing on passedSSLContextConfigurator.SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)Create SSL Engine configuration basing on passedSSLContextConfigurator.SSLEngineConfigurator(SSLEngineConfigurator pattern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SSLEngineconfigure(SSLEngine sslEngine)Configure passedSSLEngine, using current configurator settingsSSLEngineConfiguratorcopy()SSLEnginecreateSSLEngine()Create and configureSSLEngineusing this context configuration.SSLEnginecreateSSLEngine(String peerHost, int peerPort)Create and configureSSLEngineusing this context configuration using advisory peer information.String[]getEnabledCipherSuites()String[]getEnabledProtocols()SSLContextgetSslContext()booleanisCipherConfigured()booleanisClientMode()WillSSLEnginebe configured to work in client mode.booleanisNeedClientAuth()booleanisProtocolConfigured()booleanisWantClientAuth()SSLEngineConfiguratorsetCipherConfigured(boolean isCipherConfigured)SSLEngineConfiguratorsetClientMode(boolean clientMode)SetSSLEngineto be configured to work in client mode.SSLEngineConfiguratorsetEnabledCipherSuites(String[] enabledCipherSuites)Sets a list of enabled cipher suites.SSLEngineConfiguratorsetEnabledProtocols(String[] enabledProtocols)Sets a list of enabled protocols.SSLEngineConfiguratorsetNeedClientAuth(boolean needClientAuth)SSLEngineConfiguratorsetProtocolConfigured(boolean isProtocolConfigured)SSLEngineConfiguratorsetWantClientAuth(boolean wantClientAuth)StringtoString()
-
-
-
Field Detail
-
sslContextConfiguration
protected volatile SSLContextConfigurator sslContextConfiguration
-
sslContext
protected volatile SSLContext sslContext
-
enabledCipherSuites
protected String[] enabledCipherSuites
The list of cipher suite
-
enabledProtocols
protected String[] enabledProtocols
the list of protocols
-
clientMode
protected boolean clientMode
Client mode when handshaking.
-
needClientAuth
protected boolean needClientAuth
Require client Authentication.
-
wantClientAuth
protected boolean wantClientAuth
True when requesting authentication.
-
-
Constructor Detail
-
SSLEngineConfigurator
public SSLEngineConfigurator(SSLContext sslContext)
Create SSL Engine configuration basing on passedSSLContext.- Parameters:
sslContext-SSLContext.
-
SSLEngineConfigurator
public SSLEngineConfigurator(SSLContext sslContext, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)
Create SSL Engine configuration basing on passedSSLContext, using passed client mode, need/want client auth parameters.- Parameters:
sslContext-SSLContext.clientMode-needClientAuth-wantClientAuth-
-
SSLEngineConfigurator
public SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration)
Create SSL Engine configuration basing on passedSSLContextConfigurator. This constructor makes possible to initialize SSLEngine and SSLContext in lazy fashion on firstcreateSSLEngine()call.- Parameters:
sslContextConfiguration-SSLContextConfigurator.
-
SSLEngineConfigurator
public SSLEngineConfigurator(SSLContextConfigurator sslContextConfiguration, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)
Create SSL Engine configuration basing on passedSSLContextConfigurator. This constructor makes possible to initialize SSLEngine and SSLContext in lazy fashion on firstcreateSSLEngine()call.- Parameters:
sslContextConfiguration-SSLContextConfigurator.clientMode-needClientAuth-wantClientAuth-
-
SSLEngineConfigurator
public SSLEngineConfigurator(SSLEngineConfigurator pattern)
-
SSLEngineConfigurator
protected SSLEngineConfigurator()
-
-
Method Detail
-
createSSLEngine
public SSLEngine createSSLEngine()
Create and configureSSLEngineusing this context configuration.- Returns:
SSLEngine.
-
createSSLEngine
public SSLEngine createSSLEngine(String peerHost, int peerPort)
Create and configureSSLEngineusing 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.
- Specified by:
createSSLEnginein interfaceSSLEngineFactory- Parameters:
peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
SSLEngine.
-
configure
public SSLEngine configure(SSLEngine sslEngine)
Configure passedSSLEngine, using current configurator settings
-
isClientMode
public boolean isClientMode()
WillSSLEnginebe configured to work in client mode.- Returns:
- true, if
SSLEnginewill be configured to work in client mode, or false for server mode.
-
setClientMode
public SSLEngineConfigurator setClientMode(boolean clientMode)
SetSSLEngineto be configured to work in client mode.- Parameters:
clientMode- true, ifSSLEnginewill be configured to work in client mode, or false for server mode.- Returns:
- this SSLEngineConfigurator
-
isNeedClientAuth
public boolean isNeedClientAuth()
-
setNeedClientAuth
public SSLEngineConfigurator setNeedClientAuth(boolean needClientAuth)
-
isWantClientAuth
public boolean isWantClientAuth()
-
setWantClientAuth
public SSLEngineConfigurator setWantClientAuth(boolean wantClientAuth)
-
getEnabledCipherSuites
public String[] getEnabledCipherSuites()
- Returns:
- an array of enabled cipher suites. Modifications made on the array content won't be propagated to SSLEngineConfigurator
-
setEnabledCipherSuites
public SSLEngineConfigurator setEnabledCipherSuites(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- list of enabled cipher suites- Returns:
- this SSLEngineConfigurator
-
getEnabledProtocols
public String[] getEnabledProtocols()
- Returns:
- an array of enabled protocols. Modifications made on the array content won't be propagated to SSLEngineConfigurator
-
setEnabledProtocols
public SSLEngineConfigurator setEnabledProtocols(String[] enabledProtocols)
Sets a list of enabled protocols. Note: further modifications made on the passed array won't be propagated to SSLEngineConfigurator.- Parameters:
enabledProtocols- list of enabled protocols- Returns:
- this SSLEngineConfigurator
-
isCipherConfigured
public boolean isCipherConfigured()
-
setCipherConfigured
public SSLEngineConfigurator setCipherConfigured(boolean isCipherConfigured)
-
isProtocolConfigured
public boolean isProtocolConfigured()
-
setProtocolConfigured
public SSLEngineConfigurator setProtocolConfigured(boolean isProtocolConfigured)
-
getSslContext
public SSLContext getSslContext()
-
copy
public SSLEngineConfigurator copy()
-
-