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
FieldsModifier and TypeFieldDescriptionstatic final StringEvent name event payload field name.static final DateTimeFormatterISO 8601 date-time formatter '2011-12-03T10:15:30.000Z' specifically for UTC/GMT time zone.protected JsonValueRepresents the event as a JSON value.static final StringTimestamp event payload field name.static final StringTracking IDs event payload field name.static final StringTransaction ID event payload field name.static final StringUser ID event payload field name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal TSets the provided name for the event.protected voidrequireField(String rootFieldName) Helper method to be used when overridingvalidate().protected final Tself()Returns this object, as its actual type.protected voidCalled bytoEvent()to allow any unset fields to be given their default value.final Ttimestamp(long timestamp) Sets the provided time stamp for the event.final AuditEventtoEvent()Generates the audit event.final TtrackingId(String trackingIdValue) Adds an entry to trackingIds for the event.final TtrackingIds(Set<String> trackingIdValues) Adds the specified entries to trackingIds for the event.final TtransactionId(String id) Sets the provided transactionId for the event.final TtransactionIdFromContext(org.forgerock.services.context.Context context) Sets transactionId from ID ofTransactionIdContext, if the providedContextcontains aTransactionIdContext.final TSets the provided userId for the event.protected voidvalidate()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 providedContextcontains aTransactionIdContext.- Parameters:
context- The CREST context.- Returns:
- this builder
-