Package org.forgerock.audit.events
Class AccessAuditEventBuilder<T extends AccessAuditEventBuilder<T>>
java.lang.Object
org.forgerock.audit.events.AuditEventBuilder<T>
org.forgerock.audit.events.AccessAuditEventBuilder<T>
- Type Parameters:
T- the type of the builder
public class AccessAuditEventBuilder<T extends AccessAuditEventBuilder<T>>
extends AuditEventBuilder<T>
Builder for audit access events.
This builder should not be used directly but be specialized for each product to allow to define new specific fields, e.g
class OpenProductAccessAuditEventBuilder<T extends OpenProductAccessAuditEventBuilder<T>>
extends AccessAuditEventBuilder<T> {
protected OpenProductAccessAuditEventBuilder(DnsUtils dnsUtils) {
super(dnsUtils);
}
public static <T> OpenProductAccessAuditEventBuilder<?> productAccessEvent() {
return new OpenProductAccessAuditEventBuilder(new DnsUtils());
}
public T someField(String v) {
jsonValue.put("someField", v);
return self();
}
...
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe status of the access request. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe client event payload field name.static final StringThe cookies event payload field name.static final StringThe protocol field CREST value.static final StringThe detail event payload field name.static final StringThe elapsed time event payload field name.static final StringThe elapsed time unit event payload field name.static final StringThe headers event payload field name.static final StringThe http event payload field name.static final StringThe IP event payload field name.static final StringThe method event payload field name.static final StringThe operation event payload field name.static final StringThe path event payload field name.static final StringThe port event payload field name.static final StringThe protocol event payload field name.static final StringThe query parameters event payload field name.static final StringThe request event payload field name.static final StringThe response event payload field name.static final StringThe secure event payload field name.static final StringThe server event payload field name.static final StringThe status event payload field name.static final StringThe status code event payload field name.Fields inherited from class org.forgerock.audit.events.AuditEventBuilder
EVENT_NAME, ISO_OFFSET_DATE_TIME_FORMAT, jsonValue, TIMESTAMP, TRACKING_IDS, TRANSACTION_ID, USER_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AccessAuditEventBuilder<?>Starts to build an audit access event.final TSets the provided client ip for the event.final TSets the provided client ip and port for the event.final TclientFromContext(org.forgerock.services.context.Context context) Sets client ip, port and host fromClientContext, if the providedContextcontains aClientContext.final TforContext(org.forgerock.services.context.Context context) Sets common fields from services contexts.final TforHttpRequest(org.forgerock.services.context.Context context, Request request) Sets common fields from CREST contexts and request.final ThttpFromContext(org.forgerock.services.context.Context context) Sets HTTP method, path, queryString and headers fromHttpContext, if the providedContextcontains aHttpContext.final ThttpRequest(boolean secure, String method, String path, Map<String, List<String>> queryParameters, Map<String, List<String>> headers) Sets the provided HTTP request fields for the event.final ThttpRequest(boolean secure, String method, String path, Map<String, List<String>> queryParameters, Map<String, List<String>> headers, Map<String, String> cookies) Sets the provided HTTP request fields for the event.final ThttpResponse(Map<String, List<String>> headers) Sets the provided HTTP fields for the event.protected booleanWhether the client.host should be looked up from client.ip.final TSets the provided request details for the event.final TSets the provided request details for the event.final TrequestFromCrestRequest(Request request) Sets request detail fromRequest.final Tresponse(AccessAuditEventBuilder.ResponseStatus status, String statusCode, long elapsedTime, TimeUnit elapsedTimeUnits) Sets the provided response for the event.final TresponseWithDetail(AccessAuditEventBuilder.ResponseStatus status, String statusCode, long elapsedTime, TimeUnit elapsedTimeUnits, JsonValue detail) Sets the provided response for the event, with an additional detail.final TSets the provided server values for the event.final TserverFromContext(org.forgerock.services.context.Context context) Sets the server fields for the event, if the providedContextcontains aClientContext..final TInstructs the builder to lookup client.host from client.ip when populating client details.Methods inherited from class org.forgerock.audit.events.AuditEventBuilder
eventName, requireField, self, setDefaults, timestamp, toEvent, trackingId, trackingIds, transactionId, transactionIdFromContext, userId, validate
-
Field Details
-
SERVER
The server event payload field name.- See Also:
-
CLIENT
The client event payload field name.- See Also:
-
IP
The IP event payload field name.- See Also:
-
PORT
The port event payload field name.- See Also:
-
REQUEST
The request event payload field name.- See Also:
-
PROTOCOL
The protocol event payload field name.- See Also:
-
OPERATION
The operation event payload field name.- See Also:
-
SECURE
The secure event payload field name.- See Also:
-
METHOD
The method event payload field name.- See Also:
-
DETAIL
The detail event payload field name.- See Also:
-
PATH
The path event payload field name.- See Also:
-
QUERY_PARAMETERS
The query parameters event payload field name.- See Also:
-
HEADERS
The headers event payload field name.- See Also:
-
HTTP
The http event payload field name.- See Also:
-
STATUS
The status event payload field name.- See Also:
-
STATUS_CODE
The status code event payload field name.- See Also:
-
ELAPSED_TIME
The elapsed time event payload field name.- See Also:
-
ELAPSED_TIME_UNITS
The elapsed time unit event payload field name.- See Also:
-
RESPONSE
The response event payload field name.- See Also:
-
COOKIES
The cookies event payload field name.- See Also:
-
CREST_PROTOCOL
The protocol field CREST value.- See Also:
-
-
Constructor Details
-
AccessAuditEventBuilder
public AccessAuditEventBuilder()
-
-
Method Details
-
accessEvent
Starts to build an audit access event.Note: it is preferable to use a specialized builder that allow to add fields specific to a product.
- Returns:
- an audit access event builder
-
withReverseDnsLookup
Instructs the builder to lookup client.host from client.ip when populating client details.- Returns:
- this builder
-
isReverseDnsLookupEnabled
protected boolean isReverseDnsLookupEnabled()Whether the client.host should be looked up from client.ip.- Returns:
- True if so.
-
server
Sets the provided server values for the event.- Parameters:
ip- the ip of the server.port- the port of the server.- Returns:
- this builder
-
client
Sets the provided client ip and port for the event.- Parameters:
ip- the ip of the client.port- the port of the client.- Returns:
- this builder
-
client
Sets the provided client ip for the event.- Parameters:
ip- the ip of the client.- Returns:
- this builder
-
request
Sets the provided request details for the event.- Parameters:
protocol- the type of request.operation- the type of operation (e.g. CREATE, READ, UPDATE, DELETE, PATCH, ACTION, or QUERY).- Returns:
- this builder
-
request
Sets the provided request details for the event.- Parameters:
protocol- the type of request.operation- the type of operation (e.g. CREATE, READ, UPDATE, DELETE, PATCH, ACTION, or QUERY).detail- additional details relating to the request (e.g. the ACTION name or summary of the payload).- Returns:
- this builder
-
httpRequest
public final T httpRequest(boolean secure, String method, String path, Map<String, List<String>> queryParameters, Map<String, List<String>> headers) Sets the provided HTTP request fields for the event.- Parameters:
secure- Was the request secure ?method- the HTTP method.path- the path of HTTP request.queryParameters- the query parameters of HTTP request.headers- the list of headers of HTTP request. The headers are optional.- Returns:
- this builder
-
httpRequest
public final T httpRequest(boolean secure, String method, String path, Map<String, List<String>> queryParameters, Map<String, List<String>> headers, Map<String, String> cookies) Sets the provided HTTP request fields for the event.- Parameters:
secure- Was the request secure ?method- the HTTP method.path- the path of HTTP request.queryParameters- the query parameters of HTTP request.headers- the list of headers of HTTP request. The headers are optional.cookies- the list of cookies of HTTP request. The cookies are optional.- Returns:
- this builder
-
httpResponse
Sets the provided HTTP fields for the event.- Parameters:
headers- the list of headers of HTTP response. The headers are optional.- Returns:
- this builder
-
response
public final T response(AccessAuditEventBuilder.ResponseStatus status, String statusCode, long elapsedTime, TimeUnit elapsedTimeUnits) Sets the provided response for the event.- Parameters:
status- the status of the operation.statusCode- the status code of the operation.elapsedTime- the execution time of the action.elapsedTimeUnits- the unit of measure for the execution time value.- Returns:
- this builder
-
responseWithDetail
public final T responseWithDetail(AccessAuditEventBuilder.ResponseStatus status, String statusCode, long elapsedTime, TimeUnit elapsedTimeUnits, JsonValue detail) Sets the provided response for the event, with an additional detail.- Parameters:
status- the status of the operation.statusCode- the status code of the operation.elapsedTime- the execution time of the action.elapsedTimeUnits- the unit of measure for the execution time value.detail- additional details relating to the response (e.g. failure description or summary of the payload).- Returns:
- this builder
-
clientFromContext
Sets client ip, port and host fromClientContext, if the providedContextcontains aClientContext.- Parameters:
context- The root CHF context.- Returns:
- this builder
-
serverFromContext
Sets the server fields for the event, if the providedContextcontains aClientContext..- Parameters:
context- the CREST context- Returns:
- this builder
-
httpFromContext
Sets HTTP method, path, queryString and headers fromHttpContext, if the providedContextcontains aHttpContext.- Parameters:
context- The CREST context.- Returns:
- this builder
-
requestFromCrestRequest
Sets request detail fromRequest.- Parameters:
request- The CREST request.- Returns:
- this builder
-
forContext
Sets common fields from services contexts.- Parameters:
context- The services context.- Returns:
- this builder
- See Also:
-
forHttpRequest
Sets common fields from CREST contexts and request.- Parameters:
context- The CREST context.request- The CREST request.- Returns:
- this builder
- See Also:
-