Package org.opends.server.api
Class ClientConnection
java.lang.Object
org.opends.server.api.ClientConnection
This class defines the set of methods and structures that must be implemented by a Directory Server client
connection.
This class is deprecated, it should be replaced by ConnectionContext
, see
OPENDJ-3620
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
This class provides a data structure which maps an authenticated user DN to the set of client connections authenticated as that user. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ClientConnection
(ServerContext serverContext) Performs the appropriate initialization generic to all client connections.protected
ClientConnection
(ServerContext serverContext, AuthenticationInfo authenticationInfo) Performs the appropriate initialization generic to all client connections. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelAllRequestsExcept
(int msgId, LocalizableMessage reason) Attempts to cancel all active requests except for the request having the specified message ID, blocking until all of the requests are cancelled or completed.cancelRequest
(int msgId, boolean notifyClient, LocalizableMessage reason) Attempts to cancel the request having the specified message ID, blocking until either the targeted request is cancelled or completed.final void
deregisterPersistentSearch
(PersistentSearch persistentSearch) Deregisters the provided persistent search for this client.abstract void
disconnect
(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message) Asynchronously closes the connection to the client, optionally sending it a message indicating the reason for the closure.final AuthenticationInfo
Retrieves information about the authentication that has been performed for this connection.abstract String
Returns a string representation of the address of the client.Returns the certificate chain associated with a connection that has been secured using SSL, or an empty array if SSL is not enabled on this connection (or there are no certificates).final String
Retrieves the address and port (if available) of the client system, separated by a colon.abstract int
Retrieves the port number for this connection on the client system if available.abstract ConnectionHandler
<?> Returns the connection handler that accepted this client connection.abstract long
Returns the unique identifier that has been assigned to this connection.protected final String
Returns a string representation of the time that this connection was established.long
Returns the length of time in milliseconds that this client connection has been idle.abstract JsonValue
Returns a summary of this client connection in JSON (format that is both human readable and machine parseable).final List
<PersistentSearch> Returns the persistent searches registered for this client.abstract String
Returns the protocol that the client is using to communicate with the Directory Server.abstract InetAddress
Returns theInetAddress
associated with the remote client system. It may benull
if the client is not connected over an IP-based connection.final Object
Returns an opaque set of information that may be used for processing multi-stage SASL binds.abstract String
Returns a string representation of the address on the server to which the client connected.protected final ServerContext
Returns the server context.final String
Returns the address and port of the server system, separated by a colon.abstract int
Retrieves the port number for this connection on the server system if available.abstract int
getSsf()
Return the Security Strength Factor of a client connection.Return the TLS cipher suite of a client connection.Return the TLS protocol of a client connection.final boolean
hasAllPrivileges
(Privilege[] privileges, Operation operation) Indicates whether the authenticate client has all of the specified privileges.static boolean
hasPrivilege
(Entry authorizationEntry, Privilege privilege, ServerContext serverContext) Indicate whether the specified authorization entry parameter has the specified privilege.final boolean
hasPrivilege
(Privilege privilege, Operation operation) Indicates whether the authenticated client has the specified privilege.boolean
Indicates if this connection is on the Administration Connector which may mean it is excluded from certain checks.abstract @com.forgerock.opendj.util.LoomTODO({"HTTP specific - can be removed?"}) boolean
Returns whether the Directory Server believes this connection to be valid and available for communication.abstract boolean
isSecure()
Indicates whether this client connection is currently using a secure mechanism to communicate with the server.boolean
Returnstrue
if this connection supports the start TLS request.final boolean
Indicates whether the user associated with this client connection must change their password before they will be allowed to do anything else.boolean
Returns whether TLS information must be logged by the caller.final void
registerPersistentSearch
(PersistentSearch persistentSearch) Registers the provided persistent search for this client.void
setAuthenticationInfo
(AuthenticationInfo authenticationInfo) Specifies information about the authentication that has been performed for this connection.final void
setMustChangePassword
(boolean mustChangePassword) Specifies whether the user associated with this client connection must change their password before they will be allowed to do anything else.final void
setSaslAuthStateInfo
(Object saslAuthState) Specifies an opaque set of information that may be used for processing multi-stage SASL binds.abstract String
toString()
Returns a string representation of this client connection.protected static LdapException
writeTimeLimitExceeded
(Duration timeout) Returns a new LdapException for max blocked write time limit exceeded.
-
Constructor Details
-
ClientConnection
Performs the appropriate initialization generic to all client connections.- Parameters:
serverContext
- the server context
-
ClientConnection
Performs the appropriate initialization generic to all client connections.- Parameters:
serverContext
- the server contextauthenticationInfo
- the initial authentication info
-
-
Method Details
-
getConnectTimeString
Returns a string representation of the time that this connection was established.- Returns:
- a string representation of the time that this connection was established
-
getConnectionId
public abstract long getConnectionId()Returns the unique identifier that has been assigned to this connection.- Returns:
- the unique identifier that has been assigned to this connection
-
getConnectionHandler
Returns the connection handler that accepted this client connection.- Returns:
- the connection handler that accepted this client connection
-
getProtocol
Returns the protocol that the client is using to communicate with the Directory Server.- Returns:
- the protocol that the client is using to communicate with the Directory Server
-
getClientAddress
Returns a string representation of the address of the client.- Returns:
- a string representation of the address of the client
-
getClientPort
public abstract int getClientPort()Retrieves the port number for this connection on the client system if available.- 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).
-
getClientHostPort
Retrieves the address and port (if available) of the client system, separated by a colon.- Returns:
- The address and port of the client system, separated by a colon.
-
getServerAddress
Returns a string representation of the address on the server to which the client connected.- Returns:
- a string representation of the address on the server to which the client connected
-
getServerPort
public abstract int getServerPort()Retrieves the port number for this connection on the server system if available.- 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).
-
getServerHostPort
Returns the address and port of the server system, separated by a colon.- Returns:
- the address and port of the server system, separated by a colon
-
getRemoteAddress
Returns theInetAddress
associated with the remote client system. It may benull
if the client is not connected over an IP-based connection.- Returns:
- the
InetAddress
associated with the remote client system. It may benull
if the client is not connected over an IP-based connection
-
isAdministrative
public boolean isAdministrative()Indicates if this connection is on the Administration Connector which may mean it is excluded from certain checks.- Returns:
true
if this connection is on the Administration Connector.
-
isConnectionValid
public abstract @com.forgerock.opendj.util.LoomTODO({"HTTP specific - can be removed?"}) boolean isConnectionValid()Returns whether the Directory Server believes this connection to be valid and available for communication.- Returns:
- true if the connection is valid, false otherwise
-
isStartTlsSupported
public boolean isStartTlsSupported()Returnstrue
if this connection supports the start TLS request.- Returns:
true
if this connection supports the start TLS request
-
isSecure
public abstract boolean isSecure()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).- Returns:
true
if the client connection is currently using a secure mechanism to communicate with the server, orfalse
if not.
-
getClientCertificateChain
Returns the certificate chain associated with a connection that has been secured using SSL, or an empty array if SSL is not enabled on this connection (or there are no certificates).- Returns:
- The array of certificates associated with this connection.
-
writeTimeLimitExceeded
Returns a new LdapException for max blocked write time limit exceeded.- Parameters:
timeout
- the value for the timeout- Returns:
- a new LdapException for max blocked write time limit exceeded
-
disconnect
public abstract void disconnect(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message) Asynchronously 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.All subclasses must invoke the
finalizeConnectionInternal
method during the course of processing this method. In addition, implementations should not block until active requests are cancelled due to the risk of deadlocks in cases where a request attempts to disconnect its own connection (e.g. when deleting the authenticated user).- 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.
-
mustChangePassword
public final boolean mustChangePassword()Indicates whether the user associated with this client connection must change their password before they will be allowed to do anything else.- Returns:
true
if the user associated with this client connection must change their password before they will be allowed to do anything else, orfalse
if not.
-
setMustChangePassword
public final void setMustChangePassword(boolean mustChangePassword) Specifies whether the user associated with this client connection must change their password before they will be allowed to do anything else.- Parameters:
mustChangePassword
- Specifies whether the user associated with this client connection must change their password before they will be allowed to do anything else.
-
getPersistentSearches
Returns the persistent searches registered for this client.- Returns:
- the persistent searches registered for this client
-
registerPersistentSearch
Registers the provided persistent search for this client. Note that this should only be called byDirectoryServer.registerPersistentSearch
and not through any other means.- Parameters:
persistentSearch
- The persistent search to register for this client.
-
deregisterPersistentSearch
Deregisters the provided persistent search for this client. Note that this should only be called byDirectoryServer.deregisterPersistentSearch
and not through any other means.- Parameters:
persistentSearch
- The persistent search to deregister for this client.
-
getAuthenticationInfo
Retrieves information about the authentication that has been performed for this connection.- Returns:
- Information about the user that is currently authenticated on this connection.
-
setAuthenticationInfo
Specifies information about the authentication that has been performed for this connection.- Parameters:
authenticationInfo
- Information about the authentication that has been performed for this connection
-
hasPrivilege
public static boolean hasPrivilege(Entry authorizationEntry, Privilege privilege, ServerContext serverContext) Indicate whether the specified authorization entry parameter has the specified privilege. The method can be used to perform a "what-if" scenario.- Parameters:
authorizationEntry
- The authentication entry to use.privilege
- The privilege to check for.serverContext
- The server context- Returns:
true
if the authentication entry has the specified privilege, orfalse
if not.
-
hasPrivilege
Indicates whether the authenticated client has the specified privilege.- Parameters:
privilege
- The privilege for which to make the determination.operation
- The operation being processed which needs to make the privilege determination, ornull
if there is no associated operation.- Returns:
true
if the authenticated client has the specified privilege, orfalse
if not.
-
hasAllPrivileges
Indicates whether the authenticate client has all of the specified privileges.- Parameters:
privileges
- The array of privileges for which to make the determination.operation
- The operation being processed which needs to make the privilege determination, ornull
if there is no associated operation.- Returns:
true
if the authenticated client has all of the specified privileges, orfalse
if not.
-
getSaslAuthStateInfo
Returns an opaque set of information that may be used for processing multi-stage SASL binds.- Returns:
- an opaque set of information that may be used for processing multi-stage SASL binds
-
setSaslAuthStateInfo
Specifies an opaque set of information that may be used for processing multi-stage SASL binds.- Parameters:
saslAuthState
- An opaque set of information that may be used for processing multi-stage SASL binds.
-
getServerContext
Returns the server context.- Returns:
- the server context
-
getMonitorSummary
Returns a summary of this client connection in JSON (format that is both human readable and machine parseable).- Returns:
- A summary of this client connection in JSON.
-
toString
Returns a string representation of this client connection. -
getIdleTime
public long getIdleTime()Returns 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.
- Returns:
- the length of time in milliseconds that this client connection has been idle
-
getSsf
public abstract int getSsf()Return the Security Strength Factor of a client connection.- Returns:
- An integer representing the SSF value of a connection.
-
getTlsProtocol
Return the TLS protocol of a client connection.- Returns:
- A string, or
"NONE"
if TLS handshake is not complete, ornull
if TLS is not active.
-
getTlsCipher
Return the TLS cipher suite of a client connection.- 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()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.- Returns:
- whether TLS information must be logged by the caller
-
cancelRequest
Attempts to cancel the request having the specified message ID, blocking until either the targeted request is cancelled or completed.- Parameters:
msgId
- The message ID of the request to be cancelled.notifyClient
-true
if the client should receive a response if the request was successfully cancelled.reason
- A message explaining the reason for the cancellation.- Returns:
- The result of the cancellation request.
-
cancelAllRequestsExcept
Attempts to cancel all active requests except for the request having the specified message ID, blocking until all of the requests are cancelled or completed.- Parameters:
msgId
- The message ID of the request that should not be cancelled.reason
- A message explaining the reason for the cancellation.
-