Package com.unboundid.ldap.listener
Class InMemoryListenerConfig
java.lang.Object
com.unboundid.ldap.listener.InMemoryListenerConfig
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class InMemoryListenerConfig
extends Object
This class provides a data structure that can be used to configure a
listener for use in the in-memory directory server. Each in-memory directory
server instance has the ability to have multiple listeners, and those
listeners may have different settings (e.g., listen on one port for
unencrypted LDAP communication with optional support for StartTLS, and listen
on a separate port for SSL-encrypted communication). If the server is to
provide support for SSL and/or StartTLS, then the
SSLUtil class can
make it easy to create the necessary socket factories.-
Constructor Summary
ConstructorsConstructorDescriptionInMemoryListenerConfig(String listenerName, InetAddress listenAddress, int listenPort, ServerSocketFactory serverSocketFactory, SocketFactory clientSocketFactory, SSLSocketFactory startTLSSocketFactory) Creates a new in-memory directory server listener configuration with the provided settings.InMemoryListenerConfig(String listenerName, InetAddress listenAddress, int listenPort, ServerSocketFactory serverSocketFactory, SocketFactory clientSocketFactory, SSLSocketFactory startTLSSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) Creates a new in-memory directory server listener configuration with the provided settings. -
Method Summary
Modifier and TypeMethodDescriptionstatic InMemoryListenerConfigcreateLDAPConfig(String listenerName) Creates a new listener configuration that will listen for unencrypted LDAP communication on an automatically-selected port on all available addresses.static InMemoryListenerConfigcreateLDAPConfig(String listenerName, int listenPort) Creates a new listener configuration that will listen for unencrypted LDAP communication on the specified port on all available addresses.static InMemoryListenerConfigcreateLDAPConfig(String listenerName, InetAddress listenAddress, int listenPort, SSLSocketFactory startTLSSocketFactory) Creates a new listener configuration that will listen for unencrypted LDAP communication, and may optionally support StartTLS.static InMemoryListenerConfigcreateLDAPConfig(String listenerName, InetAddress listenAddress, int listenPort, SSLSocketFactory startTLSSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) Creates a new listener configuration that will listen for unencrypted LDAP communication, and may optionally support StartTLS.static InMemoryListenerConfigcreateLDAPSConfig(String listenerName, int listenPort, SSLServerSocketFactory serverSocketFactory) Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on the specified port on all available addresses.static InMemoryListenerConfigcreateLDAPSConfig(String listenerName, InetAddress listenAddress, int listenPort, SSLServerSocketFactory serverSocketFactory, SSLSocketFactory clientSocketFactory) Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on an automatically-selected port on all available addresses.static InMemoryListenerConfigcreateLDAPSConfig(String listenerName, InetAddress listenAddress, int listenPort, SSLServerSocketFactory serverSocketFactory, SSLSocketFactory clientSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on an automatically-selected port on all available addresses.static InMemoryListenerConfigcreateLDAPSConfig(String listenerName, SSLServerSocketFactory serverSocketFactory) Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on an automatically-selected port on all available addresses.Retrieves the socket factory that should be used to create client connections to the server, if defined.Retrieves the address on which the listener should accept connections from clients, if defined.Retrieves the name for this listener configuration.intRetrieves the port on which the listener should accept connections from clients, if defined.Retrieves the socket factory that should be used to create sockets when accepting client connections, if defined.Retrieves the socket factory that should be used to add StartTLS encryption to existing connections, if defined.booleanIndicates whether the listener should request that the client present its own certificate chain during TLS negotiation.booleanIndicates 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.toString()Retrieves a string representation of this listener configuration.voidtoString(StringBuilder buffer) Appends a string representation of this listener configuration to the provided buffer.
-
Constructor Details
-
InMemoryListenerConfig
public InMemoryListenerConfig(@NotNull String listenerName, @Nullable InetAddress listenAddress, int listenPort, @Nullable ServerSocketFactory serverSocketFactory, @Nullable SocketFactory clientSocketFactory, @Nullable SSLSocketFactory startTLSSocketFactory) throws LDAPException Creates a new in-memory directory server listener configuration with the provided settings.- Parameters:
listenerName- The name to assign to this listener. It must not benulland must not be the same as the name for any other listener configured in the server.listenAddress- The address on which the listener should accept connections from clients. It may benullto indicate that it should accept connections on all addresses on all interfaces.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.serverSocketFactory- The socket factory that should be used to create sockets when accepting client connections. It may benullif the JVM-default server socket factory should be used.clientSocketFactory- The socket factory that should be used to create client connections to the server. It may benullif the JVM-default socket factory should be used.startTLSSocketFactory- The socket factory that should be used to add StartTLS encryption to existing connections. It may benullif StartTLS is not to be supported on this listener, and should benullif the server socket factory already provides some other form of communication security.- Throws:
LDAPException- If the provided listener name isnullor the configured listen port is out of range.
-
InMemoryListenerConfig
public InMemoryListenerConfig(@NotNull String listenerName, @Nullable InetAddress listenAddress, int listenPort, @Nullable ServerSocketFactory serverSocketFactory, @Nullable SocketFactory clientSocketFactory, @Nullable SSLSocketFactory startTLSSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) throws LDAPException Creates a new in-memory directory server listener configuration with the provided settings.- Parameters:
listenerName- The name to assign to this listener. It must not benulland must not be the same as the name for any other listener configured in the server.listenAddress- The address on which the listener should accept connections from clients. It may benullto indicate that it should accept connections on all addresses on all interfaces.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.serverSocketFactory- The socket factory that should be used to create sockets when accepting client connections. It may benullif the JVM-default server socket factory should be used.clientSocketFactory- The socket factory that should be used to create client connections to the server. It may benullif the JVM-default socket factory should be used.startTLSSocketFactory- The socket factory that should be used to add StartTLS encryption to existing connections. It may benullif StartTLS is not to be supported on this listener, and should benullif the server socket factory already provides some other form of communication security.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.requireClientCertificate- Indicates whether the listener should require that the client present its own certificate chain during TLS negotiation, and should fail negotiation if the client does not present one. This will be ignored for non-TLS-based connections or ifrequestClientCertificateisfalse.- Throws:
LDAPException- If the provided listener name isnullor the configured listen port is out of range.
-
-
Method Details
-
createLDAPConfig
@NotNull public static InMemoryListenerConfig createLDAPConfig(@NotNull String listenerName) throws LDAPException Creates a new listener configuration that will listen for unencrypted LDAP communication on an automatically-selected port on all available addresses. It will not support StartTLS.- Parameters:
listenerName- The name to use for the listener. It must not benull.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided name isnull.
-
createLDAPConfig
@NotNull public static InMemoryListenerConfig createLDAPConfig(@NotNull String listenerName, int listenPort) throws LDAPException Creates a new listener configuration that will listen for unencrypted LDAP communication on the specified port on all available addresses. It will not support StartTLS.- Parameters:
listenerName- The name to use for the listener. It must not benull.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided listener name isnullor the configured listen port is out of range.
-
createLDAPConfig
@NotNull public static InMemoryListenerConfig createLDAPConfig(@NotNull String listenerName, @Nullable InetAddress listenAddress, int listenPort, @Nullable SSLSocketFactory startTLSSocketFactory) throws LDAPException Creates a new listener configuration that will listen for unencrypted LDAP communication, and may optionally support StartTLS.- Parameters:
listenerName- The name to assign to this listener. It must not benulland must not be the same as the name for any other listener configured in the server.listenAddress- The address on which the listener should accept connections from clients. It may benullto indicate that it should accept connections on all addresses on all interfaces.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.startTLSSocketFactory- The socket factory that should be used to add StartTLS encryption to an existing connection. It may benullif StartTLS is not to be supported on this listener, and should benullif the server socket factory already provides some other form of communication security.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided listener name isnullor the configured listen port is out of range.
-
createLDAPConfig
@NotNull public static InMemoryListenerConfig createLDAPConfig(@NotNull String listenerName, @Nullable InetAddress listenAddress, int listenPort, @Nullable SSLSocketFactory startTLSSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) throws LDAPException Creates a new listener configuration that will listen for unencrypted LDAP communication, and may optionally support StartTLS.- Parameters:
listenerName- The name to assign to this listener. It must not benulland must not be the same as the name for any other listener configured in the server.listenAddress- The address on which the listener should accept connections from clients. It may benullto indicate that it should accept connections on all addresses on all interfaces.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.startTLSSocketFactory- The socket factory that should be used to add StartTLS encryption to an existing connection. It may benullif StartTLS is not to be supported on this listener, and should benullif the server socket factory already provides some other form of communication security.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.requireClientCertificate- Indicates whether the listener should require that the client present its own certificate chain during TLS negotiation, and should fail negotiation if the client does not present one. This will be ignored for non-TLS-based connections or ifrequestClientCertificateisfalse.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided listener name isnullor the configured listen port is out of range.
-
createLDAPSConfig
@NotNull public static InMemoryListenerConfig createLDAPSConfig(@NotNull String listenerName, @NotNull SSLServerSocketFactory serverSocketFactory) throws LDAPException Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on an automatically-selected port on all available addresses.- Parameters:
listenerName- The name to use for the listener. It must not benull.serverSocketFactory- The SSL server socket factory that will be used for accepting SSL-based connections from clients. It must not benull.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided name isnull.
-
createLDAPSConfig
@NotNull public static InMemoryListenerConfig createLDAPSConfig(@NotNull String listenerName, int listenPort, @NotNull SSLServerSocketFactory serverSocketFactory) throws LDAPException Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on the specified port on all available addresses.- Parameters:
listenerName- The name to use for the listener. It must not benull.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.serverSocketFactory- The SSL server socket factory that will be used for accepting SSL-based connections from clients. It must not benull.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided name isnull.
-
createLDAPSConfig
@NotNull public static InMemoryListenerConfig createLDAPSConfig(@NotNull String listenerName, @Nullable InetAddress listenAddress, int listenPort, @NotNull SSLServerSocketFactory serverSocketFactory, @Nullable SSLSocketFactory clientSocketFactory) throws LDAPException Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on an automatically-selected port on all available addresses.- Parameters:
listenerName- The name to use for the listener. It must not benull.listenAddress- The address on which the listener should accept connections from clients. It may benullto indicate that it should accept connections on all addresses on all interfaces.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.serverSocketFactory- The SSL server socket factory that will be used for accepting SSL-based connections from clients. It must not benull.clientSocketFactory- The SSL socket factory that will be used to create secure connections to the server. It may benullif a default "trust all" socket factory should be used.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided name or server socket factory isnull, or an error occurs while attempting to create a client socket factory.
-
createLDAPSConfig
@NotNull public static InMemoryListenerConfig createLDAPSConfig(@NotNull String listenerName, @Nullable InetAddress listenAddress, int listenPort, @NotNull SSLServerSocketFactory serverSocketFactory, @Nullable SSLSocketFactory clientSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) throws LDAPException Creates a new listener configuration that will listen for SSL-encrypted LDAP communication on an automatically-selected port on all available addresses.- Parameters:
listenerName- The name to use for the listener. It must not benull.listenAddress- The address on which the listener should accept connections from clients. It may benullto indicate that it should accept connections on all addresses on all interfaces.listenPort- The port on which the listener should accept connections from clients. It may be 0 to indicate that the server should automatically choose an available port.serverSocketFactory- The SSL server socket factory that will be used for accepting SSL-based connections from clients. It must not benull.clientSocketFactory- The SSL socket factory that will be used to create secure connections to the server. It may benullif a default "trust all" socket factory should be used.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.requireClientCertificate- Indicates whether the listener should require that the client present its own certificate chain during TLS negotiation, and should fail negotiation if the client does not present one. This will be ignored for non-TLS-based connections or ifrequestClientCertificateisfalse.- Returns:
- The newly-created listener configuration.
- Throws:
LDAPException- If the provided name or server socket factory isnull, or an error occurs while attempting to create a client socket factory.
-
getListenerName
Retrieves the name for this listener configuration.- Returns:
- The name for this listener configuration.
-
getListenAddress
Retrieves the address on which the listener should accept connections from clients, if defined.- Returns:
- The address on which the listener should accept connections from
clients, or
nullif it should accept connections on all addresses on all interfaces.
-
getListenPort
Retrieves the port on which the listener should accept connections from clients, if defined.- Returns:
- The port on which the listener should accept connections from clients, or 0 if the listener should automatically select an available port.
-
getServerSocketFactory
Retrieves the socket factory that should be used to create sockets when accepting client connections, if defined.- Returns:
- The socket factory that should be used to create sockets when
accepting client connections, or
nullif the JVM-default server socket factory should be used.
-
getClientSocketFactory
Retrieves the socket factory that should be used to create client connections to the server, if defined.- Returns:
- The socket factory that should be used to create client
connections to the server, or
nullif the JVM-default socket factory should be used.
-
getStartTLSSocketFactory
Retrieves the socket factory that should be used to add StartTLS encryption to existing connections, if defined.- Returns:
- The socket factory that should be used to add StartTLS encryption
to existing connections, or
nullif StartTLS should not be supported.
-
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:
trueif the listener should request that the client present its own certificate chain during TLS negotiation, orfalseif not.
-
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 ifrequestClientCertificatereturns false.- Returns:
trueif the listener should require that the client present its own certificate chain during TLS negotiation, orfalseif TLS negotiation should continue even if the client did not present a certificate chain when requested.
-
toString
Retrieves a string representation of this listener configuration. -
toString
Appends a string representation of this listener configuration to the provided buffer.- Parameters:
buffer- The buffer to which the information should be appended.
-