org.jwall.web.audit
Class AuditEventRegexpFilter

java.lang.Object
  extended by org.jwall.web.audit.AuditEventRegexpFilter
All Implemented Interfaces:
AuditEventFilter

public class AuditEventRegexpFilter
extends java.lang.Object
implements AuditEventFilter

This class resembles a flexible AuditEventFilter that uses regular expressions to match an AuditEvent object. It is intended to be an example-implementation of the AuditEventFilter interface, but may well suit for a lot of applications.

Author:
Christian Bockermann <chris@jwall.org>

Constructor Summary
AuditEventRegexpFilter(java.lang.String variable, java.lang.String regexp)
          Creates a filter that matches all audit-events which have a ModSecurity-variable variable that has a values matching regexp.
 
Method Summary
 java.lang.String filterCommand()
          The method should return a string that represents the instance of this filter.
 boolean isNegated()
          Returns true if the expression is negated, e.g. starts with a !
 boolean matches(AuditEvent e)
          This method returns true, if the filter matches the given event evt.
 java.lang.String toString()
          Returns a string with information about this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AuditEventRegexpFilter

public AuditEventRegexpFilter(java.lang.String variable,
                              java.lang.String regexp)
                       throws SyntaxException
Creates a filter that matches all audit-events which have a ModSecurity-variable variable that has a values matching regexp.

Parameters:
variable - The variable whose value is checked.
regexp - The regular expression that needs to be matched.
Throws:
SyntaxException - In case an unknown variable is specified (variable needs to be in ModSecurity.VARIABLES[]) or the regular expression failed to be parsed.
Method Detail

isNegated

public boolean isNegated()
Returns true if the expression is negated, e.g. starts with a !.

Returns:
Wether the filter-expression is negated.

matches

public boolean matches(AuditEvent e)
Description copied from interface: AuditEventFilter
This method returns true, if the filter matches the given event evt.

Specified by:
matches in interface AuditEventFilter
Parameters:
e - the event to match against
Returns:
true iff the event matches this filter

filterCommand

public java.lang.String filterCommand()
Description copied from interface: AuditEventFilter
The method should return a string that represents the instance of this filter. This can then be used to create a new instance from this string that behaves exactly as the filter that produced the string.

Specified by:
filterCommand in interface AuditEventFilter
Returns:
A string-representation of this filter.

toString

public java.lang.String toString()
Returns a string with information about this filter.

Overrides:
toString in class java.lang.Object
Returns:
Information about this filter as string.