org.jwall.web.audit.io
Class ConcurrentAuditWriter

java.lang.Object
  extended by org.jwall.web.audit.io.ConcurrentAuditWriter
All Implemented Interfaces:
AuditEventWriter

public class ConcurrentAuditWriter
extends java.lang.Object
implements AuditEventWriter

This class implements a simple writer that writes audit-events in the concurrent log format of modsecurity. It can be used with the AuditLogger tool to create concurrent audit-logs. It can also be used to convert serial auditlogs into the concurrent log format.

Author:
Christian Bockermann <chris@jwall.org>

Field Summary
static java.text.SimpleDateFormat DATE_FORMAT
           
static java.text.SimpleDateFormat DIR_FORMAT
           
 
Constructor Summary
ConcurrentAuditWriter(java.io.File baseDir)
          Create a new audit-writer that writes events into sub-directories below the given directory base according to their date.
ConcurrentAuditWriter(java.io.File baseDir, java.io.File indexFile)
          This constructor creates a new instance of the class that writes all events to files within the given directory baseDir.
 
Method Summary
static java.lang.String createSummary(AuditEvent evt)
          This method creates a summary-string from the given audit-event.
 void writeEvent(AuditEvent evt)
          This method writes the given audit-event evt to a file, whose name is deducted from the creation time of the event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_FORMAT

public static java.text.SimpleDateFormat DIR_FORMAT

DATE_FORMAT

public static java.text.SimpleDateFormat DATE_FORMAT
Constructor Detail

ConcurrentAuditWriter

public ConcurrentAuditWriter(java.io.File baseDir,
                             java.io.File indexFile)
                      throws java.io.IOException
This constructor creates a new instance of the class that writes all events to files within the given directory baseDir. In addition to that, the writer creates summary-entries in an index-file denoted by indexFile.

Parameters:
baseDir - The directory where to store the event-data files.
indexFile - The file to which the index-entries are appended.
Throws:
java.io.IOException - In case an IO-error occurs (file-permissions, etc.)

ConcurrentAuditWriter

public ConcurrentAuditWriter(java.io.File baseDir)
                      throws java.io.IOException
Create a new audit-writer that writes events into sub-directories below the given directory base according to their date. The index-file is assumed to be the file index within that directory.

Parameters:
baseDir - The base directory where the audit-data files are stored.
Throws:
java.lang.Exception - In case base is not a directory or cannot be created or is not writable.
java.io.IOException
Method Detail

writeEvent

public void writeEvent(AuditEvent evt)
                throws java.io.IOException
This method writes the given audit-event evt to a file, whose name is deducted from the creation time of the event. The file is created relative to the base-directory given at construction-time of this writer-instance. Additionally a summary-entry will be created that is appended to the index-file.

Specified by:
writeEvent in interface AuditEventWriter
Parameters:
evt - The AuditEvent-instance to be written to disk.
Throws:
java.io.IOException

createSummary

public static java.lang.String createSummary(AuditEvent evt)
This method creates a summary-string from the given audit-event. The summary is used within the index-file.

Parameters:
evt - The event to create the summary from.
Returns:
A string, representing the summary of the event.