Class SessionContext

java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.http.session.SessionContext
All Implemented Interfaces:
Context

public final class SessionContext extends AbstractContext
A SessionContext is a mechanism for maintaining state between components when processing a successive requests from the same logical client or end-user. For example, a filter may store information about the end-user in the SessionContext which can then be accessed in subsequent filters and handlers in order to perform access control decisions, routing decisions, etc.

Unlike an AttributesContext, a SessionContext has a life-cycle that spans successive requests from the same client, although its content may be lost after periods of inactivity. The exact details of how a "session" is associated with a client, how it is persisted between requests, and if and when it is expired are the responsibility of the Session and AsyncSessionManager implementation.

Use an AttributesContext for transferring transient state between components when processing a single request.

  • Constructor Details

    • SessionContext

      public SessionContext(Context parent, Session session)
      Constructs a new SessionContext.
      Parameters:
      parent - The parent Context.
      session - The HTTP Session.
    • SessionContext

      public SessionContext(JsonValue savedContext, ClassLoader classLoader)
      Restore from JSON representation.
      Parameters:
      savedContext - The JSON representation from which this context's attributes should be parsed.
      classLoader - The ClassLoader which can properly resolve the persisted class-name.
  • Method Details

    • getSession

      public Session getSession()
      Returns the Session associated with the remote client.
      Returns:
      The Session associated with the remote client.
    • setSession

      public SessionContext setSession(Session session)
      Sets the Session associated with the remote client.
      Parameters:
      session - The session.
      Returns:
      This SessionContext.