|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.catalina.valves.ValveBase org.apache.catalina.valves.RequestFilterValve
public abstract class RequestFilterValve
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:
process()
method.
This Valve may be attached to any Container, depending on the granularity of the filtering you wish to perform.
Field Summary | |
---|---|
protected java.lang.String |
allow
The comma-delimited set of allow expressions. |
protected java.util.regex.Pattern[] |
allows
The set of allow regular expressions we will evaluate. |
protected boolean |
allowValid
Helper variable to catch configuration errors. |
protected java.util.regex.Pattern[] |
denies
The set of deny regular expressions we will evaluate. |
protected java.lang.String |
deny
The comma-delimited set of deny expressions. |
protected int |
denyStatus
The HTTP response status code that is used when rejecting denied request. |
protected boolean |
denyValid
Helper variable to catch configuration errors. |
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component. |
protected static StringManager |
sm
The StringManager for this package. |
protected boolean |
started
Has this component been started yet? |
Fields inherited from class org.apache.catalina.valves.ValveBase |
---|
container, containerLog, controller, domain, mserver, next, oname |
Fields inherited from interface org.apache.catalina.Lifecycle |
---|
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT |
Constructor Summary | |
---|---|
RequestFilterValve()
|
Method Summary | |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component. |
protected void |
denyRequest(Request request,
Response response)
Reject the request that was denied by this valve. |
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. |
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 . |
int |
getDenyStatus()
Return response status code that is used to reject denied request. |
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. |
boolean |
isAllowed(java.lang.String property)
Perform the test implemented by this Valve, matching against the specified request property value. |
boolean |
isAllowValid()
Returns false if the last change to the
allow pattern did not apply successfully. |
boolean |
isDenyValid()
Returns false if the last change to the
deny pattern did not apply successfully. |
protected java.util.regex.Pattern[] |
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)
Perform the filtering that has been configured for this Valve, matching against the specified request property. |
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component. |
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. |
void |
setDenyStatus(int denyStatus)
Set response status code that is used to reject denied request. |
void |
start()
Prepare for the beginning of active use of the public methods of this component. |
void |
stop()
Gracefully terminate the active use of the public methods of this component. |
Methods inherited from class org.apache.catalina.valves.ValveBase |
---|
backgroundProcess, createObjectName, event, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static StringManager sm
protected volatile java.lang.String allow
allow
expressions.
protected volatile boolean allowValid
true
by default, but becomes false
if there was an attempt to assign an invalid value to the
allow
pattern.
protected volatile java.util.regex.Pattern[] allows
allow
regular expressions we will evaluate.
protected volatile java.util.regex.Pattern[] denies
deny
regular expressions we will evaluate.
protected volatile java.lang.String deny
deny
expressions.
protected volatile boolean denyValid
true
by default, but becomes false
if there was an attempt to assign an invalid value to the
deny
pattern.
protected int denyStatus
protected LifecycleSupport lifecycle
protected boolean started
Constructor Detail |
---|
public RequestFilterValve()
Method Detail |
---|
public java.lang.String getAllow()
allow
expressions
configured for this Valve, if any; otherwise, return null
.
public void setAllow(java.lang.String allow)
allow
expressions
configured for this Valve, if any.
allow
- The new set of allow expressionspublic java.lang.String getDeny()
deny
expressions
configured for this Valve, if any; otherwise, return null
.
public void setDeny(java.lang.String deny)
deny
expressions
configured for this Valve, if any.
deny
- The new set of deny expressionspublic final boolean isAllowValid()
false
if the last change to the
allow
pattern did not apply successfully. E.g.
if the pattern is syntactically invalid.
public final boolean isDenyValid()
false
if the last change to the
deny
pattern did not apply successfully. E.g.
if the pattern is syntactically invalid.
public int getDenyStatus()
public void setDenyStatus(int denyStatus)
public java.lang.String getInfo()
getInfo
in interface Valve
getInfo
in class ValveBase
public abstract void invoke(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException
process()
method to perform the actual filtering.
This method must be implemented by a concrete subclass.
invoke
in interface Valve
invoke
in class ValveBase
request
- The servlet request to be processedresponse
- The servlet response to be created
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet error occursprotected java.util.regex.Pattern[] precalculate(java.lang.String list)
null
or a comma-delimited
list of regular expression patterns.
list
- The comma-separated list of patterns
java.lang.IllegalArgumentException
- if one of the patterns has
invalid syntaxprotected void process(java.lang.String property, Request request, Response response) throws java.io.IOException, javax.servlet.ServletException
property
- The request property on which to filterrequest
- The servlet request to be processedresponse
- The servlet response to be processed
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet error occursprotected void denyRequest(Request request, Response response) throws java.io.IOException, javax.servlet.ServletException
request
- The servlet request to be processedresponse
- The servlet response to be processed
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet error occurspublic boolean isAllowed(java.lang.String property)
property
- The request property value on which to filterpublic void addLifecycleListener(LifecycleListener listener)
addLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners
in interface Lifecycle
public void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic void start() throws LifecycleException
configure()
,
and before any of the public methods of the component are utilized.
start
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedpublic void stop() throws LifecycleException
stop
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that needs to be reported
|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |