org.iges.anagram.filter
Class AbuseFilter

java.lang.Object
  |
  +--org.iges.anagram.AbstractModule
        |
        +--org.iges.anagram.filter.Filter
              |
              +--org.iges.anagram.filter.AbuseFilter
All Implemented Interfaces:
Module

public class AbuseFilter
extends Filter

A filter that tracks the number of hits per hour for each IP that uses this server, and blocks requests that have exceeded the IP's abuse limit.


Nested Class Summary
protected  class AbuseFilter.HitLimiter
          Tracks hits/hour, and switches to a blocked state if the number exceeds a given threshold.
 
Field Summary
protected  long defaultHitLimit
           
protected  long defaultTimeout
           
 
Fields inherited from class org.iges.anagram.filter.Filter
enabled, filterName, moduleID, next
 
Fields inherited from class org.iges.anagram.AbstractModule
log, moduleName, parent, server
 
Constructor Summary
AbuseFilter()
           
 
Method Summary
protected  java.io.File blockFile(java.lang.String ip)
           
protected  void checkBlock(ClientRequest clientRequest, long now, long hitLimit)
           
 void configure(Setting setting)
          Configures the module according to the settings provided.
protected  void doFilter(ClientRequest clientRequest)
           
 java.lang.String getFilterName()
          The name of this filter.
protected  AbuseFilter.HitLimiter loadBlock(java.lang.String ip)
           
protected  void saveBlock(java.lang.String ip, AbuseFilter.HitLimiter limiter)
           
 
Methods inherited from class org.iges.anagram.filter.Filter
getModuleID, handle, isEnabled, setEnabled, setNext
 
Methods inherited from class org.iges.anagram.AbstractModule
configModule, debug, debug, error, fail, fail, fail, getModuleName, info, init, toString, verbose, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultHitLimit

protected long defaultHitLimit

defaultTimeout

protected long defaultTimeout
Constructor Detail

AbuseFilter

public AbuseFilter()
Method Detail

getFilterName

public java.lang.String getFilterName()
Description copied from class: Filter
The name of this filter. Used to build the module ID

Specified by:
getFilterName in class Filter

configure

public void configure(Setting setting)
               throws ConfigException
Description copied from class: AbstractModule
Configures the module according to the settings provided. The server supports dynamic reconfiguration. Thus this method may be called at any time in the life of the module. If the module cannot be reconfigured, it should throw an exception.

Specified by:
configure in interface Module
Overrides:
configure in class Filter
ConfigException

doFilter

protected void doFilter(ClientRequest clientRequest)
                 throws ModuleException
Specified by:
doFilter in class Filter
ModuleException

blockFile

protected java.io.File blockFile(java.lang.String ip)

loadBlock

protected AbuseFilter.HitLimiter loadBlock(java.lang.String ip)

saveBlock

protected void saveBlock(java.lang.String ip,
                         AbuseFilter.HitLimiter limiter)

checkBlock

protected void checkBlock(ClientRequest clientRequest,
                          long now,
                          long hitLimit)
                   throws ModuleException
ModuleException