} else if (token == XContentParser.Token.END_OBJECT) {
if (currentPerm != null && perms.contains(currentPerm)) {
log.error("Duplicate permissions " + currentPerm);
throw new MalformedConfigurationException(
"Duplicate permissions found");
}
/*if (currentPerm != null && !currentPerm.isValid()) {
log.error("Perm not valid " + currentPerm);
throw new MalformedConfigurationException(
"Invalid permission found");
}*/
if (currentPerm != null) {
if(currentPerm.permLevel == null){
currentPerm.permLevel = getDefaultPermLevelForEvaluator();
}
perms.add(currentPerm);
currentPerm = null;
}
} else if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = this.parser.currentName();
} else if (token.isValue()) {
if ("hosts".equals(currentFieldName)) {
currentPerm.addInetAddress(this.parser.text());
}
if ("users".equals(currentFieldName)) {
currentPerm.addUser(this.parser.text());
}
if ("roles".equals(currentFieldName)) {
currentPerm.addRole(this.parser.text());
} else if ("indices".equals(currentFieldName)) {
currentPerm.addIndice(this.parser.text());
} else if ("types".equals(currentFieldName)) {
currentPerm.addType(this.parser.text());
} else if (permissionFieldName.equals(currentFieldName)) {
final String text = this.parser.text();
currentPerm.setPermLevel(this
.createFromString(text == null ? null : text
.trim()));
}
}
}
} catch (final Exception e) {
throw new MalformedConfigurationException(e);
} finally {
this.parser.close();
}
log.debug("Checking " + perms.size() + " perms");
T permLevel = null;
for (final Perm<T> p : perms) {
if (p.isDefault()) {
permLevel = p.permLevel;
if (log.isDebugEnabled()) {
log.debug("Default set to " + permLevel);
}
break;
}
}
if (permLevel == null) {
throw new MalformedConfigurationException(
"No default configuration found");
}
/*for (final Perm<T> p : perms) {