Interface AuditService
-
- All Superinterfaces:
RequestHandler
- All Known Implementing Classes:
AuditServiceProxy
public interface AuditService extends RequestHandler
CRESTRequestHandlerresponsible for storing and retrieving audit events.After construction, the AuditService will be in the 'STARTING' state until
startup()is called. When in the 'STARTING' state, a call to any method other thanstartup()will lead toServiceUnavailableException.After
startup()is called, assuming startup succeeds, the AuditService will then be in the 'RUNNING' state and further calls tostartup()will be ignored.Calling
shutdown()will put the AuditService into the 'SHUTDOWN' state; once shutdown, the AuditService will remain in this state and cannot be restarted. Further calls toshutdown()will be ignored. When in the 'SHUTDOWN' state, a call to any method other thanshutdown()will lead toServiceUnavailableException.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AuditServiceConfigurationgetConfig()Gets the AuditService configuration.Set<String>getKnownTopics()Returns the set of event topics (schemas) that theAuditServiceunderstands.AuditEventHandlergetRegisteredHandler(String handlerName)Returns the registered handler corresponding to provided name.Collection<AuditEventHandler>getRegisteredHandlers()Returns the registered handlers.Promise<ActionResponse,ResourceException>handleAction(org.forgerock.services.context.Context context, ActionRequest request)Audit service may support actions on the service itself or on handlers.Promise<ResourceResponse,ResourceException>handleCreate(org.forgerock.services.context.Context context, CreateRequest request)Propagates the audit event to theAuditEventHandlerobjects that have been registered for the audit event topic.Promise<ResourceResponse,ResourceException>handleDelete(org.forgerock.services.context.Context context, DeleteRequest request)Audit service does not support changing audit entries.Promise<ResourceResponse,ResourceException>handlePatch(org.forgerock.services.context.Context context, PatchRequest request)Audit service does not support changing audit entries.Promise<QueryResponse,ResourceException>handleQuery(org.forgerock.services.context.Context context, QueryRequest request, QueryResourceHandler handler)Performs the query on the specified object and returns the associated results.Promise<ResourceResponse,ResourceException>handleRead(org.forgerock.services.context.Context context, ReadRequest request)Gets an object from the audit logs by identifier.Promise<ResourceResponse,ResourceException>handleUpdate(org.forgerock.services.context.Context context, UpdateRequest request)Audit service does not support changing audit entries.booleanisAuditing(String topic)Returns whether or not events of the specified topic will be handled.booleanisRunning()Returnstrueif this object is running.voidshutdown()Closes thisAuditServiceand all itsAuditEventHandlers.voidstartup()Allows thisAuditServiceand all itsAuditEventHandlers to perform any initialization that would be unsafe to do if any other instance of theAuditServicewere still running.
-
-
-
Method Detail
-
handleRead
Promise<ResourceResponse,ResourceException> handleRead(org.forgerock.services.context.Context context, ReadRequest request)
Gets an object from the audit logs by identifier. The returned object is not validated against the current schema and may need processing to conform to an updated schema.The object will contain metadata properties, including object identifier
_id, and object version_revto enable optimistic concurrencyIf this
Reads a JSON resource, returning aAuditServicehas been closed, the returned promise will resolve to aServiceUnavailableException.Promisethat will be completed when the resource has been read.Read expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbidden.NotSupportedExceptionif the requested functionality is not implemented/supportedBadRequestExceptionif the passed identifier or filter is invalidNotFoundExceptionif the specified resource could not be found.
- Specified by:
handleReadin interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The read request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleCreate
Promise<ResourceResponse,ResourceException> handleCreate(org.forgerock.services.context.Context context, CreateRequest request)
Propagates the audit event to theAuditEventHandlerobjects that have been registered for the audit event topic.This method sets the
_idproperty to the assigned identifier for the object, and the_revproperty to the revised object version (For optimistic concurrency).If this
Adds a new JSON resource, returning aAuditServicehas been closed, the returned promise will resolve to aServiceUnavailableException.Promisethat will be completed when the resource has been added.Create expects failure exceptions as follows:
CreateNotSupportedExceptionif create is not implemented or supported by the RequestHandler.ForbiddenExceptionif access to the resource is forbidden.NotSupportedExceptionif the requested functionality is not implemented/supportedPreconditionFailedExceptionif a resource with the same ID already existsBadRequestExceptionif the passed identifier or value is invalidNotFoundExceptionif the specified id could not be resolved, for example when an intermediate resource in the hierarchy does not exist.
- Specified by:
handleCreatein interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The create request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleUpdate
Promise<ResourceResponse,ResourceException> handleUpdate(org.forgerock.services.context.Context context, UpdateRequest request)
Audit service does not support changing audit entries.The returned promise will resolve to a
NotSupportedException.- Specified by:
handleUpdatein interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The update request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleDelete
Promise<ResourceResponse,ResourceException> handleDelete(org.forgerock.services.context.Context context, DeleteRequest request)
Audit service does not support changing audit entries.The returned promise will resolve to a
NotSupportedException.- Specified by:
handleDeletein interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The delete request.- Returns:
- A
Promisecontaining the result of the operation.
-
handlePatch
Promise<ResourceResponse,ResourceException> handlePatch(org.forgerock.services.context.Context context, PatchRequest request)
Audit service does not support changing audit entries.The returned promise will resolve to a
NotSupportedException.- Specified by:
handlePatchin interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The patch request.- Returns:
- A
Promisecontaining the result of the operation.
-
handleQuery
Promise<QueryResponse,ResourceException> handleQuery(org.forgerock.services.context.Context context, QueryRequest request, QueryResourceHandler handler)
Performs the query on the specified object and returns the associated results.Queries are parametric; a set of named parameters is provided as the query criteria. The query result is a JSON object structure composed of basic Java types.
The returned map is structured as follow:- The top level map contains meta-data about the query, plus an entry with the actual result records.
- The
QueryConstantsdefines the map keys, including the result records (QUERY_RESULT)
If this
Searches for all JSON resources matching a user specified set of criteria, returning aAuditServicehas been closed, the returned promise will resolve to aServiceUnavailableException.Promisethat will be completed when the search has completed.Implementations must invoke
QueryResourceHandler.handleResource(ResourceResponse)for each resource which matches the query criteria. Once all matching resources have been returned implementations are required to return either aQueryResponseif the query has completed successfully, orResourceExceptionif the query did not complete successfully (even if some matching resources were returned).Query expects failure exceptions as follows:
ForbiddenExceptionif access to the resource is forbiddenNotSupportedExceptionif the requested functionality is not implemented/supportedBadRequestExceptionif the passed identifier, parameters or filter is invalidNotFoundExceptionif the specified resource could not be found
- Specified by:
handleQueryin interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The query request.handler- The query resource handler to be notified for each matching resource.- Returns:
- A
Promisecontaining the result of the operation.
-
handleAction
Promise<ActionResponse,ResourceException> handleAction(org.forgerock.services.context.Context context, ActionRequest request)
Audit service may support actions on the service itself or on handlers.One of the following paths format is expected:
[path-to-audit-service]?_action=XXX : call a global action on audit service [path-to-audit-service/[topic]?_action=XXX : call an action on audit service and a single topic [path-to-audit-service]?_action=XXX&handler=HHH : call on action on a specific handler [path-to-audit-service/[topic]?_action=XXX&handler=HHH : call on action on a specific handler and topic- Specified by:
handleActionin interfaceRequestHandler- Parameters:
context- The request server context, such as associated principal.request- The action request.- Returns:
- A
Promisecontaining the result of the operation.
-
getConfig
AuditServiceConfiguration getConfig() throws ServiceUnavailableException
Gets the AuditService configuration.- Returns:
- the audit service config
- Throws:
ServiceUnavailableException- if the AuditService has been closed.
-
getRegisteredHandler
AuditEventHandler getRegisteredHandler(String handlerName) throws ServiceUnavailableException
Returns the registered handler corresponding to provided name.- Parameters:
handlerName- Name of the registered handler to retrieve.- Returns:
- the handler, or
nullif no handler with the provided name was registered to the service. - Throws:
ServiceUnavailableException- if the AuditService has been closed.
-
getRegisteredHandlers
Collection<AuditEventHandler> getRegisteredHandlers() throws ServiceUnavailableException
Returns the registered handlers.- Returns:
- the handlers
- Throws:
ServiceUnavailableException- if the AuditService has been closed.
-
isAuditing
boolean isAuditing(String topic) throws ServiceUnavailableException
Returns whether or not events of the specified topic will be handled.- Parameters:
topic- Identifies a category of events to which handlers may or may not be registered.- Returns:
- whether handling of the specified topic is enabled.
- Throws:
ServiceUnavailableException- if the AuditService has been closed.
-
getKnownTopics
Set<String> getKnownTopics() throws ServiceUnavailableException
Returns the set of event topics (schemas) that theAuditServiceunderstands.- Returns:
- The set of event topics.
- Throws:
ServiceUnavailableException- if the AuditService has been closed.
-
startup
void startup() throws ServiceUnavailableExceptionAllows thisAuditServiceand all itsAuditEventHandlers to perform any initialization that would be unsafe to do if any other instance of theAuditServicewere still running.- Throws:
ServiceUnavailableException- if the AuditService has been closed.
-
shutdown
void shutdown()
Closes thisAuditServiceand all itsAuditEventHandlers.This ensures that any buffered are flushed and all file handles / network connections are closed.
Once
closed, any further calls to thisAuditServicewill throw, or return a promise that will resolve to,ServiceUnavailableException.
-
isRunning
boolean isRunning()
Returnstrueif this object is running.This object will be in a 'running' state if
startup()completed successfully andshutdown()has not yet been called.- Returns:
- true if this object is running; false otherwise.
-
-