* to be filled with ACEs matching the principal names.
* @throws RepositoryException
*/
static void collectEntries(NodeImpl aclNode, Map princToEntries)
throws RepositoryException {
SessionImpl sImpl = (SessionImpl) aclNode.getSession();
PrincipalManager principalMgr = sImpl.getPrincipalManager();
AccessControlManager acMgr = sImpl.getAccessControlManager();
NodeIterator itr = aclNode.getNodes();
while (itr.hasNext()) {
NodeImpl aceNode = (NodeImpl) itr.nextNode();
String principalName = aceNode.getProperty(AccessControlConstants.P_PRINCIPAL_NAME).getString();
// only process aceNode if 'principalName' is contained in the given set
if (princToEntries.containsKey(principalName)) {
Principal princ = null;
if (principalMgr.hasPrincipal(principalName)) {
try {
princ = principalMgr.getPrincipal(principalName);
} catch (NoSuchPrincipalException e) {
// should not get here
}
}
if (princ == null) {
log.warn("Principal with name " + principalName + " unknown to PrincipalManager.");
princ = new PrincipalImpl(principalName);
}
Value[] privValues = aceNode.getProperty(AccessControlConstants.P_PRIVILEGES).getValues();
Privilege[] privs = new Privilege[privValues.length];
for (int i = 0; i < privValues.length; i++) {
privs[i] = acMgr.privilegeFromName(privValues[i].getString());
}
// create a new ACEImpl (omitting validation check)
Entry ace = new Entry(
princ,
privs,
aceNode.isNodeType(AccessControlConstants.NT_REP_GRANT_ACE),
sImpl.getValueFactory());
// add it to the proper list (e.g. separated by principals)
((List) princToEntries.get(principalName)).add(ace);
}
}
}