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:
process() method.
As an option the valve can generate an invalid authenticate header instead of denying the request. This
can be combined with the context attribute preemptiveAuthentication="true" and an authenticator to force
authentication instead of denial.
This Valve may be attached to any Container, depending on the granularity of the filtering you wish to perform.
| Modifier and Type | Field and Description |
|---|---|
| private volatile boolean | addConnectorPort
Flag deciding whether we add the server connector port to the property compared in the filtering method. |
| protected volatile Pattern | allow
The regular expression used to test for allowed requests. |
| protected volatile boolean | allowValid
Helper variable to catch configuration errors. |
| protected volatile String | allowValue
The current allow configuration value that may or may not compile into a valid |
| protected volatile Pattern | deny
The regular expression used to test for denied requests. |
| protected int | denyStatus
The HTTP response status code that is used when rejecting denied request. |
| protected volatile boolean | denyValid
Helper variable to catch configuration errors. |
| protected volatile String | |
| private boolean | invalidAuthenticationWhenDeny
If |
| private volatile boolean | usePeerAddress
Flag deciding whether we use the connection peer address or the remote address. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | denyRequest(Request
The servlet request to be processed request, Response The servlet response to be processed response)Reject the request that was denied by this valve. |
| public boolean | Returns: true to add the connector portGet the flag deciding whether we add the server connector port to the property compared in the filtering method. |
| public String | Returns: the regular expressionReturn the regular expression used to test for allowed requests for this Valve, if any; otherwise, return
|
| public String | Returns: the regular expressionReturn the regular expression used to test for denied requests for this Valve, if any; otherwise, return
|
| public int | |
| public boolean | Returns: true if a deny is handled by setting an invalid auth header.
|
| protected abstract Log | |
| public boolean | Returns: true if we use the connection peer addressGet the flag deciding whether we use the connection peer address or the remote address. |
| protected void | initInternal()
Overrides org. Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method. |
| public abstract void | invoke(Request
The servlet request to be processed request, Response The servlet response to be created response)Redeclares org. Extract the desired request property, and pass it (along with the specified request and response objects) to the
protected |
| public boolean | |
| public final boolean | Returns: false if the current pattern is invalidReturns |
| public final boolean | Returns: false if the current pattern is invalidReturns |
| protected void | |
| public void | setAddConnectorPort(boolean
The new flag addConnectorPort)Set the flag deciding whether we add the server connector port to the property compared in the filtering method. |
| public void | |
| public void | |
| public void | setDenyStatus(int
The status code denyStatus)Set response status code that is used to reject denied request. |
| public void | setInvalidAuthenticationWhenDeny(boolean
true to handle a deny by setting an invalid auth headerSet invalidAuthenticationWhenDeny property. |
| public void | setUsePeerAddress(boolean
The new flag usePeerAddress)Set the flag deciding whether we use the connection peer address or the remote address. |
| protected void | startInternal()
Overrides org. Start this component and implement the requirements of
|
| addConnectorPort | back to summary |
|---|---|
| private volatile boolean addConnectorPort Flag deciding whether we add the server connector port to the property compared in the filtering method. The port will be appended using a ";" as a separator. | |
| allow | back to summary |
|---|---|
| protected volatile Pattern allow The regular expression used to test for allowed requests. | |
| allowValid | back to summary |
|---|---|
| protected volatile boolean allowValid Helper variable to catch configuration errors. It is | |
| allowValue | back to summary |
|---|---|
| protected volatile String allowValue The current allow configuration value that may or may not compile into a valid | |
| deny | back to summary |
|---|---|
| protected volatile Pattern deny The regular expression used to test for denied requests. | |
| denyStatus | back to summary |
|---|---|
| protected int denyStatus The HTTP response status code that is used when rejecting denied request. It is 403 by default, but may be changed to be 404. | |
| denyValid | back to summary |
|---|---|
| protected volatile boolean denyValid Helper variable to catch configuration errors. It is | |
| denyValue | back to summary |
|---|---|
| protected volatile String denyValue The current deny configuration value that may or may not compile into a valid | |
| invalidAuthenticationWhenDeny | back to summary |
|---|---|
| private boolean invalidAuthenticationWhenDeny
If | |
| usePeerAddress | back to summary |
|---|---|
| private volatile boolean usePeerAddress Flag deciding whether we use the connection peer address or the remote address. This makes a dfifference when using AJP or the RemoteIpValve. | |
| RequestFilterValve | back to summary |
|---|---|
| public RequestFilterValve() | |
| denyRequest | back to summary |
|---|---|
| protected void denyRequest(Request request, Response response) throws IOException, ServletException Reject the request that was denied by this valve.
If
| |
| getAddConnectorPort | back to summary |
|---|---|
| public boolean getAddConnectorPort() Get the flag deciding whether we add the server connector port to the property compared in the filtering method. The port will be appended using a ";" as a separator.
| |
| getAllow | back to summary |
|---|---|
| public String getAllow() Return the regular expression used to test for allowed requests for this Valve, if any; otherwise, return
| |
| getDeny | back to summary |
|---|---|
| public String getDeny() Return the regular expression used to test for denied requests for this Valve, if any; otherwise, return
| |
| getDenyStatus | back to summary |
|---|---|
public int getDenyStatus()
| |
| getInvalidAuthenticationWhenDeny | back to summary |
|---|---|
public boolean getInvalidAuthenticationWhenDeny()
| |
| getLog | back to summary |
|---|---|
| protected abstract Log getLog() | |
| getUsePeerAddress | back to summary |
|---|---|
| public boolean getUsePeerAddress() Get the flag deciding whether we use the connection peer address or the remote address. This makes a dfifference when using AJP or the RemoteIpValve.
| |
| initInternal | back to summary |
|---|---|
| protected void initInternal() throws LifecycleException Overrides org. Doc from org. Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.
| |
| invoke | back to summary |
|---|---|
| public abstract void invoke(Request request, Response response) throws IOException, ServletException Redeclares org. Extract the desired request property, and pass it (along with the specified request and response objects) to the
protected
| |
| isAllowed | back to summary |
|---|---|
| public boolean isAllowed(String property) Perform the test implemented by this Valve, matching against the specified request property value. This method is public so that it can be called through JMX, e.g. to test whether certain IP address is allowed or denied by the valve configuration.
| |
| isAllowValid | back to summary |
|---|---|
| public final boolean isAllowValid() Returns
| |
| isDenyValid | back to summary |
|---|---|
| public final boolean isDenyValid() Returns
| |
| process | back to summary |
|---|---|
| protected void process(String property, Request request, Response response) throws IOException, ServletException Perform the filtering that has been configured for this Valve, matching against the specified request property.
| |
| setAddConnectorPort | back to summary |
|---|---|
| public void setAddConnectorPort(boolean addConnectorPort) Set the flag deciding whether we add the server connector port to the property compared in the filtering method. The port will be appended using a ";" as a separator.
| |
| setAllow | back to summary |
|---|---|
| public void setAllow(String allow) Set the regular expression used to test for allowed requests for this Valve, if any.
| |
| setDeny | back to summary |
|---|---|
| public void setDeny(String deny) Set the regular expression used to test for denied requests for this Valve, if any.
| |
| setDenyStatus | back to summary |
|---|---|
| public void setDenyStatus(int denyStatus) Set response status code that is used to reject denied request.
| |
| setInvalidAuthenticationWhenDeny | back to summary |
|---|---|
| public void setInvalidAuthenticationWhenDeny(boolean value) Set invalidAuthenticationWhenDeny property.
| |
| setUsePeerAddress | back to summary |
|---|---|
| public void setUsePeerAddress(boolean usePeerAddress) Set the flag deciding whether we use the connection peer address or the remote address. This makes a dfifference when using AJP or the RemoteIpValve.
| |
| startInternal | back to summary |
|---|---|
| protected void startInternal() throws LifecycleException Overrides org. Doc from org. Start this component and implement the requirements of
| |