| Method from org.apache.catalina.valves.RequestFilterValve Detail: |
public String getAllow() {
// ------------------------------------------------------------- Properties
return (this.allow);
}
Return a comma-delimited set of the allow expressions
configured for this Valve, if any; otherwise, return null. |
public String getDeny() {
return (this.deny);
}
Return a comma-delimited set of the deny expressions
configured for this Valve, if any; otherwise, return null. |
public String getInfo() {
return (info);
}
Return descriptive information about this Valve implementation. |
abstract public void invoke(Request request,
Response response) 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. |
protected Pattern[] precalculate(String list) {
if (list == null)
return (new Pattern[0]);
list = list.trim();
if (list.length() < 1)
return (new Pattern[0]);
list += ",";
ArrayList reList = new ArrayList();
while (list.length() > 0) {
int comma = list.indexOf(',");
if (comma < 0)
break;
String pattern = list.substring(0, comma).trim();
try {
reList.add(Pattern.compile(pattern));
} catch (PatternSyntaxException e) {
IllegalArgumentException iae = new IllegalArgumentException
(sm.getString("requestFilterValve.syntax", pattern));
iae.initCause(e);
throw iae;
}
list = list.substring(comma + 1);
}
Pattern reArray[] = new Pattern[reList.size()];
return ((Pattern[]) reList.toArray(reArray));
}
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,
Request request,
Response response) throws IOException, ServletException {
// Check the deny patterns, if any
for (int i = 0; i < denies.length; i++) {
if (denies[i].matcher(property).matches()) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
}
// Check the allow patterns, if any
for (int i = 0; i < allows.length; i++) {
if (allows[i].matcher(property).matches()) {
getNext().invoke(request, response);
return;
}
}
// Allow if denies specified but not allows
if ((denies.length > 0) && (allows.length == 0)) {
getNext().invoke(request, response);
return;
}
// Deny this request
response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
Perform the filtering that has been configured for this Valve, matching
against the specified request property. |
public void setAllow(String allow) {
this.allow = allow;
allows = precalculate(allow);
}
Set the comma-delimited set of the allow expressions
configured for this Valve, if any. |
public void setDeny(String deny) {
this.deny = deny;
denies = precalculate(deny);
}
Set the comma-delimited set of the deny expressions
configured for this Valve, if any. |