List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>();
for (String name : grantedPrivilegeNames) {
if (name.length() == 0) {
continue; //empty, skip it.
}
Privilege privilege = accessControlManager.privilegeFromName(name);
grantedPrivilegeList.add(privilege);
if (log.isDebugEnabled()) {
if (newPrivileges.length() > 0) {
newPrivileges.append(", "); //separate entries by commas
}
newPrivileges.append("granted=");
newPrivileges.append(privilege.getName());
}
}
if (grantedPrivilegeList.size() > 0) {
Principal principal = authorizable.getPrincipal();
updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()]));
}
//if the authorizable is a user (not a group) process any denied privileges
if (!authorizable.isGroup()) {
//add a fresh ACE with the denied privileges
List<Privilege> deniedPrivilegeList = new ArrayList<Privilege>();
for (String name : deniedPrivilegeNames) {
if (name.length() == 0) {
continue; //empty, skip it.
}
Privilege privilege = accessControlManager.privilegeFromName(name);
deniedPrivilegeList.add(privilege);
if (log.isDebugEnabled()) {
if (newPrivileges.length() > 0) {
newPrivileges.append(", "); //separate entries by commas
}
newPrivileges.append("denied=");
newPrivileges.append(privilege.getName());
}
}
if (deniedPrivilegeList.size() > 0) {
Principal principal = authorizable.getPrincipal();
AccessControlUtil.addEntry(updatedAcl, principal, deniedPrivilegeList.toArray(new Privilege[deniedPrivilegeList.size()]), false);