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
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClientConnection(ServerContext serverContext) Performs the appropriate initialization generic to all client connections. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelAllRequestsExcept(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.protected static ResultconvertResult(Request request, Result result) final voidderegisterPersistentSearch(PersistentSearch persistentSearch) Deregisters the provided persistent search for this client.abstract voiddisconnect(DisconnectReason disconnectReason, boolean sendNotification, LocalizableMessage message) Asynchronously closes the connection to the client, optionally sending it a message indicating the reason for the closure.protected final voidPerforms any internal cleanup that may be necessary when this client connection is disconnected.final AuthenticationInfoRetrieves information about the authentication that has been performed for this connection.abstract StringRetrieves 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 StringRetrieves the address and port (if available) of the client system, separated by a colon.abstract intRetrieves the port number for this connection on the client system if available.abstract ConnectionHandler<?>Retrieves the connection handler that accepted this client connection.abstract @com.forgerock.opendj.util.LoomTODO({"Fix shouting"}) longRetrieves the unique identifier that has been assigned to this connection.protected final StringRetrieves a string representation of the time that this connection was established.@com.forgerock.opendj.util.LoomTODO({"LDAP specific - can be removed"}) longRetrieves the length of time in milliseconds that this client connection has been idle.abstract JsonValueReturns a summary of this client connection in JSON (format that is both human readable and machine parseable).final List<PersistentSearch>Retrieves the set of persistent searches registered for this client.abstract StringRetrieves the protocol that the client is using to communicate with the Directory Server.abstract InetAddressRetrieves theInetAddressassociated with the remote client system.final ObjectRetrieves an opaque set of information that may be used for processing multi-stage SASL binds.abstract StringRetrieves a string representation of the address on the server to which the client connected.protected final ServerContextReturns the server context.final StringRetrieves the address and port of the server system, separated by a colon.abstract intRetrieves the port number for this connection on the server system if available.abstract @com.forgerock.opendj.util.LoomTODO({"Fix shouting"}) intgetSSF()Return the Security Strength Factor of a client connection.protected StringgetThreadNameForRequest(RequestContext context, Request request) Returns the name that should be used for processing a request.Return the TLS cipher suite of a client connection.Return the TLS protocol of a client connection.final booleanhasAllPrivileges(Privilege[] privileges, Operation operation) Indicates whether the authenticate client has all of the specified privileges.static booleanhasPrivilege(Entry authorizationEntry, Privilege privilege, ServerContext serverContext) Indicate whether the specified authorization entry parameter has the specified privilege.final booleanhasPrivilege(Privilege privilege, Operation operation) Indicates whether the authenticated client has the specified privilege.abstract @com.forgerock.opendj.util.LoomTODO({"HTTP specific - can be removed?"}) booleanReturns whether the Directory Server believes this connection to be valid and available for communication.abstract booleanisSecure()Indicates whether this client connection is currently using a secure mechanism to communicate with the server.booleanReturnstrueif this connection supports the start TLS request.final booleanIndicates whether the user associated with this client connection must change their password before they will be allowed to do anything else.booleanReturns whether TLS information must be logged by the caller.final voidregisterPersistentSearch(PersistentSearch persistentSearch) Registers the provided persistent search for this client.voidsetAuthenticationInfo(AuthenticationInfo authenticationInfo) Specifies information about the authentication that has been performed for this connection.protected final voidsetAuthenticationInfoNoTrackingOfAuthenticatedUsers(AuthenticationInfo authenticationInfo) Specifies information about the authentication that has been performed for this connection.final voidsetMustChangePassword(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 voidsetSASLAuthStateInfo(Object saslAuthState) Specifies an opaque set of information that may be used for processing multi-stage SASL binds.final StringtoString()Retrieves a string representation of this client connection.protected abstract voidtoString(StringBuilder buffer) Appends a string representation of this client connection to the provided buffer.final voidupdateAuthenticationInfo(Entry oldEntry, Entry newEntry) Updates the cached entry associated with either the authentication and/or authorization identity with the provided version.protected static LdapExceptionwriteTimeLimitExceeded(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
-
-
Method Details
-
finalizeConnectionInternal
protected final void finalizeConnectionInternal()Performs any internal cleanup that may be necessary when this client connection is disconnected. In this case, it will be used to ensure that the connection is deregistered with theAuthenticatedUsersmanager, and will then invoke thefinalizeClientConnectionmethod. -
getConnectTimeString
Retrieves 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 @com.forgerock.opendj.util.LoomTODO({"Fix shouting"}) long getConnectionID()Retrieves the unique identifier that has been assigned to this connection.- Returns:
- The unique identifier that has been assigned to this connection.
-
getConnectionHandler
Retrieves the connection handler that accepted this client connection.- Returns:
- The connection handler that accepted this client connection.
-
getProtocol
Retrieves 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
Retrieves 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
Retrieves 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
Retrieves 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
Retrieves theInetAddressassociated with the remote client system.- Returns:
- The
InetAddressassociated with the remote client system. It may benullif the client is not connected over an IP-based connection.
-
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()Returnstrueif this connection supports the start TLS request.- Returns:
trueif 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 fromfalsetotrueif the client uses the StartTLS extended operation).- Returns:
trueif the client connection is currently using a secure mechanism to communicate with the server, orfalseif 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
finalizeConnectionInternalmethod 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 benullif 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:
trueif the user associated with this client connection must change their password before they will be allowed to do anything else, orfalseif 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
Retrieves the set of persistent searches registered for this client.- Returns:
- The set of persistent searches registered for this client.
-
registerPersistentSearch
Registers the provided persistent search for this client. Note that this should only be called byDirectoryServer.registerPersistentSearchand 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.deregisterPersistentSearchand 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
-
setAuthenticationInfoNoTrackingOfAuthenticatedUsers
protected final void setAuthenticationInfoNoTrackingOfAuthenticatedUsers(AuthenticationInfo authenticationInfo) Specifies information about the authentication that has been performed for this connection. Contrary tosetAuthenticationInfo(AuthenticationInfo), the current method does not track the authentication info in the authenticated users.- Parameters:
authenticationInfo-null-able information about the authentication that has been performed for this connection
-
updateAuthenticationInfo
Updates the cached entry associated with either the authentication and/or authorization identity with the provided version.- Parameters:
oldEntry- The user entry currently serving as the authentication and/or authorization identity.newEntry- The updated entry that should replace the existing entry. It may optionally have a different DN than the old entry.
-
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:
trueif the authentication entry has the specified privilege, orfalseif 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, ornullif there is no associated operation.- Returns:
trueif the authenticated client has the specified privilege, orfalseif 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, ornullif there is no associated operation.- Returns:
trueif the authenticated client has all of the specified privileges, orfalseif not.
-
getSASLAuthStateInfo
Retrieves 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
Retrieves a string representation of this client connection. -
toString
Appends a string representation of this client connection to the provided buffer.- Parameters:
buffer- The buffer to which the information should be appended.
-
getIdleTime
public @com.forgerock.opendj.util.LoomTODO({"LDAP specific - can be removed"}) long getIdleTime()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.
- Returns:
- The length of time in milliseconds that this client connection has been idle.
-
getSSF
public abstract @com.forgerock.opendj.util.LoomTODO({"Fix shouting"}) 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, ornullif 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, ornullif 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-trueif 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.
-
convertResult
- Parameters:
request- The request.result- The result.- Returns:
- The converted result.
-
getThreadNameForRequest
Returns the name that should be used for processing a request.- Parameters:
context- The request context.request- The request.- Returns:
- The name of the thread.
-