Search in sources :

Example 71 with AccessControlException

use of javax.jcr.security.AccessControlException in project jackrabbit by apache.

the class PrivilegeManagerImpl method getPrivilege.

// ------------------------------------------------------------< private >---
/**
 * @param name
 * @return The privilege with the specified name.
 * @throws AccessControlException
 * @throws RepositoryException
 */
private Privilege getPrivilege(Name name) throws AccessControlException, RepositoryException {
    Privilege privilege;
    synchronized (cache) {
        if (cache.containsKey(name)) {
            privilege = cache.get(name);
        } else {
            PrivilegeDefinition def = registry.get(name);
            if (def != null) {
                privilege = new PrivilegeImpl(def);
                cache.put(name, privilege);
            } else {
                throw new AccessControlException("Unknown privilege " + resolver.getJCRName(name));
            }
        }
    }
    return privilege;
}
Also used : PrivilegeDefinition(org.apache.jackrabbit.spi.PrivilegeDefinition) AccessControlException(javax.jcr.security.AccessControlException) Privilege(javax.jcr.security.Privilege)

Example 72 with AccessControlException

use of javax.jcr.security.AccessControlException in project jackrabbit by apache.

the class PrivilegeManagerImplTest method testGetBitsFromCustomPrivilege.

public void testGetBitsFromCustomPrivilege() throws AccessControlException {
    Privilege p = buildCustomPrivilege(Privilege.JCR_READ, null);
    try {
        getPrivilegeManagerImpl().getBits(p);
        fail("Retrieving bits from unknown privilege should fail.");
    } catch (AccessControlException e) {
    // ok
    }
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) Privilege(javax.jcr.security.Privilege)

Example 73 with AccessControlException

use of javax.jcr.security.AccessControlException in project jackrabbit by apache.

the class PrivilegeManagerImplTest method testGetBitsWithInvalidPrivilege.

public void testGetBitsWithInvalidPrivilege() {
    Privilege p = buildCustomPrivilege("anyName", null);
    try {
        getPrivilegeManagerImpl().getBits(p);
        fail();
    } catch (AccessControlException e) {
    // ok
    }
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) Privilege(javax.jcr.security.Privilege)

Example 74 with AccessControlException

use of javax.jcr.security.AccessControlException in project jackrabbit by apache.

the class PrivilegeRegistryTest method testGetBitsWithInvalidPrivilege.

public void testGetBitsWithInvalidPrivilege() {
    Privilege p = buildUnregisteredPrivilege("anyName", null);
    try {
        PrivilegeRegistry.getBits(new Privilege[] { p });
        fail();
    } catch (AccessControlException e) {
    // ok
    }
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) Privilege(javax.jcr.security.Privilege)

Example 75 with AccessControlException

use of javax.jcr.security.AccessControlException in project jackrabbit by apache.

the class PrivilegeRegistryTest method testGetBitsFromInvalidPrivilege.

public void testGetBitsFromInvalidPrivilege() throws AccessControlException {
    Privilege p = buildUnregisteredPrivilege(Privilege.JCR_READ, null);
    try {
        PrivilegeRegistry.getBits(new Privilege[] { p });
        fail("Retrieving bits from unknown privilege should fail.");
    } catch (AccessControlException e) {
    // ok
    }
}
Also used : AccessControlException(javax.jcr.security.AccessControlException) Privilege(javax.jcr.security.Privilege)

Aggregations

AccessControlException (javax.jcr.security.AccessControlException)86 Test (org.junit.Test)32 Privilege (javax.jcr.security.Privilege)20 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)19 Principal (java.security.Principal)17 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)11 Tree (org.apache.jackrabbit.oak.api.Tree)11 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)9 JackrabbitAccessControlEntry (org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry)8 JackrabbitAccessControlPolicy (org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy)8 RepositoryException (javax.jcr.RepositoryException)6 Value (javax.jcr.Value)6 TestPrincipal (org.apache.jackrabbit.core.security.TestPrincipal)6 Restriction (org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction)6 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)6 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)6 AccessControlEntry (javax.jcr.security.AccessControlEntry)5 AccessControlList (javax.jcr.security.AccessControlList)5 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)5 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)4