Package org.ldaptive.ssl
Class SslConfig
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.AbstractConfig
-
- org.ldaptive.ssl.SslConfig
-
- All Implemented Interfaces:
Freezable
public final class SslConfig extends AbstractConfig
Contains all the configuration data for SSL and startTLS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SslConfig.Builder
-
Field Summary
Fields Modifier and Type Field Description private CredentialConfig
credentialConfig
Configuration for the trust and authentication material to use for SSL and startTLS.private String[]
enabledCipherSuites
Enabled cipher suites.private String[]
enabledProtocols
Enabled protocol versions.private HandshakeCompletedListener[]
handshakeCompletedListeners
Handshake completed listeners.private Duration
handshakeTimeout
Duration of time that handshakes will block.private CertificateHostnameVerifier
hostnameVerifier
Certificate hostname verifier.private TrustManager[]
trustManagers
Trust managers.-
Fields inherited from class org.ldaptive.AbstractConfig
logger
-
-
Constructor Summary
Constructors Constructor Description SslConfig()
Default constructor.SslConfig(TrustManager... managers)
Creates a new ssl config.SslConfig(CredentialConfig config)
Creates a new ssl config.SslConfig(CredentialConfig config, TrustManager... managers)
Creates a new ssl config.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SslConfig.Builder
builder()
Creates a builder for this class.static SslConfig
copy(SslConfig config)
Returns a ssl config initialized with the supplied config.SSLContextInitializer
createSSLContextInitializer()
Creates anSSLContextInitializer
from this configuration.void
freeze()
Freezes this object, making it immutable.CredentialConfig
getCredentialConfig()
Returns the credential config.String[]
getEnabledCipherSuites()
Returns the names of the SSL cipher suites to use for secure connections.String[]
getEnabledProtocols()
Returns the names of the SSL protocols to use for secure connections.HandshakeCompletedListener[]
getHandshakeCompletedListeners()
Returns the handshake completed listeners to use for secure connections.Duration
getHandshakeTimeout()
Returns the handshake timeout.CertificateHostnameVerifier
getHostnameVerifier()
Returns the hostname verifier.TrustManager[]
getTrustManagers()
Returns the trust managers.boolean
isEmpty()
Returns whether this ssl config contains any configuration data.void
setCredentialConfig(CredentialConfig config)
Sets the credential config.void
setEnabledCipherSuites(String... suites)
Sets the SSL cipher suites to use for secure connections.void
setEnabledProtocols(String... protocols)
Sets the SSL protocol versions to use for secure connections.void
setHandshakeCompletedListeners(HandshakeCompletedListener... listeners)
Sets the handshake completed listeners to use for secure connections.void
setHandshakeTimeout(Duration time)
Sets the maximum amount of time that handshakes will block.void
setHostnameVerifier(CertificateHostnameVerifier verifier)
Sets the hostname verifier.void
setTrustManagers(TrustManager... managers)
Sets the trust managers.String
toString()
-
Methods inherited from class org.ldaptive.AbstractConfig
checkArrayContainsNull, checkStringInput
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
credentialConfig
private CredentialConfig credentialConfig
Configuration for the trust and authentication material to use for SSL and startTLS.
-
trustManagers
private TrustManager[] trustManagers
Trust managers.
-
hostnameVerifier
private CertificateHostnameVerifier hostnameVerifier
Certificate hostname verifier.
-
enabledCipherSuites
private String[] enabledCipherSuites
Enabled cipher suites.
-
enabledProtocols
private String[] enabledProtocols
Enabled protocol versions.
-
handshakeCompletedListeners
private HandshakeCompletedListener[] handshakeCompletedListeners
Handshake completed listeners.
-
handshakeTimeout
private Duration handshakeTimeout
Duration of time that handshakes will block.
-
-
Constructor Detail
-
SslConfig
public SslConfig()
Default constructor.
-
SslConfig
public SslConfig(CredentialConfig config)
Creates a new ssl config.- Parameters:
config
- credential config
-
SslConfig
public SslConfig(TrustManager... managers)
Creates a new ssl config.- Parameters:
managers
- trust managers
-
SslConfig
public SslConfig(CredentialConfig config, TrustManager... managers)
Creates a new ssl config.- Parameters:
config
- credential configmanagers
- trust managers
-
-
Method Detail
-
freeze
public void freeze()
Description copied from interface:Freezable
Freezes this object, making it immutable.- Specified by:
freeze
in interfaceFreezable
- Overrides:
freeze
in classAbstractFreezable
-
isEmpty
public boolean isEmpty()
Returns whether this ssl config contains any configuration data.- Returns:
- whether all properties are null
-
getCredentialConfig
public CredentialConfig getCredentialConfig()
Returns the credential config.- Returns:
- credential config
-
setCredentialConfig
public void setCredentialConfig(CredentialConfig config)
Sets the credential config.- Parameters:
config
- credential config
-
getTrustManagers
public TrustManager[] getTrustManagers()
Returns the trust managers.- Returns:
- trust managers
-
setTrustManagers
public void setTrustManagers(TrustManager... managers)
Sets the trust managers.- Parameters:
managers
- trust managers
-
getHostnameVerifier
public CertificateHostnameVerifier getHostnameVerifier()
Returns the hostname verifier.- Returns:
- hostname verifier
-
setHostnameVerifier
public void setHostnameVerifier(CertificateHostnameVerifier verifier)
Sets the hostname verifier.- Parameters:
verifier
- hostname verifier
-
getEnabledCipherSuites
public String[] getEnabledCipherSuites()
Returns the names of the SSL cipher suites to use for secure connections.- Returns:
- cipher suites
-
setEnabledCipherSuites
public void setEnabledCipherSuites(String... suites)
Sets the SSL cipher suites to use for secure connections.- Parameters:
suites
- cipher suites
-
getEnabledProtocols
public String[] getEnabledProtocols()
Returns the names of the SSL protocols to use for secure connections.- Returns:
- enabled protocols
-
setEnabledProtocols
public void setEnabledProtocols(String... protocols)
Sets the SSL protocol versions to use for secure connections.- Parameters:
protocols
- enabled protocols
-
getHandshakeCompletedListeners
public HandshakeCompletedListener[] getHandshakeCompletedListeners()
Returns the handshake completed listeners to use for secure connections.- Returns:
- handshake completed listeners
-
setHandshakeCompletedListeners
public void setHandshakeCompletedListeners(HandshakeCompletedListener... listeners)
Sets the handshake completed listeners to use for secure connections.- Parameters:
listeners
- for SSL handshake events
-
getHandshakeTimeout
public Duration getHandshakeTimeout()
Returns the handshake timeout.- Returns:
- timeout
-
setHandshakeTimeout
public void setHandshakeTimeout(Duration time)
Sets the maximum amount of time that handshakes will block.- Parameters:
time
- timeout for handshakes
-
copy
public static SslConfig copy(SslConfig config)
Returns a ssl config initialized with the supplied config.- Parameters:
config
- ssl config to read properties from- Returns:
- ssl config
-
createSSLContextInitializer
public SSLContextInitializer createSSLContextInitializer() throws GeneralSecurityException
Creates anSSLContextInitializer
from this configuration. If aCredentialConfig
is provided it is used, otherwise aDefaultSSLContextInitializer
is created.- Returns:
- SSL context initializer
- Throws:
GeneralSecurityException
- if the SSL context initializer cannot be created
-
builder
public static SslConfig.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-