Package org.forgerock.services.context
Class RequestAuditContext
java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.services.context.RequestAuditContext
- All Implemented Interfaces:
Context
A context for audit information for an incoming request.
-
Field Summary
Fields inherited from class org.forgerock.services.context.AbstractContext
data
-
Constructor Summary
ConstructorDescriptionRequestAuditContext
(JsonValue savedContext, ClassLoader classLoader) Restores a saved context.RequestAuditContext
(Context parent) Deprecated.RequestAuditContext
(Context parent, Clock clock) Deprecated.Prefer usingRequestAuditContext(Context, Instant)
.RequestAuditContext
(Context parent, Instant requestReceivedTime) Constructs a new context using the specified parent and the current time as the request received time. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTrackingId
(String trackingId) Adds a tracking ID to the context.long
Get the time in milliseconds since the epoch that the request was received.Get all tracking IDs stored in this context.Get the user ID stored in this context.void
Set the user ID on the context.Return this Context as a JsonValue (for persistence).Methods inherited from class org.forgerock.services.context.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toString
-
Constructor Details
-
RequestAuditContext
Deprecated.Prefer usingRequestAuditContext(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.Prefer usingRequestAuditContext(Context, Instant)
.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 ofClock
to use.
-
RequestAuditContext
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
Restores a saved context.- Parameters:
savedContext
- The saved state.classLoader
- TheClassLoader
to use.
-
-
Method Details
-
addTrackingId
Adds a tracking ID to the context. If already present, it will be ignored. Note thattrackingIds
will not be serialized if empty.- Parameters:
trackingId
- The tracking ID to add.
-
getTrackingIds
Get all tracking IDs stored in this context. This is an unmodifiable collection.- Returns:
- The tracking IDs stored in this context.
-
setUserId
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 thatuserId
will not be serialized ifnull
.- Parameters:
userId
- the user ID
-
getUserId
Get the user ID stored in this context.- Returns:
- the user ID
-
toJsonValue
Description copied from interface:Context
Return this Context as a JsonValue (for persistence).- Specified by:
toJsonValue
in interfaceContext
- Overrides:
toJsonValue
in classAbstractContext
- 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.
-
RequestAuditContext(Context, Instant)
not to rely on the system clock.