Search in sources :

Example 1 with SimplePrincipal

use of org.modeshape.jcr.security.SimplePrincipal in project kylo by Teradata.

the class JcrAccessControlUtil method addEntry.

private static boolean addEntry(Session session, AccessControlList acl, Principal principal, Privilege... privileges) throws RepositoryException, AccessControlException, UnsupportedRepositoryOperationException {
    // Ensure admin is always included in the ACL
    if (acl.getAccessControlEntries().length == 0) {
        SimplePrincipal simple = SimplePrincipal.newInstance(ModeShapeRoles.ADMIN);
        acl.addAccessControlEntry(simple, asPrivileges(session, Privilege.JCR_ALL));
    }
    // ModeShape reads back all principals as SimplePrincipals after they are stored, so we have to use
    // the same principal type here or the entry will treated as a new one instead of adding privileges to the
    // to an existing principal.  This can be considered a bug in ModeShape.
    SimplePrincipal simple = encodePrincipal(principal);
    boolean added = acl.addAccessControlEntry(simple, privileges);
    return added;
}
Also used : SimplePrincipal(org.modeshape.jcr.security.SimplePrincipal)

Aggregations

SimplePrincipal (org.modeshape.jcr.security.SimplePrincipal)1