@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class LDAPListenerClientConnection extends java.lang.Thread implements java.io.Closeable
LDAPListener
, although connections may also
be created independently if they were accepted in some other way. Each
connection has its own thread that will be used to read requests from the
client, and connections created outside of an LDAPListener
instance,
then the thread must be explicitly started.Constructor and Description |
---|
LDAPListenerClientConnection(LDAPListener listener,
java.net.Socket socket,
LDAPListenerRequestHandler requestHandler,
LDAPListenerExceptionHandler exceptionHandler)
Creates a new LDAP listener client connection that will communicate with
the client using the provided socket.
|
Modifier and Type | Method and Description |
---|---|
void |
addIntermediateResponseTransformer(IntermediateResponseTransformer t)
Adds the provided intermediate response transformer to this client
connection.
|
void |
addSearchEntryTransformer(SearchEntryTransformer t)
Adds the provided search entry transformer to this client connection.
|
void |
addSearchReferenceTransformer(SearchReferenceTransformer t)
Adds the provided search reference transformer to this client connection.
|
void |
close()
Closes the connection to the client.
|
java.io.OutputStream |
convertToTLS(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Attempts to convert this unencrypted connection to one that uses TLS
encryption, as would be used during the course of invoking the StartTLS
extended operation.
|
java.io.OutputStream |
convertToTLS(javax.net.ssl.SSLSocketFactory sslSocketFactory,
boolean requestClientCertificate,
boolean requireClientCertificate)
Attempts to convert this unencrypted connection to one that uses TLS
encryption, as would be used during the course of invoking the StartTLS
extended operation.
|
long |
getConnectionID()
Retrieves the connection ID that has been assigned to this connection by
the associated listener.
|
java.net.Socket |
getSocket()
Retrieves the socket used to communicate with the client.
|
void |
removeIntermediateResponseTransformer(IntermediateResponseTransformer t)
Removes the provided intermediate response transformer from this client
connection.
|
void |
removeSearchEntryTransformer(SearchEntryTransformer t)
Removes the provided search entry transformer from this client connection.
|
void |
removeSearchReferenceTransformer(SearchReferenceTransformer t)
Removes the provided search reference transformer from this client
connection.
|
void |
run()
Operates in a loop, waiting for a request to arrive from the client and
handing it off to the request handler for processing.
|
void |
sendIntermediateResponse(int messageID,
IntermediateResponseProtocolOp protocolOp,
Control... controls)
Sends an intermediate response message to the client with the provided
information.
|
void |
sendSearchResultEntry(int messageID,
Entry entry,
Control... controls)
Sends a search result entry message to the client with the provided
information.
|
void |
sendSearchResultEntry(int messageID,
SearchResultEntryProtocolOp protocolOp,
Control... controls)
Sends a search result entry message to the client with the provided
information.
|
void |
sendSearchResultReference(int messageID,
SearchResultReferenceProtocolOp protocolOp,
Control... controls)
Sends a search result reference message to the client with the provided
information.
|
void |
sendUnsolicitedNotification(ExtendedResponseProtocolOp extendedResponse,
Control... controls)
Sends an unsolicited notification message to the client with the provided
information.
|
void |
sendUnsolicitedNotification(ExtendedResult result)
Sends an unsolicited notification message to the client with the provided
extended result.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public LDAPListenerClientConnection(@Nullable LDAPListener listener, @NotNull java.net.Socket socket, @NotNull LDAPListenerRequestHandler requestHandler, @Nullable LDAPListenerExceptionHandler exceptionHandler) throws LDAPException
Thread.start()
method must be
called to start listening for requests from the client.listener
- The listener that accepted this client
connection. It may be null
if this
connection was not accepted by a listener.socket
- The socket that may be used to communicate with
the client. It must not be null
.requestHandler
- The request handler that will be used to process
requests read from the client. The
LDAPListenerRequestHandler.newInstance(com.unboundid.ldap.listener.LDAPListenerClientConnection)
method will be called on the provided object to
obtain a new instance to use for this connection.
The provided request handler must not be
null
.exceptionHandler
- The disconnect handler to be notified when this
connection is closed. It may be null
if
no disconnect handler should be used.LDAPException
- If a problem occurs while preparing this client
connection. for use. If this is thrown, then the
provided socket will be closed.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- If a problem occurs while closing the socket.@InternalUseOnly public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void sendSearchResultEntry(int messageID, @NotNull SearchResultEntryProtocolOp protocolOp, @Nullable Control... controls) throws LDAPException
messageID
- The message ID for the LDAP message to send to the
client. It must match the message ID of the associated
search request.protocolOp
- The search result entry protocol op to include in the
LDAP message to send to the client. It must not be
null
.controls
- The set of controls to include in the response message.
It may be empty or null
if no controls should
be included.LDAPException
- If a problem occurs while attempting to send the
provided response message. If an exception is
thrown, then the client connection will have been
terminated.public void sendSearchResultEntry(int messageID, @NotNull Entry entry, @Nullable Control... controls) throws LDAPException
messageID
- The message ID for the LDAP message to send to the
client. It must match the message ID of the associated
search request.entry
- The entry to return to the client. It must not be
null
.controls
- The set of controls to include in the response message.
It may be empty or null
if no controls should be
included.LDAPException
- If a problem occurs while attempting to send the
provided response message. If an exception is
thrown, then the client connection will have been
terminated.public void sendSearchResultReference(int messageID, @NotNull SearchResultReferenceProtocolOp protocolOp, @Nullable Control... controls) throws LDAPException
messageID
- The message ID for the LDAP message to send to the
client. It must match the message ID of the associated
search request.protocolOp
- The search result reference protocol op to include in
the LDAP message to send to the client.controls
- The set of controls to include in the response message.
It may be empty or null
if no controls should
be included.LDAPException
- If a problem occurs while attempting to send the
provided response message. If an exception is
thrown, then the client connection will have been
terminated.public void sendIntermediateResponse(int messageID, @NotNull IntermediateResponseProtocolOp protocolOp, @Nullable Control... controls) throws LDAPException
messageID
- The message ID for the LDAP message to send to the
client. It must match the message ID of the associated
search request.protocolOp
- The intermediate response protocol op to include in the
LDAP message to send to the client.controls
- The set of controls to include in the response message.
It may be empty or null
if no controls should
be included.LDAPException
- If a problem occurs while attempting to send the
provided response message. If an exception is
thrown, then the client connection will have been
terminated.public void sendUnsolicitedNotification(@NotNull ExtendedResult result) throws LDAPException
result
- The extended result to use for the unsolicited
notification.LDAPException
- If a problem occurs while attempting to send the
unsolicited notification. If an exception is
thrown, then the client connection will have been
terminated.public void sendUnsolicitedNotification(@NotNull ExtendedResponseProtocolOp extendedResponse, @Nullable Control... controls) throws LDAPException
extendedResponse
- The extended response to use for the unsolicited
notification.controls
- The set of controls to include with the
unsolicited notification. It may be empty or
null
if no controls should be included.LDAPException
- If a problem occurs while attempting to send the
unsolicited notification. If an exception is
thrown, then the client connection will have been
terminated.@NotNull public java.net.Socket getSocket()
@NotNull public java.io.OutputStream convertToTLS(@NotNull javax.net.ssl.SSLSocketFactory sslSocketFactory) throws LDAPException
sslSocketFactory
- The SSL socket factory that will be used to
convert the existing Socket
to an
SSLSocket
.LDAPException
- If a problem is encountered while trying to convert
the existing socket to an SSL socket. If this is
thrown, then the connection will have been closed.@NotNull public java.io.OutputStream convertToTLS(@NotNull javax.net.ssl.SSLSocketFactory sslSocketFactory, boolean requestClientCertificate, boolean requireClientCertificate) throws LDAPException
sslSocketFactory
- The SSL socket factory that will be used
to convert the existing Socket
to
an SSLSocket
.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
if requestClientCertificate
is
false
.LDAPException
- If a problem is encountered while trying to convert
the existing socket to an SSL socket. If this is
thrown, then the connection will have been closed.public long getConnectionID()
public void addSearchEntryTransformer(@NotNull SearchEntryTransformer t)
t
- A search entry transformer to be used to intercept and/or alter
search result entries before they are returned to the client.public void removeSearchEntryTransformer(@NotNull SearchEntryTransformer t)
t
- The search entry transformer to be removed.public void addSearchReferenceTransformer(@NotNull SearchReferenceTransformer t)
t
- A search reference transformer to be used to intercept and/or
alter search result references before they are returned to the
client.public void removeSearchReferenceTransformer(@NotNull SearchReferenceTransformer t)
t
- The search reference transformer to be removed.public void addIntermediateResponseTransformer(@NotNull IntermediateResponseTransformer t)
t
- An intermediate response transformer to be used to intercept
and/or alter intermediate responses before they are returned to
the client.public void removeIntermediateResponseTransformer(@NotNull IntermediateResponseTransformer t)
t
- The intermediate response transformer to be removed.