shield: handle null tokens when parsing roles

The roles parsing does not currently handle null tokens since the YAML parser
was not emitting them. With the upgrade to Jackson 2.7.1, the parser is now
emitting the null token value.

Original commit: elastic/x-pack-elasticsearch@abcad633ad
This commit is contained in:
jaymode 2016-02-26 15:03:56 -05:00
parent 47f1c2daa5
commit 06fc60c2f6
1 changed files with 6 additions and 0 deletions

View File

@ -203,6 +203,8 @@ public class FileRolesStore extends AbstractLifecycleComponent<RolesStore> imple
if (!names.isEmpty()) {
name = new Privilege.Name(names);
}
} else if (token == XContentParser.Token.VALUE_NULL) {
continue;
} else {
logger.error("invalid role definition [{}] in roles file [{}]. [cluster] field value can either " +
"be a string or a list of strings, but [{}] was found instead. skipping role...",
@ -264,6 +266,8 @@ public class FileRolesStore extends AbstractLifecycleComponent<RolesStore> imple
} else {
fields = Collections.singletonList(field);
}
} else if (token == XContentParser.Token.VALUE_NULL) {
fields = Collections.emptyList();
}
} else if ("query".equals(currentFieldName)) {
if (token == XContentParser.Token.START_OBJECT) {
@ -320,6 +324,8 @@ public class FileRolesStore extends AbstractLifecycleComponent<RolesStore> imple
}
}
continue;
} else if (token == XContentParser.Token.VALUE_NULL) {
continue;
} else {
logger.error("invalid role definition [{}] in roles file [{}]. " +
"could not parse [{}] as index privileges. privilege lists must either " +