Class RequestAuditContext

java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.services.context.RequestAuditContext
All Implemented Interfaces:
Context

public class RequestAuditContext extends AbstractContext
A context for audit information for an incoming request.
  • Constructor Details

    • RequestAuditContext

      @Deprecated(since="26.2.0") public RequestAuditContext(Context parent)
      Deprecated.
      Prefer using RequestAuditContext(Context, Instant) not to rely on the system clock.
      Constructs a new context using the specified parent and the current time as the request received time.
      Parameters:
      parent - The parent context.
    • RequestAuditContext

      @Deprecated public RequestAuditContext(Context parent, Clock clock)
      Deprecated.
      Constructs a new context using the specified parent and the current time as the request received time.
      Parameters:
      parent - The parent context.
      clock - The instance of Clock to use.
    • RequestAuditContext

      public RequestAuditContext(Context parent, Instant requestReceivedTime)
      Constructs a new context using the specified parent and the current time as the request received time.
      Parameters:
      parent - The parent context.
      requestReceivedTime - The time at which the request was received.
    • RequestAuditContext

      public RequestAuditContext(JsonValue savedContext, ClassLoader classLoader)
      Restores a saved context.
      Parameters:
      savedContext - The saved state.
      classLoader - The ClassLoader to use.
  • Method Details

    • addTrackingId

      public void addTrackingId(String trackingId)
      Adds a tracking ID to the context. If already present, it will be ignored. Note that trackingIds will not be serialized if empty.
      Parameters:
      trackingId - The tracking ID to add.
    • getTrackingIds

      public Set<String> getTrackingIds()
      Get all tracking IDs stored in this context. This is an unmodifiable collection.
      Returns:
      The tracking IDs stored in this context.
    • setUserId

      public void setUserId(String userId)
      Set the user ID on the context. This supports setting the user ID once it is known to the system, for example after sign-on. Note that userId will not be serialized if null.
      Parameters:
      userId - the user ID
    • getUserId

      public String getUserId()
      Get the user ID stored in this context.
      Returns:
      the user ID
    • toJsonValue

      public JsonValue toJsonValue()
      Description copied from interface: Context
      Return this Context as a JsonValue (for persistence).
      Specified by:
      toJsonValue in interface Context
      Overrides:
      toJsonValue in class AbstractContext
      Returns:
      the Context data as a JsonValue.
    • getRequestReceivedTime

      public long getRequestReceivedTime()
      Get the time in milliseconds since the epoch that the request was received.
      Returns:
      The request received time.