Class RestAuditLogger
- java.lang.Object
-
- org.linuxforhealth.fhir.server.util.RestAuditLogger
-
- Direct Known Subclasses:
EraseOperationAuditLogger
public class RestAuditLogger extends java.lang.Object
This class provides convenience methods for FHIR Rest services that need to write FHIR audit log entries.
-
-
Constructor Summary
Constructors Constructor Description RestAuditLogger()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static AuditLogEntry
initLogEntry(AuditLogEventType eventType)
Builds and returns an AuditLogEntry with the minimum required fields populated.static void
logBundle(javax.servlet.http.HttpServletRequest request, Bundle requestBundle, Bundle responseBundle, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'bundle' REST service invocation.static void
logConfig(java.lang.String configData)
Logs an Audit Log Entry for FHIR server configuration data.static void
logCreate(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'create' REST service invocation.static void
logDelete(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'delete' REST service invocation.static void
logHistory(javax.servlet.http.HttpServletRequest request, Bundle bundle, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'history' REST service invocation.static void
logMetadata(javax.servlet.http.HttpServletRequest request, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'metadata' REST service invocation.static void
logOperation(javax.servlet.http.HttpServletRequest request, java.lang.String operationName, java.lang.String resourceTypeName, java.lang.String logicalId, java.lang.String versionId, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for an 'operation' REST service invocation.static void
logPatch(javax.servlet.http.HttpServletRequest request, Resource oldResource, Resource updatedResource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for an 'patch' REST service invocation.static void
logRead(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'read' REST service invocation.static void
logSearch(javax.servlet.http.HttpServletRequest request, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> queryParms, Bundle bundle, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'search' REST service invocation.static void
logUpdate(javax.servlet.http.HttpServletRequest request, Resource oldResource, Resource updatedResource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for an 'update' REST service invocation.static void
logValidate(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'validate' REST service invocation.static void
logVersionRead(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for a 'version-read' REST service invocation.protected static AuditLogEntry
populateAuditLogEntry(AuditLogEntry entry, javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Populates the passed audit log entry, with attributes common to all REST services.
-
-
-
Method Detail
-
logCreate
public static void logCreate(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'create' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.resource
- The Resource object being created.startTime
- The start time of the create request execution.endTime
- The end time of the create request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logUpdate
public static void logUpdate(javax.servlet.http.HttpServletRequest request, Resource oldResource, Resource updatedResource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for an 'update' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.oldResource
- The previous version of the Resource, before it was updated.updatedResource
- The updated version of the Resource.startTime
- The start time of the update request execution.endTime
- The end time of the update request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logPatch
public static void logPatch(javax.servlet.http.HttpServletRequest request, Resource oldResource, Resource updatedResource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for an 'patch' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.oldResource
- The previous version of the Resource, before it was patched.updatedResource
- The patched version of the Resource.startTime
- The start time of the patch request execution.endTime
- The end time of the patch request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logRead
public static void logRead(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'read' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.resource
- The Resource object being read.startTime
- The start time of the read request execution.endTime
- The end time of the read request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logDelete
public static void logDelete(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'delete' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.resource
- The Resource object being deleted.startTime
- The start time of the read request execution.endTime
- The end time of the read request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logVersionRead
public static void logVersionRead(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'version-read' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.resource
- The Resource object being read.startTime
- The start time of the read request execution.endTime
- The end time of the read request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logHistory
public static void logHistory(javax.servlet.http.HttpServletRequest request, Bundle bundle, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'history' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.bundle
- The Bundle that is returned to the REST service caller.startTime
- The start time of the bundle request execution.endTime
- The end time of the bundle request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logValidate
public static void logValidate(javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'validate' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.resource
- The Resource object being validated.startTime
- The start time of the validate request execution.endTime
- The end time of the validate request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logBundle
public static void logBundle(javax.servlet.http.HttpServletRequest request, Bundle requestBundle, Bundle responseBundle, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'bundle' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.requestBundle
- The Bundle that contains the requests.responseBundle
- The Bundle that is returned to the REST service caller.startTime
- The start time of the bundle request execution.endTime
- The end time of the bundle request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logSearch
public static void logSearch(javax.servlet.http.HttpServletRequest request, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> queryParms, Bundle bundle, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'search' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.queryParms
- The query parameters passed to the search REST service.bundle
- The Bundle that is returned to the REST service caller.startTime
- The start time of the bundle request execution.endTime
- The end time of the bundle request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logMetadata
public static void logMetadata(javax.servlet.http.HttpServletRequest request, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus) throws java.lang.Exception
Builds an audit log entry for a 'metadata' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.startTime
- The start time of the metadata request execution.endTime
- The end time of the metadata request execution.responseStatus
- The response status.- Throws:
java.lang.Exception
-
logConfig
public static void logConfig(java.lang.String configData) throws java.lang.Exception
Logs an Audit Log Entry for FHIR server configuration data.- Parameters:
configData
- The configuration data to be saved in the audit log.- Throws:
java.lang.Exception
-
logOperation
public static void logOperation(javax.servlet.http.HttpServletRequest request, java.lang.String operationName, java.lang.String resourceTypeName, java.lang.String logicalId, java.lang.String versionId, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Builds an audit log entry for an 'operation' REST service invocation.- Parameters:
request
- The HttpServletRequest representation of the REST request.operationName
- The name of the operation being executed.resourceTypeName
- The name of the resource type that is the target of the operation.logicalId
- The logical id of the target resource.versionId
- The version id of the target resource.startTime
- The start time of the metadata request execution.endTime
- The end time of the metadata request execution.responseStatus
- The response status.
-
populateAuditLogEntry
protected static AuditLogEntry populateAuditLogEntry(AuditLogEntry entry, javax.servlet.http.HttpServletRequest request, Resource resource, java.util.Date startTime, java.util.Date endTime, javax.ws.rs.core.Response.Status responseStatus)
Populates the passed audit log entry, with attributes common to all REST services.- Parameters:
entry
- The AuditLogEntry to be populated.request
- The HttpServletRequest representation of the REST request.resource
- The Resource object.startTime
- The start time of the request execution.endTime
- The end time of the request execution.responseStatus
- The response status.- Returns:
- AuditLogEntry - an initialized audit log entry.
-
initLogEntry
protected static AuditLogEntry initLogEntry(AuditLogEventType eventType)
Builds and returns an AuditLogEntry with the minimum required fields populated.- Parameters:
eventType
- A valid type of audit log event- Returns:
- AuditLogEntry with the minimum required fields populated.
-
-