RoleAssignment.ManagementModel managementModel = new RoleAssignment.ManagementModel(role);
ModelNode assignmentNode = property.getValue();
if (assignmentNode.hasDefined("include")) {
List<Property> inclusions = assignmentNode.get("include").asPropertyList();
for (Property inclusion : inclusions) {
Principal principal = mapPrincipal(principals, inclusion.getValue());
if (principal != null) {
managementModel.include(principal);
}
}
if (managementModel.getIncludes().isEmpty()) {
// if the only inclusion was the local user, the list is empty and mapping can be skipped
add = false;
}
} else {
// don't add this model, but goon so that principals in "exclude" will get extracted
add = false;
}
if (assignmentNode.hasDefined("exclude")) {
List<Property> exclusions = assignmentNode.get("exclude").asPropertyList();
for (Property exclusion : exclusions) {
Principal principal = mapPrincipal(principals, exclusion.getValue());
if (principal != null && principal.getType() == USER) {
// exclude only users (see constraints)
managementModel.exclude(principal);
}
}
}