public interface AuditService extends RequestHandler
RequestHandler
responsible 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 than startup()
will lead to
ServiceUnavailableException
.
After startup()
is called, assuming startup succeeds, the AuditService will then be in the
'RUNNING' state and further calls to startup()
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 to shutdown()
will be ignored. When in the 'SHUTDOWN' state, a call to any method other than shutdown()
will
lead to ServiceUnavailableException
.
Modifier and Type | Method and Description |
---|---|
AuditServiceConfiguration |
getConfig()
Gets the AuditService configuration.
|
Set<String> |
getKnownTopics()
Returns the set of event topics (schemas) that the
AuditService understands. |
AuditEventHandler |
getRegisteredHandler(String handlerName)
Returns the registered handler corresponding to provided name.
|
Collection<AuditEventHandler> |
getRegisteredHandlers()
Returns the registered handlers.
|
Promise<ActionResponse,ResourceException> |
handleAction(Context context,
ActionRequest request)
Audit service may support actions on the service itself or on handlers.
|
Promise<ResourceResponse,ResourceException> |
handleCreate(Context context,
CreateRequest request)
Propagates the audit event to the
AuditEventHandler objects that have been registered
for the audit event topic. |
Promise<ResourceResponse,ResourceException> |
handleDelete(Context context,
DeleteRequest request)
Audit service does not support changing audit entries.
|
Promise<ResourceResponse,ResourceException> |
handlePatch(Context context,
PatchRequest request)
Audit service does not support changing audit entries.
|
Promise<QueryResponse,ResourceException> |
handleQuery(Context context,
QueryRequest request,
QueryResourceHandler handler)
Performs the query on the specified object and returns the associated results.
|
Promise<ResourceResponse,ResourceException> |
handleRead(Context context,
ReadRequest request)
Gets an object from the audit logs by identifier.
|
Promise<ResourceResponse,ResourceException> |
handleUpdate(Context context,
UpdateRequest request)
Audit service does not support changing audit entries.
|
boolean |
isAuditing(String topic)
Returns whether or not events of the specified topic will be handled.
|
boolean |
isRunning()
Returns true if this object is running.
|
void |
shutdown()
Closes this
AuditService and all its AuditEventHandler s. |
void |
startup()
Allows this
AuditService and all its AuditEventHandler s to perform any initialization that
would be unsafe to do if any other instance of the AuditService were still running. |
Promise<ResourceResponse,ResourceException> handleRead(Context context, ReadRequest request)
The object will contain metadata properties, including object identifier _id
,
and object version _rev
to enable optimistic concurrency
If this AuditService
has been closed, the returned promise will resolve to a
ServiceUnavailableException
.
Promise
that will be
completed when the resource has been read.
Read expects failure exceptions as follows:
ForbiddenException
if access to the resource is forbidden.
NotSupportedException
if the requested functionality is not
implemented/supported
BadRequestException
if the passed identifier or filter is
invalid
NotFoundException
if the specified resource could not be
found.
handleRead
in interface RequestHandler
context
- The request server context, such as associated principal.request
- The read request.Promise
containing the result of the operation.Promise<ResourceResponse,ResourceException> handleCreate(Context context, CreateRequest request)
AuditEventHandler
objects that have been registered
for the audit event topic.
This method sets the _id
property to the assigned identifier for the object,
and the _rev
property to the revised object version (For optimistic concurrency).
If this AuditService
has been closed, the returned promise will resolve to a
ServiceUnavailableException
.
Promise
that will be
completed when the resource has been added.
Create expects failure exceptions as follows:
ForbiddenException
if access to the resource is forbidden.
NotSupportedException
if the requested functionality is not
implemented/supported
PreconditionFailedException
if a resource with the same ID
already exists
BadRequestException
if the passed identifier or value is
invalid
NotFoundException
if the specified id could not be resolved,
for example when an intermediate resource in the hierarchy does not
exist.
handleCreate
in interface RequestHandler
context
- The request server context, such as associated principal.request
- The create request.Promise
containing the result of the operation.Promise<ResourceResponse,ResourceException> handleUpdate(Context context, UpdateRequest request)
The returned promise will resolve to a NotSupportedException
.
handleUpdate
in interface RequestHandler
context
- The request server context, such as associated principal.request
- The update request.Promise
containing the result of the operation.Promise<ResourceResponse,ResourceException> handleDelete(Context context, DeleteRequest request)
The returned promise will resolve to a NotSupportedException
.
handleDelete
in interface RequestHandler
context
- The request server context, such as associated principal.request
- The delete request.Promise
containing the result of the operation.Promise<ResourceResponse,ResourceException> handlePatch(Context context, PatchRequest request)
The returned promise will resolve to a NotSupportedException
.
handlePatch
in interface RequestHandler
context
- The request server context, such as associated principal.request
- The patch request.Promise
containing the result of the operation.Promise<QueryResponse,ResourceException> handleQuery(Context context, QueryRequest request, QueryResourceHandler handler)
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:QueryConstants
defines the map keys, including the result records (QUERY_RESULT)
If this AuditService
has been closed, the returned promise will resolve to a
ServiceUnavailableException
.
Promise
that 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 a
QueryResponse
if the query has completed successfully, or
ResourceException
if the query did not complete successfully
(even if some matching resources were returned).
Query expects failure exceptions as follows:
ForbiddenException
if access to the resource is forbidden
NotSupportedException
if the requested functionality is not
implemented/supported
BadRequestException
if the passed identifier, parameters or
filter is invalid
NotFoundException
if the specified resource could not be
found
handleQuery
in interface RequestHandler
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.Promise
containing the result of the operation.Promise<ActionResponse,ResourceException> handleAction(Context context, ActionRequest request)
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
handleAction
in interface RequestHandler
context
- The request server context, such as associated principal.request
- The action request.Promise
containing the result of the operation.AuditServiceConfiguration getConfig() throws ServiceUnavailableException
ServiceUnavailableException
- if the AuditService has been closed.AuditEventHandler getRegisteredHandler(String handlerName) throws ServiceUnavailableException
handlerName
- Name of the registered handler to retrieve.null
if no handler with the provided name
was registered to the service.ServiceUnavailableException
- if the AuditService has been closed.Collection<AuditEventHandler> getRegisteredHandlers() throws ServiceUnavailableException
ServiceUnavailableException
- if the AuditService has been closed.boolean isAuditing(String topic) throws ServiceUnavailableException
topic
- Identifies a category of events to which handlers may or may not be registered.ServiceUnavailableException
- if the AuditService has been closed.Set<String> getKnownTopics() throws ServiceUnavailableException
AuditService
understands.ServiceUnavailableException
- if the AuditService has been closed.void startup() throws ServiceUnavailableException
AuditService
and all its AuditEventHandler
s to perform any initialization that
would be unsafe to do if any other instance of the AuditService
were still running.ServiceUnavailableException
- if the AuditService has been closed.void shutdown()
AuditService
and all its AuditEventHandler
s.
This ensures that any buffered are flushed and all file handles / network connections are closed.
Once closed
, any further calls to this AuditService
will throw, or return a promise
that will resolve to, ServiceUnavailableException
.
boolean isRunning()
This object will be in a 'running' state if startup()
completed successfully and shutdown()
has not yet been called.
Copyright 2011-2017 ForgeRock AS.