for (String name : newCustomPrivs.keySet()) {
boolean isAbstract = true;
String[] aggrNames = newCustomPrivs.get(name);
Privilege registered = privilegeManager.registerPrivilege(name, isAbstract, aggrNames);
// validate definition
Privilege privilege = privilegeManager.getPrivilege(name);
assertNotNull(privilege);
assertEquals(name, privilege.getName());
assertTrue(privilege.isAbstract());
assertEquals(0, privilege.getDeclaredAggregatePrivileges().length);
assertContainsDeclared(privilegeManager.getPrivilege(PrivilegeConstants.JCR_ALL), name);
}
Map<String, String[]> newAggregates = new HashMap<String, String[]>();
// a new aggregate of custom privileges
newAggregates.put("newA2", getAggregateNames("test:new", "new"));
// a new aggregate of custom and built-in privilege
newAggregates.put("newA1", getAggregateNames("new", PrivilegeConstants.JCR_READ));
// aggregating built-in privileges
newAggregates.put("aggrBuiltIn", getAggregateNames(PrivilegeConstants.JCR_MODIFY_PROPERTIES, PrivilegeConstants.JCR_READ));
for (String name : newAggregates.keySet()) {
boolean isAbstract = false;
String[] aggrNames = newAggregates.get(name);
privilegeManager.registerPrivilege(name, isAbstract, aggrNames);
Privilege p = privilegeManager.getPrivilege(name);
assertNotNull(p);
assertEquals(name, p.getName());
assertFalse(p.isAbstract());
for (String n : aggrNames) {
assertContainsDeclared(p, n);
}
assertContainsDeclared(privilegeManager.getPrivilege(PrivilegeConstants.JCR_ALL), name);