public final class LDAPOptions extends Object
For example you set LDAP options when you want to use StartTLS.
LDAPOptions options = new LDAPOptions();
SSLContext sslContext =
new SSLContextBuilder().setTrustManager(...).getSSLContext();
options.setSSLContext(sslContext);
options.setUseStartTLS(true);
String host = ...;
int port = ...;
LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port, options);
Connection connection = factory.getConnection();
// Connection uses StartTLS...
| Constructor and Description |
|---|
LDAPOptions()
Creates a new set of connection options with default settings.
|
LDAPOptions(LDAPOptions options)
Creates a new set of connection options having the same initial set of
options as the provided set of connection options.
|
| Modifier and Type | Method and Description |
|---|---|
LDAPOptions |
addEnabledCipherSuite(String... suites)
Adds the cipher suites enabled for secure connections with the Directory
Server.
|
LDAPOptions |
addEnabledProtocol(String... protocols)
Adds the protocol versions enabled for secure connections with the
Directory Server.
|
long |
getConnectTimeout(TimeUnit unit)
Returns the connect timeout in the specified unit.
|
DecodeOptions |
getDecodeOptions()
Returns the decoding options which will be used to control how requests
and responses are decoded.
|
List<String> |
getEnabledCipherSuites()
Returns the names of the protocol versions which are currently enabled
for secure connections with the Directory Server.
|
List<String> |
getEnabledProtocols()
Returns the names of the protocol versions which are currently enabled
for secure connections with the Directory Server.
|
int |
getLinger()
Returns the value of the
SO_LINGER socket option for new connections. |
ClassLoader |
getProviderClassLoader()
Returns the class loader which will be used to load the
TransportProvider. |
SSLContext |
getSSLContext()
Returns the SSL context which will be used when initiating connections
with the Directory Server.
|
long |
getTimeout(TimeUnit unit)
Returns the operation timeout in the specified unit.
|
String |
getTransportProvider()
Returns the name of the provider used for transport.
|
boolean |
isKeepAlive()
Returns the value of the
SO_KEEPALIVE socket option for new connections. |
boolean |
isReuseAddress()
Returns the value of the
SO_REUSEADDR socket option for new connections. |
boolean |
isTCPNoDelay()
Returns the value of the
TCP_NODELAY socket option for new connections. |
LDAPOptions |
setConnectTimeout(long timeout,
TimeUnit unit)
Sets the connect timeout.
|
T |
setDecodeOptions(DecodeOptions decodeOptions)
Sets the decoding options which will be used to control how requests and
responses are decoded.
|
T |
setKeepAlive(boolean keepAlive)
Specifies the value of the
SO_KEEPALIVE socket option for new connections. |
T |
setLinger(int linger)
Specifies the value of the
SO_LINGER socket option for new connections. |
T |
setProviderClassLoader(ClassLoader classLoader)
Sets the class loader which will be used to load the
TransportProvider. |
T |
setReuseAddress(boolean reuseAddress)
Specifies the value of the
SO_REUSEADDR socket option for new connections. |
LDAPOptions |
setSSLContext(SSLContext sslContext)
Sets the SSL context which will be used when initiating connections with
the Directory Server.
|
T |
setTCPNoDelay(boolean tcpNoDelay)
Specifies the value of the
TCP_NODELAY socket option for new connections. |
LDAPOptions |
setTimeout(long timeout,
TimeUnit unit)
Sets the operation timeout.
|
T |
setTransportProvider(String providerName)
Sets the name of the provider to use for transport.
|
LDAPOptions |
setUseStartTLS(boolean useStartTLS)
Specifies whether or not SSL or StartTLS should be used for securing
connections when an SSL context is specified.
|
boolean |
useStartTLS()
Indicates whether or not SSL or StartTLS should be used for securing
connections when an SSL context is specified.
|
public LDAPOptions()
public LDAPOptions(LDAPOptions options)
options - The set of connection options to be copied.public LDAPOptions addEnabledCipherSuite(String... suites)
The suites must be supported by the SSLContext specified in
setSSLContext(SSLContext). Following a successful call to this
method, only the suites listed in the protocols parameter are enabled for
use.
suites - Names of all the suites to enable.public LDAPOptions addEnabledProtocol(String... protocols)
The protocols must be supported by the SSLContext specified in
setSSLContext(SSLContext). Following a successful call to this
method, only the protocols listed in the protocols parameter are enabled
for use.
protocols - Names of all the protocols to enable.public long getConnectTimeout(TimeUnit unit)
TimeoutResultException error result will be returned. A timeout
setting of 0 causes the OS connect timeout to be used.
The default operation timeout is 10 seconds and may be configured using
the org.forgerock.opendj.io.connectTimeout property.
unit - The time unit.public List<String> getEnabledCipherSuites()
public List<String> getEnabledProtocols()
public SSLContext getSSLContext()
By default no SSL context will be used, indicating that connections will
not be secured. If a non-null SSL context is returned then
connections will be secured using either SSL or StartTLS depending on
useStartTLS().
null
indicating that connections will not be secured.public long getTimeout(TimeUnit unit)
TimeoutResultException error
result returned. A timeout setting of 0 disables operation timeout
limits.
The default operation timeout is 0 (no timeout) and may be configured
using the org.forgerock.opendj.io.timeout property.
unit - The time unit.public LDAPOptions setConnectTimeout(long timeout, TimeUnit unit)
TimeoutResultException error result will
be returned. A timeout setting of 0 causes the OS connect timeout to be
used.
The default operation timeout is 10 seconds and may be configured using
the org.forgerock.opendj.io.connectTimeout property.
timeout - The connect timeout, which may be 0 if there is no connect
timeout.unit - The time unit.public LDAPOptions setSSLContext(SSLContext sslContext)
By default no SSL context will be used, indicating that connections will
not be secured. If a non-null SSL context is returned then
connections will be secured using either SSL or StartTLS depending on
useStartTLS().
sslContext - The SSL context which will be used when initiating secure
connections with the Directory Server, which may be
null indicating that connections will not be secured.public LDAPOptions setTimeout(long timeout, TimeUnit unit)
TimeoutResultException error result returned. A
timeout setting of 0 disables operation timeout limits.
The default operation timeout is 0 (no timeout) and may be configured
using the org.forgerock.opendj.io.timeout property.
timeout - The operation timeout, which may be 0 if there is no operation
timeout.unit - The time unit.public LDAPOptions setUseStartTLS(boolean useStartTLS)
By default SSL will be used in preference to StartTLS.
useStartTLS - true if StartTLS should be used for securing
connections when an SSL context is specified, otherwise
false indicating that SSL should be used.public boolean useStartTLS()
By default SSL will be used in preference to StartTLS.
true if StartTLS should be used for securing connections
when an SSL context is specified, otherwise false
indicating that SSL should be used.public DecodeOptions getDecodeOptions()
null).public int getLinger()
SO_LINGER socket option for new connections.
The default setting is -1 (disabled) and may be configured using
the org.forgerock.opendj.io.linger property.
SO_LINGER socket option for new connections, or -1 if linger
should be disabled.public ClassLoader getProviderClassLoader()
TransportProvider.
By default this method will return null indicating that the
default class loader will be used.
The transport provider is loaded using java.util.ServiceLoader,
the JDK service-provider loading facility. The provider must be
accessible from the same class loader that was initially queried to
locate the configuration file; note that this is not necessarily the
class loader from which the file was actually loaded. This method allows
to provide a class loader to be used for loading the provider.
null if the default class loader should be
used.public String getTransportProvider()
Transport providers implement TransportProvider interface.
The name should correspond to the name of an existing provider, as
returned by TransportProvider#getName() method.
null if no
specific provider has been selected. In that case, the first
provider found will be used.public boolean isKeepAlive()
SO_KEEPALIVE socket option for new connections.
The default setting is true and may be configured using the
org.forgerock.opendj.io.keepAlive property.
SO_KEEPALIVE socket option for new connections.public boolean isReuseAddress()
SO_REUSEADDR socket option for new connections.
The default setting is true and may be configured using the
org.forgerock.opendj.io.reuseAddress property.
SO_REUSEADDR socket option for new connections.public boolean isTCPNoDelay()
TCP_NODELAY socket option for new connections.
The default setting is true and may be configured using the
org.forgerock.opendj.io.tcpNoDelay property.
TCP_NODELAY socket option for new connections.public T setDecodeOptions(DecodeOptions decodeOptions)
decodeOptions - The decoding options which will be used to control how
requests and responses are decoded (never null).NullPointerException - If decodeOptions was null.public T setKeepAlive(boolean keepAlive)
SO_KEEPALIVE socket option for new connections.
The default setting is true and may be configured using the
org.forgerock.opendj.io.keepAlive property.
keepAlive - The value of the SO_KEEPALIVE socket option for new connections.public T setLinger(int linger)
SO_LINGER socket option for new connections.
The default setting is -1 (disabled) and may be configured using
the org.forgerock.opendj.io.linger property.
linger - The value of the SO_LINGER socket option for new connections, or -1 if linger
should be disabled.public T setProviderClassLoader(ClassLoader classLoader)
TransportProvider.
The default class loader will be used if no class loader is set using this method.
The transport provider is loaded using java.util.ServiceLoader,
the JDK service-provider loading facility. The provider must be
accessible from the same class loader that was initially queried to
locate the configuration file; note that this is not necessarily the
class loader from which the file was actually loaded. This method allows
to provide a class loader to be used for loading the provider.
classLoader - The class loader which will be used when loading the transport
provider, or null if the default class loader should
be used.public T setReuseAddress(boolean reuseAddress)
SO_REUSEADDR socket option for new connections.
The default setting is true and may be configured using the
org.forgerock.opendj.io.reuseAddress property.
reuseAddress - The value of the SO_REUSEADDR socket option for new connections.public T setTCPNoDelay(boolean tcpNoDelay)
TCP_NODELAY socket option for new connections.
The default setting is true and may be configured using the
org.forgerock.opendj.io.tcpNoDelay property.
tcpNoDelay - The value of the TCP_NODELAY socket option for new connections.public T setTransportProvider(String providerName)
Transport providers implement TransportProvider interface.
The name should correspond to the name of an existing provider, as
returned by TransportProvider#getName() method.
providerName - The name of transport provider, or null if no specific
provider is preferred. In that case, the first provider found
will be used.Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.