Package org.forgerock.audit.events
Class AuditEventBuilder<T extends AuditEventBuilder<T>>
java.lang.Object
org.forgerock.audit.events.AuditEventBuilder<T>
- Type Parameters:
T
- the type of the builder
- Direct Known Subclasses:
AccessAuditEventBuilder
,ActivityAuditEventBuilder
,AuthenticationAuditEventBuilder
,ConfigAuditEventBuilder
Root builder for all audit events.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Event name event payload field name.static final DateTimeFormatter
ISO 8601 date-time formatter '2011-12-03T10:15:30.000Z' specifically for UTC/GMT time zone.protected JsonValue
Represents the event as a JSON value.static final String
Timestamp event payload field name.static final String
Tracking IDs event payload field name.static final String
Transaction ID event payload field name.static final String
User ID event payload field name. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal T
Sets the provided name for the event.protected void
requireField
(String rootFieldName) Helper method to be used when overridingvalidate()
.protected final T
self()
Returns this object, as its actual type.protected void
Called bytoEvent()
to allow any unset fields to be given their default value.final T
timestamp
(long timestamp) Sets the provided time stamp for the event.final AuditEvent
toEvent()
Generates the audit event.final T
trackingId
(String trackingIdValue) Adds an entry to trackingIds for the event.final T
trackingIds
(Set<String> trackingIdValues) Adds the specified entries to trackingIds for the event.final T
transactionId
(String id) Sets the provided transactionId for the event.final T
transactionIdFromContext
(Context context) Sets transactionId from ID ofTransactionIdContext
, if the providedContext
contains aTransactionIdContext
.final T
Sets the provided userId for the event.protected void
validate()
Called bytoEvent()
to ensure that the audit event will be created in a valid state.
-
Field Details
-
EVENT_NAME
Event name event payload field name.- See Also:
-
TIMESTAMP
Timestamp event payload field name.- See Also:
-
TRANSACTION_ID
Transaction ID event payload field name.- See Also:
-
USER_ID
User ID event payload field name.- See Also:
-
TRACKING_IDS
Tracking IDs event payload field name.- See Also:
-
ISO_OFFSET_DATE_TIME_FORMAT
ISO 8601 date-time formatter '2011-12-03T10:15:30.000Z' specifically for UTC/GMT time zone. -
jsonValue
Represents the event as a JSON value.
-
-
Constructor Details
-
AuditEventBuilder
protected AuditEventBuilder()Creates the builder.
-
-
Method Details
-
self
Returns this object, as its actual type.- Returns:
- this object
-
toEvent
Generates the audit event. As a side-effect of calling this method, this builder is reset to its starting state.- Returns:
- the audit event
-
setDefaults
protected void setDefaults()Called bytoEvent()
to allow any unset fields to be given their default value. When overriding this method, the super class implementation must be called. -
validate
protected void validate()Called bytoEvent()
to ensure that the audit event will be created in a valid state. When overriding this method, the super class implementation must be called.- Throws:
IllegalStateException
- if a required field has not been populated.
-
requireField
Helper method to be used when overridingvalidate()
.- Parameters:
rootFieldName
- The name of the field that must be populated.- Throws:
IllegalStateException
- if the required field has not been populated.
-
eventName
Sets the provided name for the event. An event's name will usually be of the form {product}-{component}-{operation}. For example, AM-SESSION-CREATED, AM-CREST-SUCCESSFUL, etc.- Parameters:
name
- the event's name.- Returns:
- this builder
-
timestamp
Sets the provided time stamp for the event.- Parameters:
timestamp
- the time stamp.- Returns:
- this builder
-
transactionId
Sets the provided transactionId for the event.- Parameters:
id
- the transaction id.- Returns:
- this builder
-
userId
Sets the provided userId for the event.- Parameters:
id
- the user id.- Returns:
- this builder
-
trackingId
Adds an entry to trackingIds for the event.- Parameters:
trackingIdValue
- the unique value associated with the object being tracked.- Returns:
- this builder
-
trackingIds
Adds the specified entries to trackingIds for the event.- Parameters:
trackingIdValues
- the set of trackingId entries to be recorded (seetrackingId(java.lang.String)
.- Returns:
- this builder
-
transactionIdFromContext
Sets transactionId from ID ofTransactionIdContext
, if the providedContext
contains aTransactionIdContext
.- Parameters:
context
- The CREST context.- Returns:
- this builder
-