Apache Tomcat 7.0.22

org.apache.catalina.valves
Class RequestFilterValve

java.lang.Object
  extended by org.apache.catalina.util.LifecycleBase
      extended by org.apache.catalina.util.LifecycleMBeanBase
          extended by org.apache.catalina.valves.ValveBase
              extended by org.apache.catalina.valves.RequestFilterValve
All Implemented Interfaces:
javax.management.MBeanRegistration, Contained, Lifecycle, Valve
Direct Known Subclasses:
RemoteAddrValve, RemoteHostValve

public abstract class RequestFilterValve
extends ValveBase

Implementation of a Valve 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 the regular expressions configured for this Valve.

This valve is configured by setting the allow and/or deny properties to a regular expressions (in the syntax supported by Pattern) to which the appropriate request property will be compared. Evaluation proceeds as follows:

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

Version:
$Id: RequestFilterValve.java 1058357 2011-01-12 23:49:18Z markt $
Author:
Craig R. McClanahan

Field Summary
protected  java.util.regex.Pattern allow
          The regular expression used to test for allowed requests.
protected  java.util.regex.Pattern deny
          The regular expression used to test for denied requests.
 
Fields inherited from class org.apache.catalina.valves.ValveBase
asyncSupported, container, containerLog, next, sm
 
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserver
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Constructor Summary
RequestFilterValve()
           
 
Method Summary
 java.lang.String getAllow()
          Return the regular expression used to test for allowed requests for this Valve, if any; otherwise, return null.
 java.lang.String getDeny()
          Return the regular expression used to test for denied requests for this Valve, if any; otherwise, return null.
 java.lang.String getInfo()
          Return descriptive information about this Valve implementation.
abstract  void invoke(Request request, Response response)
          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.
protected  void process(java.lang.String property, Request request, Response response)
          Perform the filtering that has been configured for this Valve, matching against the specified request property.
 void setAllow(java.lang.String allow)
          Set the regular expression used to test for allowed requests for this Valve, if any.
 void setDeny(java.lang.String deny)
          Set the regular expression used to test for denied requests for this Valve, if any.
 
Methods inherited from class org.apache.catalina.valves.ValveBase
backgroundProcess, event, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, startInternal, stopInternal, toString
 
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
 
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allow

protected java.util.regex.Pattern allow
The regular expression used to test for allowed requests.


deny

protected java.util.regex.Pattern deny
The regular expression used to test for denied requests.

Constructor Detail

RequestFilterValve

public RequestFilterValve()
Method Detail

getAllow

public java.lang.String getAllow()
Return the regular expression used to test for allowed requests for this Valve, if any; otherwise, return null.


setAllow

public void setAllow(java.lang.String allow)
Set the regular expression used to test for allowed requests for this Valve, if any.

Parameters:
allow - The new allow expression

getDeny

public java.lang.String getDeny()
Return the regular expression used to test for denied requests for this Valve, if any; otherwise, return null.


setDeny

public void setDeny(java.lang.String deny)
Set the regular expression used to test for denied requests for this Valve, if any.

Parameters:
deny - The new deny expression

getInfo

public java.lang.String getInfo()
Return descriptive information about this Valve implementation.

Specified by:
getInfo in interface Valve
Overrides:
getInfo in class ValveBase

invoke

public abstract void invoke(Request request,
                            Response response)
                     throws java.io.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:
invoke in interface Valve
Specified by:
invoke in class ValveBase
Parameters:
request - The servlet request to be processed
response - The servlet response to be created
Throws:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet error occurs

process

protected void process(java.lang.String property,
                       Request request,
                       Response response)
                throws java.io.IOException,
                       ServletException
Perform the filtering that has been configured for this Valve, 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:
java.io.IOException - if an input/output error occurs
ServletException - if a servlet error occurs

Apache Tomcat 7.0.22

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