Class 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 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 the java.net.InetAddress associated with the remote client system.
        Returns:
        The java.net.InetAddress associated with the remote client system. It may be null if 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. If null, 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 a Single that, once it is subscribed, will attempt to cancel the specified request.
        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:
        A Single that, once it is subscribed, will attempt to cancel the specified request.
      • cancelAllRequests

        public Completable cancelAllRequests​(boolean notifyClient,
                                             LocalizableMessage reason)
        Returns a Completable that, once it is subscribed, will attempt to cancel all active requests on this connection.
        Parameters:
        notifyClient - true if the client should receive a response for requests that were successfully cancelled.
        reason - A message explaining the reason for the cancellation.
        Returns:
        A Completable that, 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 a Completable that, 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 - true if the client should receive a response for requests that were successfully cancelled.
        reason - A message explaining the reason for the cancellation.
        Returns:
        A Completable that, 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:
        true If the request context has been added or false if a request context with the same message ID has already been registered.
      • removePendingRequest

        public boolean 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.
        Returns:
        true if the message ID identified a registered request context, false otherwise.