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
FieldsModifier and TypeFieldDescriptionprotected booleanClient mode when handshaking.protected String[]The list of cipher suites.protected String[]The list of protocols.protected booleanRequire client Authentication.protected SSLContextprotected SslContextConfiguratorprotected booleanTrue when requesting authentication. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault 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.CreateSSLContextand store it for further invocation of this method.booleanbooleanWillSSLEnginebe configured to work in client mode.booleanGet the hostname verification state.booleanGet "need client auth" property.booleanbooleanGet "want client auth" property.setCipherConfigured(boolean isCipherConfigured) setClientMode(boolean clientMode) SetSSLEngineto 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- originalSslEngineConfiguratorinstance 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()WillSSLEnginebe configured to work in client mode.- Returns:
true, ifSSLEnginewill be configured to work inclientmode, orfalseforservermode.
-
setClientMode
SetSSLEngineto be configured to work in client mode.- Parameters:
clientMode-true, ifSSLEnginewill be configured to work inclientmode, orfalseforservermode.- 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:
Stringarray with enabled cipher suites.
-
setEnabledCipherSuites
Set enabled cipher suites.- Parameters:
enabledCipherSuites-Stringarray with cipher suites.- Returns:
- updated
SslEngineConfigurator.
-
getEnabledProtocols
Get enabled protocols.- Returns:
Stringarray with enabled protocols.
-
setEnabledProtocols
Set enabled protocols.- Parameters:
enabledProtocols-Stringarray 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:
trueif the hostname verification is enabled,falseotherwise.
-
setHostVerificationEnabled
Set hostname verification.- Parameters:
hostVerificationEnabled- whentrue, servers hostname will be verified using JDK defaultHostnameVerifier. Whenfalse, hostname verification won't be performed unless customHostnameVerifieris set.- Returns:
- updated
SslEngineConfigurator. - See Also:
-
getHostnameVerifier
Get custom hostname verifier.- Returns:
- user provided hostname verifier instance.
-
setHostnameVerifier
Set custom hostname verifier.When custom
HostnameVerifierinstance 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
CreateSSLContextand store it for further invocation of this method.- Returns:
- created ssl context.
-
toString
-
copy
-