Package org.forgerock.opendj.server.core
Class ConnectionContext
- java.lang.Object
-
- org.forgerock.opendj.server.core.AbstractContext
-
- org.forgerock.opendj.server.core.ConnectionContext
-
- All Implemented Interfaces:
org.forgerock.services.context.Context
public class ConnectionContext extends AbstractContext
A context that maintains information on a client, including connection information.
-
-
Constructor Summary
Constructors Constructor Description ConnectionContext(ClientConnection clientConnection, org.forgerock.services.context.Context parent)Creates a new client context with a parent context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddPendingRequest(RequestContext requestContext)Adds the request context to the set of request context associated to requests which are in progress for this connection.CompletablecancelAllRequests(boolean notifyClient, LocalizableMessage reason)Returns aCompletablethat, once it is subscribed, will attempt to cancel all active requests on this connection.CompletablecancelAllRequestsExcept(int msgId, boolean notifyClient, LocalizableMessage reason)Returns aCompletablethat, once it is subscribed, will attempt to cancel all active requests on this connection that do not have the specified message ID.Single<Result>cancelRequest(int msgId, boolean notifyClient, LocalizableMessage reason)Returns aSinglethat, once it is subscribed, will attempt to cancel the specified request.AuthenticationInfogetAuthenticationInfo()Returns the authentication info to use for this connection context.ClientConnectiongetClientConnection()Returns the client connection.longgetConnectionId()Returns the unique identifier that has been assigned to this connection.longgetLastCompletionTime()Returns the time the last request on the connection was completed.longgetMaxBlockedWriteTimeLimit()Retrieves the maximum length of time in milliseconds that attempts to write data to the client should be allowed to block.StringgetProtocol()Returns the protocol that the client is using to communicate with the Directory Server.InetAddressgetRemoteAddress()Returns thejava.net.InetAddressassociated with the remote client system.intgetServerPort()Returns the port number for this connection on the server system if available.intgetSsf()Returns the cipher strength, in bits, currently in use by the underlying connection.booleanisIdle()Returns if the connection is idle.voidremovePendingRequest(int messageId)Removes the request context from the set of in-progress request contexts.voidsetAuthenticationInfo(AuthenticationInfo authenticationInfo)Sets the authentication info to use for this connection context.-
Methods inherited from class org.forgerock.opendj.server.core.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
-
-
-
-
Constructor Detail
-
ConnectionContext
public ConnectionContext(ClientConnection clientConnection, org.forgerock.services.context.Context parent)
Creates a new client context with a parent context.- Parameters:
clientConnection- The client connection.parent- The parent context.
-
-
Method Detail
-
getClientConnection
public ClientConnection getClientConnection()
Returns the client connection.- Returns:
- the client Connection
-
getAuthenticationInfo
public AuthenticationInfo getAuthenticationInfo()
Returns the authentication info to use for this connection context.- Returns:
- the authentication info, never
null
-
getProtocol
public String 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.
-
getRemoteAddress
public InetAddress getRemoteAddress()
Returns thejava.net.InetAddressassociated with the remote client system.- Returns:
- The
java.net.InetAddressassociated with the remote client system. It may benullif the client is not connected over an IP-based connection.
-
getServerPort
public int getServerPort()
Returns 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).
-
getSsf
public int getSsf()
Returns the cipher strength, in bits, currently in use by the underlying connection. The returned value is always greater or equal to zero, where a value of zero indicates that the underlying connection is unprotected.- Returns:
- The cipher strength, in bits, currently in use by the underlying connection.
-
setAuthenticationInfo
public void setAuthenticationInfo(AuthenticationInfo authenticationInfo)
Sets the authentication info to use for this connection context.- Parameters:
authenticationInfo- the authentication info. Ifnull, then an authentication info suitable for anonymous users will be created.
-
getConnectionId
public long getConnectionId()
Returns the unique identifier that has been assigned to this connection.- Returns:
- the unique identifier that has been assigned to this connection
-
getMaxBlockedWriteTimeLimit
public long getMaxBlockedWriteTimeLimit()
Retrieves the maximum length of time in milliseconds that attempts to write data to the client should be allowed to block.- Returns:
- The maximum length of time in milliseconds that attempts to write data to the client should be allowed to block.
-
cancelRequest
public Single<Result> cancelRequest(int msgId, boolean notifyClient, LocalizableMessage reason)
Returns aSinglethat, once it is subscribed, will attempt to cancel the specified request.- 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:
- A
Singlethat, once it is subscribed, will attempt to cancel the specified request.
-
cancelAllRequests
public Completable cancelAllRequests(boolean notifyClient, LocalizableMessage reason)
Returns aCompletablethat, once it is subscribed, will attempt to cancel all active requests on this connection.- Parameters:
notifyClient-trueif the client should receive a response for requests that were successfully cancelled.reason- A message explaining the reason for the cancellation.- Returns:
- A
Completablethat, once it is subscribed, will attempt to cancel all active requests on this connection.
-
cancelAllRequestsExcept
public Completable cancelAllRequestsExcept(int msgId, boolean notifyClient, LocalizableMessage reason)
Returns aCompletablethat, once it is subscribed, will attempt to cancel all active requests on this connection that do not have the specified message ID.- Parameters:
msgId- The message ID of the request that should not be cancelled.notifyClient-trueif the client should receive a response for requests that were successfully cancelled.reason- A message explaining the reason for the cancellation.- Returns:
- A
Completablethat, once it is subscribed, will attempt to cancel all active requests on this connection that do not have the specified message ID.
-
addPendingRequest
public boolean addPendingRequest(RequestContext requestContext)
Adds the request context to the set of request context associated to requests which are in progress for this connection.- Parameters:
requestContext- The request context to add- Returns:
trueIf the request context has been added orfalseif a request context with the same message ID has already been registered.
-
removePendingRequest
public void removePendingRequest(int messageId)
Removes the request context from the set of in-progress request contexts.- Parameters:
messageId- The message ID identifying the request context to remove.
-
isIdle
public boolean isIdle()
Returns if the connection is idle.- Returns:
- if the connection is idle
-
getLastCompletionTime
public long getLastCompletionTime()
Returns the time the last request on the connection was completed.- Returns:
- the time the last request on the connection was completed
-
-