/**
* @see org.apache.james.jspf.terms.GenericMechanism#config(Configuration)
*/
public synchronized void config(Configuration params) throws PermErrorException {
if (params.groupCount() == 0) {
throw new PermErrorException("Missing ip");
}
String ipString = params.group(1);
if (!isValidAddress(ipString)) {
throw new PermErrorException("Invalid Address: " + ipString);
}
int maskLength = getMaxCidr();
if (params.groupCount() >= 2 && params.group(2) != null) {
String maskLengthString = params.group(2);
maskLength = Integer.parseInt(maskLengthString);
if (maskLength > getMaxCidr() || (maskLengthString.length() > 1 && maskLengthString.startsWith("0"))) {
throw new PermErrorException("Invalid CIDR: " + maskLengthString);
}
}
ip = IPAddr.getAddress(ipString, maskLength);
}