Package com.unboundid.ldap.listener
Class LDAPListenerConfig
- java.lang.Object
-
- com.unboundid.ldap.listener.LDAPListenerConfig
-
@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class LDAPListenerConfig extends java.lang.Object
This class provides a mechanism for defining the configuration to use for anLDAPListener
instance. Note that while instances of this class are not inherently threadsafe, a private copy of the configuration will be created whenever a newLDAPListener
is created so that this configuration may continue to be altered for new instances without impacting any existing listeners.
-
-
Constructor Summary
Constructors Constructor Description LDAPListenerConfig(int listenPort, LDAPListenerRequestHandler requestHandler)
Creates a new listener configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LDAPListenerConfig
duplicate()
Creates a copy of this configuration that may be altered without impacting this configuration, and which will not be altered by changes to this configuration.LDAPListenerExceptionHandler
getExceptionHandler()
Retrieves the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.int
getLingerTimeoutSeconds()
Retrieves the timeout in seconds that should be used if the SO_LINGER socket option is enabled.java.net.InetAddress
getListenAddress()
Retrieves the address on which to listen for client connections, if defined.int
getListenPort()
Retrieves the port number on which to listen for client connections.int
getMaxConnections()
Retrieves the maximum number of concurrent connections that the listener will allow.int
getMaxMessageSizeBytes()
Retrieves the maximum size in bytes for LDAP messages that will be accepted by this listener.int
getReceiveBufferSize()
Retrieves the receive buffer size that should be used for sockets accepted by the listener.LDAPListenerRequestHandler
getRequestHandler()
Retrieves the LDAP listener request handler that should be used to process requests read from clients.int
getSendBufferSize()
Retrieves the send buffer size that should be used for sockets accepted by the listener.javax.net.ServerSocketFactory
getServerSocketFactory()
Retrieves the factory that will be used to create the server socket that will listen for client connections.boolean
requestClientCertificate()
Indicates whether the listener should request that the client present its own certificate chain during TLS negotiation.boolean
requireClientCertificate()
Indicates whether the listener should require that the client present its own certificate chain during TLS negotiation and should fail negotiation if no certificate chain was provided.void
setExceptionHandler(LDAPListenerExceptionHandler exceptionHandler)
Specifies the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.void
setLingerTimeoutSeconds(int lingerTimeout)
Specifies the timeout in seconds that should be used if the SO_LINGER socket option is enabled.void
setListenAddress(java.net.InetAddress listenAddress)
Specifies the address on which to listen for client connections.void
setListenPort(int listenPort)
Specifies the port number on which to listen for client connections.void
setMaxConnections(int maxConnections)
Specifies the maximum number of concurrent connections that the listener will allow.void
setMaxMessageSizeBytes(int maxMessageSizeBytes)
Specifies the maximum size in bytes for LDAP messages that will be accepted by this listener.void
setReceiveBufferSize(int receiveBufferSize)
Specifies the receive buffer size that should be used for sockets accepted by the listener.void
setRequestClientCertificate(boolean requestClientCertificate)
Specifies whether the listener should request that the client present its own certificate chain during TLS negotiation.void
setRequestHandler(LDAPListenerRequestHandler requestHandler)
Specifies the LDAP listener request handler that should be used to process requests read from clients.void
setRequireClientCertificate(boolean requireClientCertificate)
Specifies whether the listener should require that the client present its own certificate chain during TLS negotiation and should fail negotiation if no certificate chain was provided.void
setSendBufferSize(int sendBufferSize)
Specifies the send buffer size that should be used for sockets accepted by the listener.void
setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
Specifies the factory that will be used to create the server socket that will listen for client connections.void
setUseKeepAlive(boolean useKeepAlive)
Specifies whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.void
setUseLinger(boolean useLinger)
Specifies whether to use the SO_LINGER socket option for sockets accepted by the listener.void
setUseReuseAddress(boolean useReuseAddress)
Specifies whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.void
setUseTCPNoDelay(boolean useTCPNoDelay)
Specifies whether to use the TCP_NODELAY socket option for sockets accepted by the listener.java.lang.String
toString()
Retrieves a string representation of this LDAP listener config.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP listener config to the provided buffer.boolean
useKeepAlive()
Indicates whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.boolean
useLinger()
Indicates whether to use the SO_LINGER socket option for sockets accepted by the listener.boolean
useReuseAddress()
Indicates whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.boolean
useTCPNoDelay()
Indicates whether to use the TCP_NODELAY socket option for sockets accepted by the listener.
-
-
-
Constructor Detail
-
LDAPListenerConfig
public LDAPListenerConfig(int listenPort, @NotNull LDAPListenerRequestHandler requestHandler)
Creates a new listener configuration.- Parameters:
listenPort
- The port on which to listen for client connections. It must be an integer between 1 and 65535, or 0 to indicate that a free port should be chosen by the JVM.requestHandler
- The request handler that will be used to process requests read from clients. It must not benull
.
-
-
Method Detail
-
getListenPort
public int getListenPort()
Retrieves the port number on which to listen for client connections. A value of zero indicates that the listener should allow the JVM to choose a free port.- Returns:
- The port number on which to listen for client connections.
-
setListenPort
public void setListenPort(int listenPort)
Specifies the port number on which to listen for client connections. The provided value must be between 1 and 65535, or it may be 0 to indicate that the JVM should select a free port on the system.- Parameters:
listenPort
- The port number on which to listen for client connections.
-
getRequestHandler
@NotNull public LDAPListenerRequestHandler getRequestHandler()
Retrieves the LDAP listener request handler that should be used to process requests read from clients.- Returns:
- The LDAP listener request handler that should be used to process requests read from clients.
-
setRequestHandler
public void setRequestHandler(@NotNull LDAPListenerRequestHandler requestHandler)
Specifies the LDAP listener request handler that should be used to process requests read from clients.- Parameters:
requestHandler
- The LDAP listener request handler that should be used to process requests read from clients. It must not benull
.
-
useKeepAlive
public boolean useKeepAlive()
Indicates whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.- Returns:
true
if the SO_KEEPALIVE socket option should be used for sockets accepted by the listener, orfalse
if not.
-
setUseKeepAlive
public void setUseKeepAlive(boolean useKeepAlive)
Specifies whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.- Parameters:
useKeepAlive
- Indicates whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.
-
useLinger
public boolean useLinger()
Indicates whether to use the SO_LINGER socket option for sockets accepted by the listener.- Returns:
true
if the SO_LINGER socket option should be used for sockets accepted by the listener, orfalse
if not.
-
setUseLinger
public void setUseLinger(boolean useLinger)
Specifies whether to use the SO_LINGER socket option for sockets accepted by the listener.- Parameters:
useLinger
- Indicates whether to use the SO_LINGER socket option for sockets accepted by the listener.
-
useReuseAddress
public boolean useReuseAddress()
Indicates whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.- Returns:
true
if the SO_REUSEADDR socket option should be used for sockets accepted by the listener, orfalse
if not.
-
setUseReuseAddress
public void setUseReuseAddress(boolean useReuseAddress)
Specifies whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.- Parameters:
useReuseAddress
- Indicates whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.
-
useTCPNoDelay
public boolean useTCPNoDelay()
Indicates whether to use the TCP_NODELAY socket option for sockets accepted by the listener.- Returns:
true
if the TCP_NODELAY socket option should be used for sockets accepted by the listener, orfalse
if not.
-
setUseTCPNoDelay
public void setUseTCPNoDelay(boolean useTCPNoDelay)
Specifies whether to use the TCP_NODELAY socket option for sockets accepted by the listener.- Parameters:
useTCPNoDelay
- Indicates whether to use the TCP_NODELAY socket option for sockets accepted by the listener.
-
getListenAddress
@Nullable public java.net.InetAddress getListenAddress()
Retrieves the address on which to listen for client connections, if defined.- Returns:
- The address on which to listen for client connections, or
null
if it should listen on all available addresses on all interfaces.
-
setListenAddress
public void setListenAddress(@Nullable java.net.InetAddress listenAddress)
Specifies the address on which to listen for client connections.- Parameters:
listenAddress
- The address on which to listen for client connections. It may benull
to indicate that it should listen on all available addresses on all interfaces.
-
getLingerTimeoutSeconds
public int getLingerTimeoutSeconds()
Retrieves the timeout in seconds that should be used if the SO_LINGER socket option is enabled.- Returns:
- The timeout in seconds that should be used if the SO_LINGER socket option is enabled.
-
setLingerTimeoutSeconds
public void setLingerTimeoutSeconds(int lingerTimeout)
Specifies the timeout in seconds that should be used if the SO_LINGER socket option is enabled.- Parameters:
lingerTimeout
- The timeout in seconds that should be used if the SO_LINGER socket option is enabled. The value must be between 0 and 65535, inclusive.
-
getMaxConnections
public int getMaxConnections()
Retrieves the maximum number of concurrent connections that the listener will allow. If a client tries to establish a new connection while the listener already has the maximum number of concurrent connections, then the new connection will be rejected.- Returns:
- The maximum number of concurrent connections that the listener will allow, or zero if no limit should be enforced.
-
setMaxConnections
public void setMaxConnections(int maxConnections)
Specifies the maximum number of concurrent connections that the listener will allow. If a client tries to establish a new connection while the listener already has the maximum number of concurrent connections, then the new connection will be rejected.- Parameters:
maxConnections
- The maximum number of concurrent connections that the listener will allow. A value that is less than or equal to zero indicates no limit.
-
getMaxMessageSizeBytes
public int getMaxMessageSizeBytes()
Retrieves the maximum size in bytes for LDAP messages that will be accepted by this listener.- Returns:
- The maximum size in bytes for LDAP messages that will be accepted by this listener.
-
setMaxMessageSizeBytes
public void setMaxMessageSizeBytes(int maxMessageSizeBytes)
Specifies the maximum size in bytes for LDAP messages that will be accepted by this listener.- Parameters:
maxMessageSizeBytes
- The maximum size in bytes for LDAP messages that will be accepted by this listener. A value that is less than or equal to zero will use the maximum allowed message size.
-
getReceiveBufferSize
public int getReceiveBufferSize()
Retrieves the receive buffer size that should be used for sockets accepted by the listener.- Returns:
- The receive buffer size that should be used for sockets accepted by the listener, or 0 if the default receive buffer size should be used.
-
setReceiveBufferSize
public void setReceiveBufferSize(int receiveBufferSize)
Specifies the receive buffer size that should be used for sockets accepted by the listener. A value less than or equal to zero indicates that the default receive buffer size should be used.- Parameters:
receiveBufferSize
- The receive buffer size that should be used for sockets accepted by the listener.
-
getSendBufferSize
public int getSendBufferSize()
Retrieves the send buffer size that should be used for sockets accepted by the listener.- Returns:
- The send buffer size that should be used for sockets accepted by the listener, or 0 if the default send buffer size should be used.
-
setSendBufferSize
public void setSendBufferSize(int sendBufferSize)
Specifies the send buffer size that should be used for sockets accepted by the listener. A value less than or equal to zero indicates that the default send buffer size should be used.- Parameters:
sendBufferSize
- The send buffer size that should be used for sockets accepted by the listener.
-
getExceptionHandler
@Nullable public LDAPListenerExceptionHandler getExceptionHandler()
Retrieves the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.- Returns:
- The exception handler that should be notified of any exceptions
caught while attempting to accept or interact with a client
connection, or
null
if none is defined.
-
setExceptionHandler
public void setExceptionHandler(@Nullable LDAPListenerExceptionHandler exceptionHandler)
Specifies the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.- Parameters:
exceptionHandler
- The exception handler that should be notified of any exceptions encountered during processing. It may benull
if no exception handler should be used.
-
getServerSocketFactory
@NotNull public javax.net.ServerSocketFactory getServerSocketFactory()
Retrieves the factory that will be used to create the server socket that will listen for client connections.- Returns:
- The factory that will be used to create the server socket that will listen for client connections.
-
setServerSocketFactory
public void setServerSocketFactory(@Nullable javax.net.ServerSocketFactory serverSocketFactory)
Specifies the factory that will be used to create the server socket that will listen for client connections.- Parameters:
serverSocketFactory
- The factory that will be used to create the server socket that will listen for client connections. It may benull
to use the JVM-default server socket factory.
-
requestClientCertificate
public boolean requestClientCertificate()
Indicates whether the listener should request that the client present its own certificate chain during TLS negotiation. This will be ignored for non-TLS-based connections.- Returns:
true
if the listener should request that the client present its own certificate chain during TLS negotiation, orfalse
if not.
-
setRequestClientCertificate
public void setRequestClientCertificate(boolean requestClientCertificate)
Specifies whether the listener should request that the client present its own certificate chain during TLS negotiation. This will be ignored for non-TLS-based connections.- Parameters:
requestClientCertificate
- Indicates whether the listener should request that the client present its own certificate chain during TLS negotiation.
-
requireClientCertificate
public boolean requireClientCertificate()
Indicates whether the listener should require that the client present its own certificate chain during TLS negotiation and should fail negotiation if no certificate chain was provided. This will be ignored for non-TLS-based connections, and it will also be ignored ifrequestClientCertificate
returns false.- Returns:
true
if the listener should require that the client present its own certificate chain during TLS negotiation, orfalse
if TLS negotiation should continue even if the client did not present a certificate chain when requested.
-
setRequireClientCertificate
public void setRequireClientCertificate(boolean requireClientCertificate)
Specifies whether the listener should require that the client present its own certificate chain during TLS negotiation and should fail negotiation if no certificate chain was provided. This will be ignored for non-TLS-based connections, and it will also be ignored ifrequestClientCertificate
returns false.- Parameters:
requireClientCertificate
- Indicates whether the listener should require that the client present its own certificate chain during TLS negotiation.
-
duplicate
@NotNull public LDAPListenerConfig duplicate()
Creates a copy of this configuration that may be altered without impacting this configuration, and which will not be altered by changes to this configuration.- Returns:
- A copy of this configuration that may be altered without impacting this configuration, and which will not be altered by changes to this configuration.
-
toString
@NotNull public java.lang.String toString()
Retrieves a string representation of this LDAP listener config.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this LDAP listener config.
-
-