Class AccessAuditEventBuilder<T extends 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();
        }
    
        ...
     }
     
     
    • Constructor Detail

      • AccessAuditEventBuilder

        public AccessAuditEventBuilder()
    • Method Detail

      • accessEvent

        public static AccessAuditEventBuilder<?> 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

        public final T 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

        public final T server​(String ip,
                              int port)
        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

        public final T client​(String ip,
                              int port)
        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

        public final T client​(String ip)
        Sets the provided client ip for the event.
        Parameters:
        ip - the ip of the client.
        Returns:
        this builder
      • request

        public final T request​(String protocol,
                               String operation)
        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

        public final T request​(String protocol,
                               String operation,
                               JsonValue detail)
        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

        public final T httpResponse​(Map<String,​List<String>> headers)
        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

        public final T clientFromContext​(org.forgerock.services.context.Context context)
        Sets client ip, port and host from ClientContext, if the provided Context contains a ClientContext.
        Parameters:
        context - The root CHF context.
        Returns:
        this builder
      • serverFromContext

        public final T serverFromContext​(org.forgerock.services.context.Context context)
        Sets the server fields for the event, if the provided Context contains a ClientContext..
        Parameters:
        context - the CREST context
        Returns:
        this builder
      • httpFromContext

        public final T httpFromContext​(org.forgerock.services.context.Context context)
        Sets HTTP method, path, queryString and headers from HttpContext, if the provided Context contains a HttpContext.
        Parameters:
        context - The CREST context.
        Returns:
        this builder
      • requestFromCrestRequest

        public final T requestFromCrestRequest​(Request request)
        Sets request detail from Request.
        Parameters:
        request - The CREST request.
        Returns:
        this builder