public final class LDAPListener extends Object implements Closeable
ServerConnection
created using the provided ServerConnectionFactory.
When processing requests, ServerConnection implementations are passed
an integer as the first parameter. This integer represents the
requestID associated with the client request and corresponds to the
requestID passed as a parameter to abandon and cancel extended
requests. The request ID may also be useful for logging purposes.
An LDAPListener does not require ServerConnection
implementations to return a result when processing requests. More
specifically, an LDAPListener does not maintain any internal state
information associated with each request which must be released. This is
useful when implementing LDAP abandon operations which may prevent results
being sent for abandoned operations.
The following code illustrates how to create a simple LDAP server:
class MyClientConnection implements ServerConnection<Integer> {
private final LDAPClientContext clientContext;
private MyClientConnection(LDAPClientContext clientContext) {
this.clientContext = clientContext;
}
public void add(Integer requestID, AddRequest request, ResultHandler<Result> handler,
IntermediateResponseHandler intermediateResponseHandler)
throws UnsupportedOperationException {
// ...
}
// ...
}
class MyServer implements ServerConnectionFactory<LDAPClientContext, RequestContext> {
public ServerConnection<RequestContext> accept(LDAPClientContext context) {
System.out.println("Connection from: " + context.getPeerAddress());
return new MyClientConnection(context);
}
}
public static void main(String[] args) throws Exception {
LDAPListener listener = new LDAPListener(1389, new MyServer());
// ...
listener.close();
}
| Constructor and Description |
|---|
LDAPListener(InetSocketAddress address,
ServerConnectionFactory<LDAPClientContext,Integer> factory)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(InetSocketAddress address,
ServerConnectionFactory<LDAPClientContext,Integer> factory,
LDAPListenerOptions options)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory,
LDAPListenerOptions options)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(String host,
int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(String host,
int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory,
LDAPListenerOptions options)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this LDAP connection listener.
|
InetAddress |
getAddress()
Returns the
InetAddress that this LDAP listener is listening on. |
String |
getHostName()
Returns the host name that this LDAP listener is listening on.
|
int |
getPort()
Returns the port that this LDAP listener is listening on.
|
String |
getProviderName()
Returns the name of the transport provider, which provides the implementation
of this factory.
|
InetSocketAddress |
getSocketAddress()
Returns the address that this LDAP listener is listening on.
|
String |
toString() |
public LDAPListener(int port, ServerConnectionFactory<LDAPClientContext,Integer> factory) throws IOException
port - The port to listen on.factory - The server connection factory which will be used to create
server connections.IOException - If an error occurred while trying to listen on the provided
address.NullPointerException - If {code factory} was null.public LDAPListener(int port, ServerConnectionFactory<LDAPClientContext,Integer> factory, LDAPListenerOptions options) throws IOException
port - The port to listen on.factory - The server connection factory which will be used to create
server connections.options - The LDAP listener options.IOException - If an error occurred while trying to listen on the provided
address.NullPointerException - If {code factory} or options was null.public LDAPListener(InetSocketAddress address, ServerConnectionFactory<LDAPClientContext,Integer> factory) throws IOException
address - The address to listen on.factory - The server connection factory which will be used to create
server connections.IOException - If an error occurred while trying to listen on the provided
address.NullPointerException - If address or {code factory} was null.public LDAPListener(InetSocketAddress address, ServerConnectionFactory<LDAPClientContext,Integer> factory, LDAPListenerOptions options) throws IOException
address - The address to listen on.factory - The server connection factory which will be used to create
server connections.options - The LDAP listener options.IOException - If an error occurred while trying to listen on the provided
address.NullPointerException - If address, {code factory}, or options was
null.public LDAPListener(String host, int port, ServerConnectionFactory<LDAPClientContext,Integer> factory) throws IOException
host - The address to listen on.port - The port to listen on.factory - The server connection factory which will be used to create
server connections.IOException - If an error occurred while trying to listen on the provided
address.NullPointerException - If host or {code factory} was null.public LDAPListener(String host, int port, ServerConnectionFactory<LDAPClientContext,Integer> factory, LDAPListenerOptions options) throws IOException
host - The address to listen on.port - The port to listen on.factory - The server connection factory which will be used to create
server connections.options - The LDAP listener options.IOException - If an error occurred while trying to listen on the provided
address.NullPointerException - If host, {code factory}, or options was
null.public void close()
close in interface Closeableclose in interface AutoCloseablepublic InetAddress getAddress()
InetAddress that this LDAP listener is listening on.InetAddress that this LDAP listener is listening on.public String getHostName()
public int getPort()
public InetSocketAddress getSocketAddress()
public String getProviderName()
Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.