public class SslEngineConfigurator
extends java.lang.Object
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);
Modifier and Type | Field and Description |
---|---|
protected boolean |
clientMode
Client mode when handshaking.
|
protected java.lang.String[] |
enabledCipherSuites
The list of cipher suites.
|
protected java.lang.String[] |
enabledProtocols
The list of protocols.
|
protected boolean |
needClientAuth
Require client Authentication.
|
protected javax.net.ssl.SSLContext |
sslContext |
protected SslContextConfigurator |
sslContextConfiguration |
protected boolean |
wantClientAuth
True when requesting authentication.
|
Modifier | Constructor and Description |
---|---|
protected |
SslEngineConfigurator()
Default constructor.
|
|
SslEngineConfigurator(javax.net.ssl.SSLContext sslContext)
Create SSL Engine configuration basing on passed
SSLContext . |
|
SslEngineConfigurator(javax.net.ssl.SSLContext sslContext,
boolean clientMode,
boolean needClientAuth,
boolean wantClientAuth)
Create SSL Engine configuration based on passed
SSLContext ,
using passed client mode, need/want client auth parameters. |
|
SslEngineConfigurator(SslContextConfigurator sslContextConfiguration)
Create SSL Engine configuration based on passed
SslContextConfigurator . |
|
SslEngineConfigurator(SslContextConfigurator sslContextConfiguration,
boolean clientMode,
boolean needClientAuth,
boolean wantClientAuth)
Create SSL Engine configuration basing on passed
SslContextConfigurator . |
|
SslEngineConfigurator(SslEngineConfigurator original)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
javax.net.ssl.SSLEngine |
configure(javax.net.ssl.SSLEngine sslEngine)
Configure passed
SSLEngine , using current configurator settings, excluding Hostname Verification. |
SslEngineConfigurator |
copy() |
javax.net.ssl.SSLEngine |
createSSLEngine(java.lang.String serverHost)
Create and configure
SSLEngine , based on current settings. |
java.lang.String[] |
getEnabledCipherSuites()
Get enabled cipher suites.
|
java.lang.String[] |
getEnabledProtocols()
Get enabled protocols.
|
javax.net.ssl.HostnameVerifier |
getHostnameVerifier()
Get custom hostname verifier.
|
javax.net.ssl.SSLContext |
getSslContext()
Create
SSLContext and store it for further invocation of this method. |
boolean |
isCipherConfigured() |
boolean |
isClientMode()
Will
SSLEngine be configured to work in client mode. |
boolean |
isHostVerificationEnabled()
Get the hostname verification state.
|
boolean |
isNeedClientAuth()
Get "need client auth" property.
|
boolean |
isProtocolConfigured() |
boolean |
isWantClientAuth()
Get "want client auth" property.
|
SslEngineConfigurator |
setCipherConfigured(boolean isCipherConfigured) |
SslEngineConfigurator |
setClientMode(boolean clientMode)
Set
SSLEngine to be configured to work in client mode. |
SslEngineConfigurator |
setEnabledCipherSuites(java.lang.String[] enabledCipherSuites)
Set enabled cipher suites.
|
SslEngineConfigurator |
setEnabledProtocols(java.lang.String[] enabledProtocols)
Set enabled protocols.
|
SslEngineConfigurator |
setHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
Set custom hostname verifier.
|
SslEngineConfigurator |
setHostVerificationEnabled(boolean hostVerificationEnabled)
Set hostname verification.
|
SslEngineConfigurator |
setNeedClientAuth(boolean needClientAuth)
Set "need client auth" property.
|
SslEngineConfigurator |
setProtocolConfigured(boolean isProtocolConfigured) |
SslEngineConfigurator |
setWantClientAuth(boolean wantClientAuth)
Set "want client auth" property.
|
java.lang.String |
toString() |
protected volatile SslContextConfigurator sslContextConfiguration
protected volatile javax.net.ssl.SSLContext sslContext
protected java.lang.String[] enabledCipherSuites
protected java.lang.String[] enabledProtocols
protected boolean clientMode
protected boolean needClientAuth
protected boolean wantClientAuth
public SslEngineConfigurator(javax.net.ssl.SSLContext sslContext)
SSLContext
.sslContext
- SSLContext
.public SslEngineConfigurator(javax.net.ssl.SSLContext sslContext, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)
SSLContext
,
using passed client mode, need/want client auth parameters.sslContext
- SSLContext
.clientMode
- will be configured to work in client mode.needClientAuth
- client authentication is required.wantClientAuth
- client should authenticate.public SslEngineConfigurator(SslContextConfigurator sslContextConfiguration)
SslContextConfigurator
.
This constructor makes possible to initialize SSLEngine and SSLContext in lazy
fashion on first createSSLEngine(String)
call.sslContextConfiguration
- SslContextConfigurator
.public SslEngineConfigurator(SslContextConfigurator sslContextConfiguration, boolean clientMode, boolean needClientAuth, boolean wantClientAuth)
SslContextConfigurator
.
This constructor makes possible to initialize SSLEngine and SSLContext in lazy
fashion on first createSSLEngine(String)
call.sslContextConfiguration
- SslContextConfigurator
.clientMode
- will be configured to work in client mode.needClientAuth
- client authentication is required.wantClientAuth
- client should authenticate.public SslEngineConfigurator(SslEngineConfigurator original)
original
- original SslEngineConfigurator
instance to be copied.protected SslEngineConfigurator()
public javax.net.ssl.SSLEngine createSSLEngine(java.lang.String serverHost)
SSLEngine
, based on current settings.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).SSLEngine
.public javax.net.ssl.SSLEngine configure(javax.net.ssl.SSLEngine sslEngine)
SSLEngine
, using current configurator settings, excluding Hostname Verification.sslEngine
- SSLEngine
to configure.SSLEngine
.public boolean isClientMode()
SSLEngine
be configured to work in client mode.true
, if SSLEngine
will be configured to work
in client
mode, or false
for server
mode.public SslEngineConfigurator setClientMode(boolean clientMode)
SSLEngine
to be configured to work in client mode.clientMode
- true
, if SSLEngine
will be configured
to work in client
mode, or false
for server
mode.SslEngineConfigurator
.public boolean isNeedClientAuth()
public SslEngineConfigurator setNeedClientAuth(boolean needClientAuth)
needClientAuth
- value to be set.SslEngineConfigurator
.public boolean isWantClientAuth()
public SslEngineConfigurator setWantClientAuth(boolean wantClientAuth)
wantClientAuth
- value to be set.SslEngineConfigurator
.public java.lang.String[] getEnabledCipherSuites()
String
array with enabled cipher suites.public SslEngineConfigurator setEnabledCipherSuites(java.lang.String[] enabledCipherSuites)
enabledCipherSuites
- String
array with cipher suites.SslEngineConfigurator
.public java.lang.String[] getEnabledProtocols()
String
array with enabled protocols.public SslEngineConfigurator setEnabledProtocols(java.lang.String[] enabledProtocols)
enabledProtocols
- String
array with protocols.SslEngineConfigurator
.public boolean isCipherConfigured()
public SslEngineConfigurator setCipherConfigured(boolean isCipherConfigured)
public boolean isProtocolConfigured()
public SslEngineConfigurator setProtocolConfigured(boolean isProtocolConfigured)
public boolean isHostVerificationEnabled()
true
if the hostname verification is enabled, false
otherwise.public SslEngineConfigurator setHostVerificationEnabled(boolean hostVerificationEnabled)
hostVerificationEnabled
- when true
, servers hostname will be verified using JDK default
HostnameVerifier
. When false
, hostname verification won't be
performed unless custom HostnameVerifier
is set.SslEngineConfigurator
.setHostnameVerifier(HostnameVerifier)
public javax.net.ssl.HostnameVerifier getHostnameVerifier()
public SslEngineConfigurator setHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
When custom HostnameVerifier
instance is registered, it will be used to perform hostname verification,
no matter on the state of hostname verification flag (see isHostVerificationEnabled()
) and JDK default
hostname verifier won't be used.
hostnameVerifier
- custom hostname verifier.SslEngineConfigurator
.public javax.net.ssl.SSLContext getSslContext()
SSLContext
and store it for further invocation of this method.public java.lang.String toString()
toString
in class java.lang.Object
public SslEngineConfigurator copy()
Copyright © 2012–2020 Oracle Corporation. All rights reserved.