Class JdbcAuditEventHandler
- All Implemented Interfaces:
AuditEventHandler
AuditEventHandler
to write AuditEvent
s to a JDBC repository.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name used for an H2 database.static final String
The name used for a MySQL database.static final String
The name used for an Oracle database.static final String
The name used for a Postgres database.Fields inherited from class org.forgerock.audit.events.handlers.AuditEventHandlerBase
eventTopicsMetaData
-
Constructor Summary
ConstructorDescriptionJdbcAuditEventHandler
(JdbcAuditEventHandlerConfiguration configuration, EventTopicsMetaData eventTopicsMetaData, DataSource dataSource) Create a new JdbcAuditEventHandler instance. -
Method Summary
Modifier and TypeMethodDescriptionpublishEvent
(Context context, String topic, JsonValue event) Publishes an event to the provided topic.queryEvents
(Context context, String topic, QueryRequest queryRequest, QueryResourceHandler queryResourceHandler) Query some events from the provided topic.Reads an event with the provided resource id from the provided topic.void
shutdown()
Instruct this object to flush any buffers and close any open file handles or network connections.void
startup()
Instruct this object that it is safe to initialize file handles and network connections.Methods inherited from class org.forgerock.audit.events.handlers.AuditEventHandlerBase
getHandledTopics, getName, handleAction, isEnabled
-
Field Details
-
MYSQL
The name used for a MySQL database.- See Also:
-
H2
The name used for an H2 database.- See Also:
-
POSTGRES
The name used for a Postgres database.- See Also:
-
ORACLE
The name used for an Oracle database.- See Also:
-
-
Constructor Details
-
JdbcAuditEventHandler
@Inject public JdbcAuditEventHandler(JdbcAuditEventHandlerConfiguration configuration, EventTopicsMetaData eventTopicsMetaData, DataSource dataSource) Create a new JdbcAuditEventHandler instance.- Parameters:
configuration
- Configuration parameters that can be adjusted by system administrators.eventTopicsMetaData
- Meta-data for all audit event topics.dataSource
- Connection pool. If this parameter is null, then a Hikari data source will be created.
-
-
Method Details
-
startup
Instruct this object that it is safe to initialize file handles and network connections.Reconfiguration of the
AuditService
and its handlers is achieved by replacing rather than modifying the existing objects. Therefore, it's essential that the replacements do not perform any I/O that would interfere with the operation of the objects they are replacing until the old objects are shutdown. For example, when shutting down an old instance of a file-based AuditEventHandler, the old instance may need to flush buffers, apply file rotation or retention policies, or even add line or block signatures as part of tamper evident logging. Any of these operations could be broken if two handler instances are operating on the same set of files simultaneously.- Throws:
ResourceException
- if starting the AuditEventHandler fails
-
shutdown
Instruct this object to flush any buffers and close any open file handles or network connections.- Throws:
ResourceException
- if closing the AuditEventHandler fails
-
publishEvent
public Promise<ResourceResponse,ResourceException> publishEvent(Context context, String topic, JsonValue event) Publishes an event to the provided topic.Note for implementors, it is imperative that the supplied
event
is not modified in any way as this may cause undesirable behaviour where multiple handlers are configured. If theevent
must be modified, then make a copy of it and work with that.- Parameters:
context
- The context chain that initiated the event.topic
- The topic where to publish the event.event
- The event to publish - which should be considered immutable.- Returns:
- a promise with either a response or an exception
-
queryEvents
public Promise<QueryResponse,ResourceException> queryEvents(Context context, String topic, QueryRequest queryRequest, QueryResourceHandler queryResourceHandler) Query some events from the provided topic.- Parameters:
context
- The context chain that initiated the event.topic
- The topic on which query is performed.queryRequest
- The request with the query.queryResourceHandler
- The handler to process responses for the query.- Returns:
- a promise with either a response or an exception
-
readEvent
public Promise<ResourceResponse,ResourceException> readEvent(Context context, String topic, String resourceId) Description copied from interface:AuditEventHandler
Reads an event with the provided resource id from the provided topic.- Parameters:
context
- The context chain that initiated the event.topic
- The topic where event is read.resourceId
- The identifier of the event.- Returns:
- a promise with either a response or an exception
-