public class AuditServiceProxy extends Object implements AuditService
setDelegate(AuditService).
Thread-safety is achieved by blocking proxied calls until the old AuditService has flushed all buffers
and closed any open file or network connections.| Modifier and Type | Field and Description |
|---|---|
static String |
ACTION_PARAM_TARGET_HANDLER
Parameter that may be used when using an action, to provide the name of the handler to use as a target.
|
| Constructor and Description |
|---|
AuditServiceProxy(AuditService delegate)
Create a new
AuditServiceProxy. |
| 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.
|
protected void |
obtainReadLock()
Obtain the read lock or block until it becomes available.
|
protected void |
obtainWriteLock()
Obtain the write lock or block until it becomes available.
|
protected void |
releaseReadLock()
Release the read lock.
|
protected void |
releaseWriteLock()
Release the write lock.
|
void |
setDelegate(AuditService newDelegate)
Sets the AuditService this object proxies.
|
void |
shutdown()
Closes this
AuditService and all its AuditEventHandlers. |
void |
startup()
Allows this
AuditService and all its AuditEventHandlers to perform any initialization that
would be unsafe to do if any other instance of the AuditService were still running. |
public static final String ACTION_PARAM_TARGET_HANDLER
public AuditServiceProxy(AuditService delegate)
AuditServiceProxy.delegate - The AuditService that this object should proxy.public void setDelegate(AuditService newDelegate) throws ServiceUnavailableException
newDelegate - A new AuditService instance with updated configuration.ServiceUnavailableException - If the new audit service cannot be started.public Promise<ResourceResponse,ResourceException> handleRead(Context context, ReadRequest request)
AuditService
The object will contain metadata properties, including object identifier _id,
and object version _rev to enable optimistic concurrency
AuditService has been closed, the returned promise will resolve to a
ServiceUnavailableException.
Reads a JSON resource, returning a 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 AuditServicehandleRead in interface RequestHandlercontext - The request server context, such as associated principal.request - The read request.Promise containing the result of the operation.public Promise<ResourceResponse,ResourceException> handleCreate(Context context, CreateRequest request)
AuditServiceAuditEventHandler 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).
AuditService has been closed, the returned promise will resolve to a
ServiceUnavailableException.
Adds a new JSON resource, returning a 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 AuditServicehandleCreate in interface RequestHandlercontext - The request server context, such as associated principal.request - The create request.Promise containing the result of the operation.public Promise<ResourceResponse,ResourceException> handleUpdate(Context context, UpdateRequest request)
AuditServiceNotSupportedException.handleUpdate in interface AuditServicehandleUpdate in interface RequestHandlercontext - The request server context, such as associated principal.request - The update request.Promise containing the result of the operation.public Promise<ResourceResponse,ResourceException> handleDelete(Context context, DeleteRequest request)
AuditServiceNotSupportedException.handleDelete in interface AuditServicehandleDelete in interface RequestHandlercontext - The request server context, such as associated principal.request - The delete request.Promise containing the result of the operation.public Promise<ResourceResponse,ResourceException> handlePatch(Context context, PatchRequest request)
AuditServiceNotSupportedException.handlePatch in interface AuditServicehandlePatch in interface RequestHandlercontext - The request server context, such as associated principal.request - The patch request.Promise containing the result of the operation.public Promise<QueryResponse,ResourceException> handleQuery(Context context, QueryRequest request, QueryResourceHandler handler)
AuditServiceQueries 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)
AuditService has been closed, the returned promise will resolve to a
ServiceUnavailableException.
Searches for all JSON resources matching a user specified set of
criteria, returning a 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 AuditServicehandleQuery in interface RequestHandlercontext - 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.public Promise<ActionResponse,ResourceException> handleAction(Context context, ActionRequest request)
AuditServiceOne 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 AuditServicehandleAction in interface RequestHandlercontext - The request server context, such as associated principal.request - The action request.Promise containing the result of the operation.public AuditServiceConfiguration getConfig() throws ServiceUnavailableException
AuditServicegetConfig in interface AuditServiceServiceUnavailableException - if the AuditService has been closed.public AuditEventHandler getRegisteredHandler(String handlerName) throws ServiceUnavailableException
AuditServicegetRegisteredHandler in interface AuditServicehandlerName - 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.public Collection<AuditEventHandler> getRegisteredHandlers() throws ServiceUnavailableException
AuditServicegetRegisteredHandlers in interface AuditServiceServiceUnavailableException - if the AuditService has been closed.public boolean isAuditing(String topic) throws ServiceUnavailableException
AuditServiceisAuditing in interface AuditServicetopic - Identifies a category of events to which handlers may or may not be registered.ServiceUnavailableException - if the AuditService has been closed.public Set<String> getKnownTopics() throws ServiceUnavailableException
AuditServiceAuditService understands.getKnownTopics in interface AuditServiceServiceUnavailableException - if the AuditService has been closed.public void shutdown()
AuditServiceAuditService and all its AuditEventHandlers.
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.shutdown in interface AuditServicepublic void startup()
throws ServiceUnavailableException
AuditServiceAuditService and all its AuditEventHandlers to perform any initialization that
would be unsafe to do if any other instance of the AuditService were still running.startup in interface AuditServiceServiceUnavailableException - if the AuditService has been closed.public boolean isRunning()
AuditServiceAuditService.startup() completed successfully and AuditService.shutdown()
has not yet been called.isRunning in interface AuditServiceprotected final void obtainReadLock()
IllegalStateException - If the current thread already holds the write lock.protected final void releaseReadLock()
protected final void obtainWriteLock()
protected final void releaseWriteLock()
Copyright © 2025 Open Identity Platform Community. All rights reserved.