Search in sources :

Example 16 with ItemBasedPrincipal

use of org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal in project jackrabbit-oak by apache.

the class AccessControlManagerImpl method getApplicablePolicies.

//-------------------------------------< JackrabbitAccessControlManager >---
@Nonnull
@Override
public JackrabbitAccessControlPolicy[] getApplicablePolicies(@Nonnull Principal principal) throws RepositoryException {
    Util.checkValidPrincipal(principal, principalManager);
    String oakPath = (principal instanceof ItemBasedPrincipal) ? ((ItemBasedPrincipal) principal).getPath() : null;
    JackrabbitAccessControlPolicy policy = createPrincipalACL(oakPath, principal);
    if (policy != null) {
        return new JackrabbitAccessControlPolicy[0];
    } else {
        return new JackrabbitAccessControlPolicy[] { new PrincipalACL(oakPath, principal) };
    }
}
Also used : ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal) JackrabbitAccessControlPolicy(org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy) Nonnull(javax.annotation.Nonnull)

Example 17 with ItemBasedPrincipal

use of org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal in project jackrabbit by apache.

the class UserAccessControlProvider method compilePermissions.

/**
     * @see org.apache.jackrabbit.core.security.authorization.AccessControlProvider#compilePermissions(Set)
     */
public CompiledPermissions compilePermissions(Set<Principal> principals) throws RepositoryException {
    checkInitialized();
    if (isAdminOrSystem(principals)) {
        return getAdminPermissions();
    } else {
        if (!anonymousAccess && isAnonymous(principals)) {
            return CompiledPermissions.NO_PERMISSION;
        }
        // determined the 'user' present in the given set of principals.
        ItemBasedPrincipal userPrincipal = getUserPrincipal(principals);
        NodeImpl userNode = getUserNode(userPrincipal);
        if (userNode == null) {
            // security workspace.
            return CompiledPermissions.NO_PERMISSION;
        } else {
            return new CompiledPermissionsImpl(principals, userNode.getPath());
        }
    }
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl) ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal)

Aggregations

ItemBasedPrincipal (org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal)17 Principal (java.security.Principal)9 UserManager (org.apache.jackrabbit.api.security.user.UserManager)7 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)6 RepositoryException (javax.jcr.RepositoryException)5 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)5 User (org.apache.jackrabbit.api.security.user.User)5 NodeImpl (org.apache.jackrabbit.core.NodeImpl)4 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)4 HashSet (java.util.HashSet)3 Node (javax.jcr.Node)3 JackrabbitAccessControlPolicy (org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy)3 Nonnull (javax.annotation.Nonnull)2 Session (javax.jcr.Session)2 SimpleCredentials (javax.jcr.SimpleCredentials)2 SessionImpl (org.apache.jackrabbit.core.SessionImpl)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1