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
Modifier and TypeClassDescriptionstatic enum
The status of the access request. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The client event payload field name.static final String
The cookies event payload field name.static final String
The protocol field CREST value.static final String
The detail event payload field name.static final String
The elapsed time event payload field name.static final String
The elapsed time unit event payload field name.static final String
The headers event payload field name.static final String
The http event payload field name.static final String
The IP event payload field name.static final String
The method event payload field name.static final String
The operation event payload field name.static final String
The path event payload field name.static final String
The port event payload field name.static final String
The protocol event payload field name.static final String
The query parameters event payload field name.static final String
The request event payload field name.static final String
The response event payload field name.static final String
The secure event payload field name.static final String
The server event payload field name.static final String
The status event payload field name.static final String
The 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic AccessAuditEventBuilder<?>
Starts to build an audit access event.final T
Sets the provided client ip for the event.final T
Sets the provided client ip and port for the event.final T
clientFromContext
(Context context) Sets client ip, port and host fromClientContext
, if the providedContext
contains aClientContext
.final T
forContext
(Context context) Sets common fields from services contexts.final T
forHttpRequest
(Context context, Request request) Sets common fields from CREST contexts and request.final T
httpFromContext
(Context context) Sets HTTP method, path, queryString and headers fromHttpContext
, if the providedContext
contains aHttpContext
.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.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.final T
httpResponse
(Map<String, List<String>> headers) Sets the provided HTTP fields for the event.protected boolean
Whether the client.host should be looked up from client.ip.final T
Sets the provided request details for the event.final T
Sets the provided request details for the event.final T
requestFromCrestRequest
(Request request) Sets request detail fromRequest
.final T
response
(AccessAuditEventBuilder.ResponseStatus status, String statusCode, long elapsedTime, TimeUnit elapsedTimeUnits) Sets the provided response for the event.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.final T
Sets the provided server values for the event.final T
serverFromContext
(Context context) Sets the server fields for the event, if the providedContext
contains aClientContext
..final T
Instructs 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 providedContext
contains aClientContext
.- Parameters:
context
- The root CHF context.- Returns:
- this builder
-
serverFromContext
Sets the server fields for the event, if the providedContext
contains aClientContext
..- Parameters:
context
- the CREST context- Returns:
- this builder
-
httpFromContext
Sets HTTP method, path, queryString and headers fromHttpContext
, if the providedContext
contains 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:
-