throw new ParsingException("Unknown simple interface criteria type " + node.asString());
}
}
private static InterfaceCriteria parsePropertyCriteria(ModelNode node) {
Property prop = node.asProperty();
String propName = prop.getName();
final Element element = Element.forName(propName);
switch (element) {
case ANY: {
return parseCompoundCriteria(prop.getValue(), true);
}
case NOT: {
return parseCompoundCriteria(prop.getValue(), true);
}
case INET_ADDRESS: {
checkStringType(prop.getValue(), element.getLocalName());
return new InetAddressMatchInterfaceCriteria(prop.getValue().asString());
}
case LOOPBACK_ADDRESS: {
checkStringType(prop.getValue(), element.getLocalName());
return new LoopbackAddressInterfaceCriteria(prop.getValue().asString());
}
case NIC: {
checkStringType(prop.getValue(), element.getLocalName());
return new NicInterfaceCriteria(prop.getValue().asString());
}
case NIC_MATCH: {
checkStringType(prop.getValue(), element.getLocalName());
try {
Pattern pattern = Pattern.compile(prop.getValue().asString());
return new NicMatchInterfaceCriteria(pattern);
} catch (PatternSyntaxException e) {
throw new ParsingException(String.format("Invalid pattern %s for interface criteria %s", prop.getValue().asString(), element.getLocalName()));
}
}
case SUBNET_MATCH: {
String value;
String[] split = null;
try {
value = prop.getValue().asString();
split = value.split("/");
if (split.length != 2) {
throw new ParsingException(String.format("Invalid 'value' %s -- must be of the form address/mask", value));
}
// todo - possible DNS hit here