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 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 SimpleDateFormat DATE_FORMAT
           
static SimpleDateFormat DIR_FORMAT
           
 
Constructor Summary
ConcurrentAuditWriter(File baseDir)
          Create a new audit-writer that writes events into sub-directories below the given directory base according to their date.
ConcurrentAuditWriter(File baseDir, 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 String createSummary(AuditEvent evt)
          This method creates a summary-string from the given audit-event.
 File getDirectoryFor(Date date)
          This method creates the file-name for the given date and also creates the file itself and the corresponding subdirectories.
 File getFileFor(AuditEvent evt)
           
 File write(AuditEvent evt)
          This method writes the given audit-event evt to a file, whose name is deducted from the creation time of the event.
 void writeEvent(AuditEvent evt)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_FORMAT

public static final SimpleDateFormat DIR_FORMAT

DATE_FORMAT

public static final SimpleDateFormat DATE_FORMAT
Constructor Detail

ConcurrentAuditWriter

public ConcurrentAuditWriter(File baseDir,
                             File indexFile)
                      throws 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:
IOException - In case an IO-error occurs (file-permissions, etc.)

ConcurrentAuditWriter

public ConcurrentAuditWriter(File baseDir)
                      throws 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:
Exception - In case base is not a directory or cannot be created or is not writable.
IOException
Method Detail

write

public File write(AuditEvent evt)
           throws 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.

Parameters:
evt - The AuditEvent-instance to be written to disk.
Throws:
IOException

getFileFor

public File getFileFor(AuditEvent evt)
                throws IOException
Throws:
IOException

writeEvent

public void writeEvent(AuditEvent evt)
                throws IOException
Specified by:
writeEvent in interface AuditEventWriter
Throws:
IOException

getDirectoryFor

public File getDirectoryFor(Date date)
                     throws IOException
This method creates the file-name for the given date and also creates the file itself and the corresponding subdirectories.

Parameters:
date - The date of an event.
Returns:
A file, denoting the absolute path to the events data file.
Throws:
IOException - In case the file or any of the subdirectories cannot be created.

createSummary

public static 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.


Copyright © 2012 jwall.org. All Rights Reserved.