Apache Tomcat 7.0.4

org.apache.catalina.filters
Class RequestFilter

java.lang.Object
  extended by org.apache.catalina.filters.FilterBase
      extended by org.apache.catalina.filters.RequestFilter
All Implemented Interfaces:
Filter, CometFilter
Direct Known Subclasses:
RemoteAddrFilter, RemoteHostFilter

public abstract class RequestFilter
extends FilterBase
implements CometFilter

Implementation of a Filter that performs filtering based on comparing the appropriate request property (selected based on which subclass you choose to configure into your Container's pipeline) against a set of regular expressions configured for this Filter.

This filter is configured by setting the allow and/or deny properties to a comma-delimited list of regular expressions (in the syntax supported by the jakarta-regexp library) to which the appropriate request property will be compared. Evaluation proceeds as follows:

This Filter may be attached to any Container, depending on the granularity of the filtering you wish to perform.

Author:
Craig R. McClanahan

Field Summary
protected  String allow
          The comma-delimited set of allow expressions.
protected  Pattern[] allows
          The set of allow regular expressions we will evaluate.
protected  Pattern[] denies
          The set of deny regular expressions we will evaluate.
protected  String deny
          The comma-delimited set of deny expressions.
 
Fields inherited from class org.apache.catalina.filters.FilterBase
sm
 
Constructor Summary
RequestFilter()
           
 
Method Summary
abstract  void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          Extract the desired request property, and pass it (along with the specified request and response objects) to the protected process() method to perform the actual filtering.
 String getAllow()
          Return a comma-delimited set of the allow expressions configured for this Filter, if any; otherwise, return null.
 String getDeny()
          Return a comma-delimited set of the deny expressions configured for this Filter, if any; otherwise, return null.
protected  Pattern[] precalculate(String list)
          Return an array of regular expression objects initialized from the specified argument, which must be null or a comma-delimited list of regular expression patterns.
protected  void process(String property, ServletRequest request, ServletResponse response, FilterChain chain)
          Perform the filtering that has been configured for this Filter, matching against the specified request property.
protected  void processCometEvent(String property, CometEvent event, CometFilterChain chain)
          Perform the filtering that has been configured for this Filter, matching against the specified request property.
 void setAllow(String allow)
          Set the comma-delimited set of the allow expressions configured for this Filter, if any.
 void setDeny(String deny)
          Set the comma-delimited set of the deny expressions configured for this Filter, if any.
 
Methods inherited from class org.apache.catalina.filters.FilterBase
destroy, getLogger, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.catalina.comet.CometFilter
doFilterEvent
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 

Field Detail

allow

protected String allow
The comma-delimited set of allow expressions.


allows

protected Pattern[] allows
The set of allow regular expressions we will evaluate.


denies

protected Pattern[] denies
The set of deny regular expressions we will evaluate.


deny

protected String deny
The comma-delimited set of deny expressions.

Constructor Detail

RequestFilter

public RequestFilter()
Method Detail

getAllow

public String getAllow()
Return a comma-delimited set of the allow expressions configured for this Filter, if any; otherwise, return null.


setAllow

public void setAllow(String allow)
Set the comma-delimited set of the allow expressions configured for this Filter, if any.

Parameters:
allow - The new set of allow expressions

getDeny

public String getDeny()
Return a comma-delimited set of the deny expressions configured for this Filter, if any; otherwise, return null.


setDeny

public void setDeny(String deny)
Set the comma-delimited set of the deny expressions configured for this Filter, if any.

Parameters:
deny - The new set of deny expressions

doFilter

public abstract void doFilter(ServletRequest request,
                              ServletResponse response,
                              FilterChain chain)
                       throws IOException,
                              ServletException
Extract the desired request property, and pass it (along with the specified request and response objects) to the protected process() method to perform the actual filtering. This method must be implemented by a concrete subclass.

Specified by:
doFilter in interface Filter
Parameters:
request - The servlet request to be processed
response - The servlet response to be created
chain - The filter chain
Throws:
IOException - if an input/output error occurs
ServletException - if a servlet error occurs

precalculate

protected Pattern[] precalculate(String list)
Return an array of regular expression objects initialized from the specified argument, which must be null or a comma-delimited list of regular expression patterns.

Parameters:
list - The comma-separated list of patterns
Throws:
IllegalArgumentException - if one of the patterns has invalid syntax

process

protected void process(String property,
                       ServletRequest request,
                       ServletResponse response,
                       FilterChain chain)
                throws IOException,
                       ServletException
Perform the filtering that has been configured for this Filter, matching against the specified request property.

Parameters:
property - The request property on which to filter
request - The servlet request to be processed
response - The servlet response to be processed
Throws:
IOException - if an input/output error occurs
ServletException - if a servlet error occurs

processCometEvent

protected void processCometEvent(String property,
                                 CometEvent event,
                                 CometFilterChain chain)
                          throws IOException,
                                 ServletException
Perform the filtering that has been configured for this Filter, matching against the specified request property.

Parameters:
property - The property to check against the allow/deny rules
event - The comet event to be filtered
chain - The comet filter chain
Throws:
IOException - if an input/output error occurs
ServletException - if a servlet error occurs

Apache Tomcat 7.0.4

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.