public static void removeEntries()

in src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java [287:316]


    public static void removeEntries(
            @NotNull SessionContext context, @NotNull List<String> principals, @NotNull List<String> paths)
            throws RepositoryException {
        Set<String> principalNames = new HashSet<>(principals);
        AccessControlManager acMgr = context.getAccessControlManager();
        for (String jcrPath : getJcrPaths(context.getSession(), paths)) {
            if (!isValidPath(context.getSession(), jcrPath)) {
                LOG.info("Cannot remove access control entries on non-existent path {}", jcrPath);
            } else {
                JackrabbitAccessControlList acl = getAccessControlList(acMgr, jcrPath, false);
                if (acl != null) {
                    boolean modified = false;
                    for (AccessControlEntry ace : acl.getAccessControlEntries()) {
                        if (principalNames.contains(ace.getPrincipal().getName())) {
                            acl.removeAccessControlEntry(ace);
                            modified = true;
                        }
                    }
                    if (modified) {
                        acMgr.setPolicy(jcrPath, acl);
                    }
                } else {
                    LOG.info(
                            "Cannot remove access control entries for principal(s) {}. No ACL at {}",
                            principalNames,
                            jcrPath);
                }
            }
        }
    }