Package org.glassfish.tyrus.client
Class SslEngineConfigurator
java.lang.Object
org.glassfish.tyrus.client.SslEngineConfigurator
SSLEngineConfigurator class from Grizzly project.
Utility class, which helps to configure SSLEngine
. Should 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);
- Author:
- Alexey Stashok
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Client mode when handshaking.protected String[]
The list of cipher suites.protected String[]
The list of protocols.protected boolean
Require client Authentication.protected SSLContext
protected SslContextConfigurator
protected boolean
True when requesting authentication. -
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructor.SslEngineConfigurator
(SSLContext sslContext) Create SSL Engine configuration basing on passedSSLContext
.SslEngineConfigurator
(SSLContext sslContext, boolean clientMode, boolean needClientAuth, boolean wantClientAuth) Create SSL Engine configuration based on passedSSLContext
, using passed client mode, need/want client auth parameters.SslEngineConfigurator
(SslContextConfigurator sslContextConfiguration) Create SSL Engine configuration based on passedSslContextConfigurator
.SslEngineConfigurator
(SslContextConfigurator sslContextConfiguration, boolean clientMode, boolean needClientAuth, boolean wantClientAuth) Create SSL Engine configuration basing on passedSslContextConfigurator
.SslEngineConfigurator
(SslEngineConfigurator original) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionConfigure passedSSLEngine
, using current configurator settings, excluding Hostname Verification.copy()
createSSLEngine
(String serverHost) Create and configureSSLEngine
, based on current settings.String[]
Get enabled cipher suites.String[]
Get enabled protocols.Get custom hostname verifier.CreateSSLContext
and store it for further invocation of this method.boolean
boolean
WillSSLEngine
be configured to work in client mode.boolean
Get the hostname verification state.boolean
Get "need client auth" property.boolean
boolean
Get "want client auth" property.setCipherConfigured
(boolean isCipherConfigured) setClientMode
(boolean clientMode) SetSSLEngine
to be configured to work in client mode.setEnabledCipherSuites
(String[] enabledCipherSuites) Set enabled cipher suites.setEnabledProtocols
(String[] enabledProtocols) Set enabled protocols.setHostnameVerifier
(HostnameVerifier hostnameVerifier) Set custom hostname verifier.setHostVerificationEnabled
(boolean hostVerificationEnabled) Set hostname verification.setNeedClientAuth
(boolean needClientAuth) Set "need client auth" property.setProtocolConfigured
(boolean isProtocolConfigured) setWantClientAuth
(boolean wantClientAuth) Set "want client auth" property.toString()
-
Field Details
-
sslContextConfiguration
-
sslContext
-
enabledCipherSuites
The list of cipher suites. -
enabledProtocols
The list of protocols. -
clientMode
protected boolean clientModeClient mode when handshaking. -
needClientAuth
protected boolean needClientAuthRequire client Authentication. -
wantClientAuth
protected boolean wantClientAuthTrue when requesting authentication.
-
-
Constructor Details
-
SslEngineConfigurator
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 based on passedSSLContext
, using passed client mode, need/want client auth parameters.- Parameters:
sslContext
-SSLContext
.clientMode
- will be configured to work in client mode.needClientAuth
- client authentication is required.wantClientAuth
- client should authenticate.
-
SslEngineConfigurator
Create SSL Engine configuration based on passedSslContextConfigurator
. This constructor makes possible to initialize SSLEngine and SSLContext in lazy fashion on firstcreateSSLEngine(String)
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(String)
call.- Parameters:
sslContextConfiguration
-SslContextConfigurator
.clientMode
- will be configured to work in client mode.needClientAuth
- client authentication is required.wantClientAuth
- client should authenticate.
-
SslEngineConfigurator
Copy constructor.- Parameters:
original
- originalSslEngineConfigurator
instance to be copied.
-
SslEngineConfigurator
protected SslEngineConfigurator()Default constructor.
-
-
Method Details
-
createSSLEngine
Create and configureSSLEngine
, based on current settings.- Parameters:
serverHost
- server host, which will be used to verify authenticity of the server (the provided host name will compared to the host in the certificate provided by the server).- Returns:
SSLEngine
.
-
configure
Configure passedSSLEngine
, using current configurator settings, excluding Hostname Verification. -
isClientMode
public boolean isClientMode()WillSSLEngine
be configured to work in client mode.- Returns:
true
, ifSSLEngine
will be configured to work inclient
mode, orfalse
forserver
mode.
-
setClientMode
SetSSLEngine
to be configured to work in client mode.- Parameters:
clientMode
-true
, ifSSLEngine
will be configured to work inclient
mode, orfalse
forserver
mode.- Returns:
- updated
SslEngineConfigurator
.
-
isNeedClientAuth
public boolean isNeedClientAuth()Get "need client auth" property.- Returns:
- need client auth property value;
-
setNeedClientAuth
Set "need client auth" property.- Parameters:
needClientAuth
- value to be set.- Returns:
- updated
SslEngineConfigurator
.
-
isWantClientAuth
public boolean isWantClientAuth()Get "want client auth" property.- Returns:
- need client auth property value;
-
setWantClientAuth
Set "want client auth" property.- Parameters:
wantClientAuth
- value to be set.- Returns:
- updated
SslEngineConfigurator
.
-
getEnabledCipherSuites
Get enabled cipher suites.- Returns:
String
array with enabled cipher suites.
-
setEnabledCipherSuites
Set enabled cipher suites.- Parameters:
enabledCipherSuites
-String
array with cipher suites.- Returns:
- updated
SslEngineConfigurator
.
-
getEnabledProtocols
Get enabled protocols.- Returns:
String
array with enabled protocols.
-
setEnabledProtocols
Set enabled protocols.- Parameters:
enabledProtocols
-String
array with protocols.- Returns:
- updated
SslEngineConfigurator
.
-
isCipherConfigured
public boolean isCipherConfigured() -
setCipherConfigured
-
isProtocolConfigured
public boolean isProtocolConfigured() -
setProtocolConfigured
-
isHostVerificationEnabled
public boolean isHostVerificationEnabled()Get the hostname verification state.- Returns:
true
if the hostname verification is enabled,false
otherwise.
-
setHostVerificationEnabled
Set hostname verification.- Parameters:
hostVerificationEnabled
- whentrue
, servers hostname will be verified using JDK defaultHostnameVerifier
. Whenfalse
, hostname verification won't be performed unless customHostnameVerifier
is set.- Returns:
- updated
SslEngineConfigurator
. - See Also:
-
getHostnameVerifier
Get custom hostname verifier.- Returns:
- user provided hostname verifier instance.
-
setHostnameVerifier
Set custom hostname verifier.When custom
HostnameVerifier
instance is registered, it will be used to perform hostname verification, no matter on the state of hostname verification flag (seeisHostVerificationEnabled()
) and JDK default hostname verifier won't be used.- Parameters:
hostnameVerifier
- custom hostname verifier.- Returns:
- updated
SslEngineConfigurator
.
-
getSslContext
CreateSSLContext
and store it for further invocation of this method.- Returns:
- created ssl context.
-
toString
-
copy
-