## org.apache.catalina.valves
Class RequestFilterValve

    java.lang.Object
      org.apache.catalina.valves.ValveBase
          org.apache.catalina.valves.RequestFilterValve

All Implemented Interfaces:
  Contained, 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 a set of regular expressions configured for this Valve.

This valve 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:

- The subclass extracts the request property to be filtered, and calls the common `process()` method.
- If there are any deny expressions configured, the property will be compared to each such expression. If a match is found, this request will be rejected with a "Forbidden" HTTP response.
- If there are any allow expressions configured, the property will be compared to each such expression. If a match is found, this request will be allowed to pass through to the next Valve in the current pipeline.
- If one or more deny expressions was specified but no allow expressions, allow this request to pass through (because none of the deny expressions matched it).
- The request will be rejected with a "Forbidden" HTTP response.

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

Version:
  $Revision: 1.6 $ $Date: 2004/08/26 21:43:51 $
Author:
  Craig R. McClanahan

Field Summary
`protected java.lang.String` `allow` The comma-delimited set of `allow` expressions.
`protected org.apache.regexp.RE[]` `allows` The set of `allow` regular expressions we will evaluate.
`protected org.apache.regexp.RE[]` `denies` The set of `deny` regular expressions we will evaluate.
`protected java.lang.String` `deny` The comma-delimited set of `deny` expressions.
`protected static StringManager` `sm` The StringManager for this package.

Fields inherited from class org.apache.catalina.valves.ValveBase
`container, debug`

Constructor Summary
`RequestFilterValve()`

Method Summary
`java.lang.String` `getAllow()` Return a comma-delimited set of the `allow` expressions configured for this Valve, if any; otherwise, return `null`.
`java.lang.String` `getDeny()` Return a comma-delimited set of the `deny` expressions configured 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, ValveContext context)` 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 org.apache.regexp.RE[]` `precalculate(java.lang.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(java.lang.String property, Request request, Response response, ValveContext context)` Perform the filtering that has been configured for this Valve, matching against the specified request property.
`void` `setAllow(java.lang.String allow)` Set the comma-delimited set of the `allow` expressions configured for this Valve, if any.
`void` `setDeny(java.lang.String deny)` Set the comma-delimited set of the `deny` expressions configured for this Valve, if any.

Methods inherited from class org.apache.catalina.valves.ValveBase
`getContainer, getDebug, setContainer, setDebug`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### allow

    protected java.lang.String allow

  The comma-delimited set of `allow` expressions.

### allows

    protected org.apache.regexp.RE[] allows

  The set of `allow` regular expressions we will evaluate.

### denies

    protected org.apache.regexp.RE[] denies

  The set of `deny` regular expressions we will evaluate.

### deny

    protected java.lang.String deny

  The comma-delimited set of `deny` expressions.

### sm

    protected static StringManager sm

  The StringManager for this package.

Constructor Detail

### RequestFilterValve

    public RequestFilterValve()

Method Detail

### getAllow

    public java.lang.String getAllow()

  Return a comma-delimited set of the `allow` expressions configured for this Valve, if any; otherwise, return `null`.

### setAllow

    public void setAllow(java.lang.String allow)

  Set the comma-delimited set of the `allow` expressions configured for this Valve, if any.

  Parameters:
    `allow` - The new set of allow expressions

### getDeny

    public java.lang.String getDeny()

  Return a comma-delimited set of the `deny` expressions configured for this Valve, if any; otherwise, return `null`.

### setDeny

    public void setDeny(java.lang.String deny)

  Set the comma-delimited set of the `deny` expressions configured for this Valve, if any.

  Parameters:
    `deny` - The new set of deny expressions

### 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,
                                ValveContext context)
                         throws java.io.IOException,
                                javax.servlet.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
    `context` - The valve context used to invoke the next valve in the current processing pipeline
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet error occurs

### precalculate

    protected org.apache.regexp.RE[] precalculate(java.lang.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:
    `java.lang.IllegalArgumentException` - if one of the patterns has invalid syntax

### process

    protected void process(java.lang.String property,
                           Request request,
                           Response response,
                           ValveContext context)
                    throws java.io.IOException,
                           javax.servlet.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
    `context` - The valve context used to invoke the next valve in the current processing pipeline
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet error occurs

Copyright ? 2000-2002 Apache Software Foundation. All Rights Reserved.