// TBD
// validate allow/deny IPs
if ((allow == null) || (allow.length() < 1)) {
if ((deny == null) || (deny.length() < 1)) {
errors.add("allow",
new ActionError("error.allow.deny.required"));
}
}
//}
try {
allows = ValveUtil.precalculate(allow);
} catch (IllegalArgumentException e) {
errors.add("allow", new ActionError("error.syntax"));
return errors;
}
try {
denies = ValveUtil.precalculate(deny);
} catch (IllegalArgumentException e) {
errors.add("allow", new ActionError("error.syntax"));
return errors;
}
String host = request.getRemoteHost();
// check for IP address also in case DNS is not configured
// to give a host name for the client machine
String ip = request.getRemoteAddr();
if (host == null) {
return errors;
}
for (int i = 0; i < denies.length; i++) {
if (denies[i].matcher(host).matches()) {
if (allows.length < 1) {
errors.add("deny",
new ActionError("error.denyHost"));
}
for (int j = 0; j < allows.length; j++) {
if (!allows[j].matcher(host).matches()) {
errors.add("deny",
new ActionError("error.denyHost"));
}
}
} else if (denies[i].matcher(ip).matches()) {
if (allows.length < 1) {
errors.add("deny",
new ActionError("error.denyHost"));
}
for (int j = 0; j < allows.length; j++) {
if (!allows[j].matcher(ip).matches()) {
errors.add("deny",
new ActionError("error.denyHost"));
}
}
}
}
boolean allowMatch = true;
if ((allows != null) && (allows.length > 0)) {
allowMatch = false;
}
for (int i = 0; i < allows.length; i++) {
if (allows[i].matcher(host).matches()) {
allowMatch = true;
}
}
if (!allowMatch) {
errors.add("allow", new ActionError("error.allowHost"));
}
return errors;
}