Package org.opends.server.protocols.ldap
Class LdapClientConnection
- java.lang.Object
-
- org.opends.server.api.ClientConnection
-
- org.opends.server.protocols.ldap.LdapClientConnection
-
- All Implemented Interfaces:
RequestHandler
,TLSCapableConnection
public final class LdapClientConnection extends ClientConnection implements TLSCapableConnection
This class defines an LDAP client connection, which is a type of client connection that will be accepted by an instance of the LDAP connection handler and have its requests decoded by an LDAP request handler.
-
-
Field Summary
-
Fields inherited from class org.opends.server.api.ClientConnection
authenticationInfo, bindInProgress, saslBindInProgress, startTLSInProgress
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disconnect(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message)
Closes the connection to the client, optionally sending it a message indicating the reason for the closure.String
getClientAddress()
Retrieves a string representation of the address of the client.Certificate[]
getClientCertificateChain()
Return the certificate chain array associated with a connection.int
getClientPort()
Retrieves the port number for this connection on the client system if available.ConnectionHandler<?>
getConnectionHandler()
Retrieves the connection handler that accepted this client connection.long
getConnectionID()
Retrieves the unique identifier that has been assigned to this connection.long
getIdleTime()
Retrieves the length of time in milliseconds that this client connection has been idle.long
getMaxBlockedWriteTimeLimit()
Retrieves the maximum length of time in milliseconds that attempts to write data to the client should be allowed to block.JsonValue
getMonitorSummary()
Returns a summary of this client connection in JSON (format that is both human readable and machine parseable).Operation
getOperationInProgress(int messageID)
Retrieves the operation in progress with the specified message ID.String
getProtocol()
Retrieves the protocol that the client is using to communicate with the Directory Server.InetAddress
getRemoteAddress()
Retrieves theInetAddress
associated with the remote client system.String
getServerAddress()
Retrieves a string representation of the address on the server to which the client connected.int
getServerPort()
Retrieves the port number for this connection on the server system if available.int
getSSF()
Return the Security Strength Factor of a client connection.String
getTlsCipher()
Return the TLS cipher suite of a client connection.String
getTlsProtocol()
Return the TLS protocol of a client connection.Flowable<Response>
handle(org.forgerock.services.context.Context context, Request request)
Processes the provided request in a reactive way.boolean
isConnectionValid()
Returns whether the Directory Server believes this connection to be valid and available for communication.boolean
isSecure()
Indicates whether this client connection is currently using a secure mechanism to communicate with the server.boolean
mustLogTlsHandshake()
Returns whether TLS information must be logged by the caller.boolean
prepareTLS(LocalizableMessageBuilder unavailableReason)
Prepares this connection for using TLS and returns whether TLS protection is actually available for the underlying client connection.void
removeOperationInProgress(int messageID)
Removes the provided operation from the set of operations in progress for this client connection.protected boolean
sendIntermediateResponseMessage(Operation operation, IntermediateResponse intermediateResponse)
Sends the provided intermediate response message to the client.void
sendResponse(Operation operation)
Removes the provided operation from the set of operations in progress of this client connection and sends a response to the client based on the information in the provided operation.void
sendSearchEntry(SearchOperation searchOperation, SearchResultEntry searchEntry)
Sends the provided search result entry to the client.boolean
sendSearchReference(SearchOperation searchOperation, SearchResultReference searchReference)
Sends the provided search result reference to the client.void
toString(StringBuilder buffer)
Appends a string representation of this client connection to the provided buffer.-
Methods inherited from class org.opends.server.api.ClientConnection
deregisterPersistentSearch, finalizeConnectionInternal, finishBind, finishSaslBind, finishStartTLS, getAuthenticationInfo, getClientHostPort, getConnectTimeString, getIdleTimeLimit, getKeyManagerProviderDN, getMaxCandidateSetSize, getPersistentSearches, getSASLAuthStateInfo, getServerContext, getServerHostPort, getSizeLimit, getTimeLimit, hasAllPrivileges, hasPrivilege, hasPrivilege, isInnerConnection, mustChangePassword, registerPersistentSearch, sendResponse, setAuthenticationInfo, setIdleTimeLimit, setMaxCandidateSetSize, setMustChangePassword, setResourceLimits, setSASLAuthStateInfo, setSizeLimit, setTimeLimit, setUnauthenticated, toString, updateAuthenticationInfo, updatePrivileges, writeTimeLimitExceeded
-
-
-
-
Method Detail
-
getConnectionID
public long getConnectionID()
Description copied from class:ClientConnection
Retrieves the unique identifier that has been assigned to this connection.- Specified by:
getConnectionID
in classClientConnection
- Returns:
- The unique identifier that has been assigned to this connection.
-
getConnectionHandler
public ConnectionHandler<?> getConnectionHandler()
Description copied from class:ClientConnection
Retrieves the connection handler that accepted this client connection.- Specified by:
getConnectionHandler
in classClientConnection
- Returns:
- The connection handler that accepted this client connection.
-
getProtocol
public String getProtocol()
Description copied from class:ClientConnection
Retrieves the protocol that the client is using to communicate with the Directory Server.- Specified by:
getProtocol
in classClientConnection
- Returns:
- The protocol that the client is using to communicate with the Directory Server.
-
getClientAddress
public String getClientAddress()
Description copied from class:ClientConnection
Retrieves a string representation of the address of the client.- Specified by:
getClientAddress
in classClientConnection
- Returns:
- A string representation of the address of the client.
-
getClientPort
public int getClientPort()
Description copied from class:ClientConnection
Retrieves the port number for this connection on the client system if available.- Specified by:
getClientPort
in classClientConnection
- Returns:
- The port number for this connection on the client system or -1 if there is no client port associated with this connection (e.g. internal client).
-
getServerAddress
public String getServerAddress()
Description copied from class:ClientConnection
Retrieves a string representation of the address on the server to which the client connected.- Specified by:
getServerAddress
in classClientConnection
- Returns:
- A string representation of the address on the server to which the client connected.
-
getServerPort
public int getServerPort()
Description copied from class:ClientConnection
Retrieves the port number for this connection on the server system if available.- Specified by:
getServerPort
in classClientConnection
- Returns:
- The port number for this connection on the server system or -1 if there is no server port associated with this connection (e.g. internal client).
-
getRemoteAddress
public InetAddress getRemoteAddress()
Description copied from class:ClientConnection
Retrieves theInetAddress
associated with the remote client system.- Specified by:
getRemoteAddress
in classClientConnection
- Returns:
- The
InetAddress
associated with the remote client system. It may benull
if the client is not connected over an IP-based connection.
-
isConnectionValid
public boolean isConnectionValid()
Description copied from class:ClientConnection
Returns whether the Directory Server believes this connection to be valid and available for communication.- Specified by:
isConnectionValid
in classClientConnection
- Returns:
- true if the connection is valid, false otherwise
-
isSecure
public boolean isSecure()
Description copied from class:ClientConnection
Indicates whether this client connection is currently using a secure mechanism to communicate with the server. Note that this may change over time based on operations performed by the client or server (e.g., it may go fromfalse
totrue
if the client uses the StartTLS extended operation).- Specified by:
isSecure
in classClientConnection
- Returns:
true
if the client connection is currently using a secure mechanism to communicate with the server, orfalse
if not.
-
sendResponse
public void sendResponse(Operation operation)
Description copied from class:ClientConnection
Removes the provided operation from the set of operations in progress of this client connection and sends a response to the client based on the information in the provided operation.Note that this does not make any attempt to cancel any processing that may already be in progress for the operation.
- Overrides:
sendResponse
in classClientConnection
- Parameters:
operation
- The operation for which to send the response
-
sendSearchEntry
public void sendSearchEntry(SearchOperation searchOperation, SearchResultEntry searchEntry)
Description copied from class:ClientConnection
Sends the provided search result entry to the client.- Specified by:
sendSearchEntry
in classClientConnection
- Parameters:
searchOperation
- The search operation with which the entry is associated.searchEntry
- The search result entry to be sent to the client.
-
sendSearchReference
public boolean sendSearchReference(SearchOperation searchOperation, SearchResultReference searchReference)
Description copied from class:ClientConnection
Sends the provided search result reference to the client.- Specified by:
sendSearchReference
in classClientConnection
- Parameters:
searchOperation
- The search operation with which the reference is associated.searchReference
- The search result reference to be sent to the client.- Returns:
true
if the client is able to accept referrals, orfalse
if the client cannot handle referrals and no more attempts should be made to send them for the associated search operation.
-
sendIntermediateResponseMessage
protected boolean sendIntermediateResponseMessage(Operation operation, IntermediateResponse intermediateResponse)
Description copied from class:ClientConnection
Sends the provided intermediate response message to the client.- Specified by:
sendIntermediateResponseMessage
in classClientConnection
- Parameters:
operation
- The operation with which the intermediate response is associated.intermediateResponse
- The intermediate response message to be sent.- Returns:
true
if processing on the associated operation should continue, orfalse
if not.
-
disconnect
public void disconnect(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message)
Description copied from class:ClientConnection
Closes the connection to the client, optionally sending it a message indicating the reason for the closure. Note that the ability to send a notice of disconnection may not be available for all protocols or under all circumstances. Also note that when attempting to disconnect a client connection as a part of operation processing (e.g., within a plugin or other extension), thedisconnectClient
method within that operation should be called rather than invoking this method directly.All subclasses must invoke the
finalizeConnectionInternal
method during the course of processing this method.- Specified by:
disconnect
in classClientConnection
- Parameters:
disconnectReason
- The disconnect reason that provides the generic cause for the disconnect.sendNotification
- Indicates whether to try to provide notification to the client that the connection will be closed.message
- The message to send to the client. It may benull
if no notification is to be sent.
-
getOperationInProgress
public Operation getOperationInProgress(int messageID)
Description copied from class:ClientConnection
Retrieves the operation in progress with the specified message ID.- Specified by:
getOperationInProgress
in classClientConnection
- Parameters:
messageID
- The message ID of the operation to retrieve.- Returns:
- The operation in progress with the specified message ID, or
null
if no such operation could be found.
-
removeOperationInProgress
public void removeOperationInProgress(int messageID)
Description copied from class:ClientConnection
Removes the provided operation from the set of operations in progress for this client connection. Note that this does not make any attempt to cancel any processing that may already be in progress for the operation.- Specified by:
removeOperationInProgress
in classClientConnection
- Parameters:
messageID
- The message ID of the operation to remove from the set of operations in progress.
-
getMaxBlockedWriteTimeLimit
public long getMaxBlockedWriteTimeLimit()
Description copied from class:ClientConnection
Retrieves the maximum length of time in milliseconds that attempts to write data to the client should be allowed to block.- Overrides:
getMaxBlockedWriteTimeLimit
in classClientConnection
- Returns:
- The maximum length of time in milliseconds that attempts to write data to the client should be allowed to block.
-
handle
public Flowable<Response> handle(org.forgerock.services.context.Context context, Request request)
Processes the provided request in a reactive way.For most requests, this will include placing the operation in the work queue. Certain requests (in particular, abandons and unbinds) will be processed directly.
- Specified by:
handle
in interfaceRequestHandler
- Parameters:
context
- The context to process the request, which is expected to contain aRequestContext
request
- The request to process.- Returns:
- a stream of responses
-
getMonitorSummary
public JsonValue getMonitorSummary()
Description copied from class:ClientConnection
Returns a summary of this client connection in JSON (format that is both human readable and machine parseable).- Specified by:
getMonitorSummary
in classClientConnection
- Returns:
- A summary of this client connection in JSON.
-
toString
public void toString(StringBuilder buffer)
Description copied from class:ClientConnection
Appends a string representation of this client connection to the provided buffer.- Specified by:
toString
in classClientConnection
- Parameters:
buffer
- The buffer to which the information should be appended.
-
prepareTLS
public boolean prepareTLS(LocalizableMessageBuilder unavailableReason)
Description copied from interface:TLSCapableConnection
Prepares this connection for using TLS and returns whether TLS protection is actually available for the underlying client connection. If there is any reason that TLS protection cannot be enabled on this client connection, then it should be appended to the provided buffer.- Specified by:
prepareTLS
in interfaceTLSCapableConnection
- Parameters:
unavailableReason
- The buffer used to hold the reason that TLS is not available on the underlying client connection.- Returns:
true
if TLS is available on the underlying client connection, orfalse
if it is not.
-
getIdleTime
public long getIdleTime()
Description copied from class:ClientConnection
Retrieves the length of time in milliseconds that this client connection has been idle.Note that the default implementation will always return zero. Subclasses associated with connection handlers should override this method if they wish to provided idle time limit functionality.
- Overrides:
getIdleTime
in classClientConnection
- Returns:
- The length of time in milliseconds that this client connection has been idle.
-
getClientCertificateChain
public Certificate[] getClientCertificateChain()
Return the certificate chain array associated with a connection.- Returns:
- The array of certificates associated with a connection.
-
getSSF
public int getSSF()
Description copied from class:ClientConnection
Return the Security Strength Factor of a client connection.- Specified by:
getSSF
in classClientConnection
- Returns:
- An integer representing the SSF value of a connection.
-
getTlsProtocol
public String getTlsProtocol()
Description copied from class:ClientConnection
Return the TLS protocol of a client connection.- Overrides:
getTlsProtocol
in classClientConnection
- Returns:
- A string, or
"NONE"
if TLS handshake is not complete, ornull
if TLS is not active.
-
getTlsCipher
public String getTlsCipher()
Description copied from class:ClientConnection
Return the TLS cipher suite of a client connection.- Overrides:
getTlsCipher
in classClientConnection
- Returns:
- A cipher name, or
"SSL_NULL_WITH_NULL_NULL"
if TLS handshake is not complete, ornull
if TLS is not active.
-
mustLogTlsHandshake
public boolean mustLogTlsHandshake()
Description copied from class:ClientConnection
Returns whether TLS information must be logged by the caller. This method relies on side-effects to ensure the TLS information is logged only once per connection, even in the face of concurrent requests.- Overrides:
mustLogTlsHandshake
in classClientConnection
- Returns:
- whether TLS information must be logged by the caller
-
-