Search in sources :

Example 1 with ImmutableACL

use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ImmutableACL in project jackrabbit-oak by apache.

the class AccessControlManagerImpl method createACL.

@CheckForNull
private JackrabbitAccessControlList createACL(@Nullable String oakPath, @Nonnull Tree accessControlledTree, boolean isEffectivePolicy, @CheckForNull Predicate<ACE> predicate) throws RepositoryException {
    JackrabbitAccessControlList acl = null;
    String aclName = Util.getAclName(oakPath);
    if (accessControlledTree.exists() && Util.isAccessControlled(oakPath, accessControlledTree, ntMgr)) {
        Tree aclTree = accessControlledTree.getChild(aclName);
        if (aclTree.exists()) {
            List<ACE> entries = new ArrayList<ACE>();
            for (Tree child : aclTree.getChildren()) {
                if (Util.isACE(child, ntMgr)) {
                    ACE ace = createACE(oakPath, child, restrictionProvider);
                    if (predicate == null || predicate.apply(ace)) {
                        entries.add(ace);
                    }
                }
            }
            if (isEffectivePolicy) {
                acl = new ImmutableACL(oakPath, entries, restrictionProvider, getNamePathMapper());
            } else {
                acl = new NodeACL(oakPath, entries);
            }
        }
    }
    return acl;
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) ArrayList(java.util.ArrayList) Tree(org.apache.jackrabbit.oak.api.Tree) ImmutableACL(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ImmutableACL) JackrabbitAccessControlList(org.apache.jackrabbit.api.security.JackrabbitAccessControlList) CheckForNull(javax.annotation.CheckForNull)

Aggregations

ArrayList (java.util.ArrayList)1 CheckForNull (javax.annotation.CheckForNull)1 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)1 ImmutableACL (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ImmutableACL)1