Search in sources :

Example 1 with PrincipalRestrictionProvider

use of org.apache.jackrabbit.oak.security.authorization.restriction.PrincipalRestrictionProvider in project jackrabbit-oak by apache.

the class AccessControlManagerImpl method createPrincipalACL.

@Nullable
private JackrabbitAccessControlList createPrincipalACL(@Nullable String oakPath, @Nonnull Principal principal) throws RepositoryException {
    Root root = getRoot();
    Result aceResult = searchAces(Collections.<Principal>singleton(principal), root);
    RestrictionProvider restrProvider = new PrincipalRestrictionProvider(restrictionProvider);
    List<ACE> entries = new ArrayList<ACE>();
    for (ResultRow row : aceResult.getRows()) {
        Tree aceTree = root.getTree(row.getPath());
        if (Util.isACE(aceTree, ntMgr)) {
            String aclPath = Text.getRelativeParent(aceTree.getPath(), 1);
            String path;
            if (aclPath.endsWith(REP_REPO_POLICY)) {
                path = null;
            } else {
                path = Text.getRelativeParent(aclPath, 1);
            }
            entries.add(createACE(path, aceTree, restrProvider));
        }
    }
    if (entries.isEmpty()) {
        // nothing found
        return null;
    } else {
        return new PrincipalACL(oakPath, principal, entries, restrProvider);
    }
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Root(org.apache.jackrabbit.oak.api.Root) PrincipalRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.PrincipalRestrictionProvider) PrincipalRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.PrincipalRestrictionProvider) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) ArrayList(java.util.ArrayList) Tree(org.apache.jackrabbit.oak.api.Tree) Result(org.apache.jackrabbit.oak.api.Result) Nullable(javax.annotation.Nullable)

Aggregations

ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 Result (org.apache.jackrabbit.oak.api.Result)1 ResultRow (org.apache.jackrabbit.oak.api.ResultRow)1 Root (org.apache.jackrabbit.oak.api.Root)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 PrincipalRestrictionProvider (org.apache.jackrabbit.oak.security.authorization.restriction.PrincipalRestrictionProvider)1 ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)1 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)1