Search in sources :

Example 26 with ACE

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

the class EntryTest method testAggregatePrivileges.

@Test
public void testAggregatePrivileges() throws Exception {
    ACE ace = createEntry(PrivilegeConstants.REP_READ_NODES, PrivilegeConstants.REP_READ_PROPERTIES);
    assertEquals(getBitsProvider().getBits(PrivilegeConstants.JCR_READ), ace.getPrivilegeBits());
    assertArrayEquals(privilegesFromNames(PrivilegeConstants.JCR_READ), ace.getPrivileges());
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Test(org.junit.Test)

Example 27 with ACE

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

the class EntryTest method testIsAllow.

@Test
public void testIsAllow() throws RepositoryException {
    ACE ace = createEntry(new String[] { PrivilegeConstants.JCR_READ }, true);
    assertTrue(ace.isAllow());
    ace = createEntry(new String[] { PrivilegeConstants.JCR_READ }, false);
    assertFalse(ace.isAllow());
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Test(org.junit.Test)

Example 28 with ACE

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

the class EntryTest method testGetRestrictionsNone.

@Test
public void testGetRestrictionsNone() throws Exception {
    ACE ace = createEntry(ImmutableSet.<Restriction>of());
    assertTrue(ace.getRestrictions().isEmpty());
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Test(org.junit.Test)

Example 29 with ACE

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

the class EntryTest method testGetPrivileges.

@Test
public void testGetPrivileges() throws RepositoryException {
    ACE entry = createEntry(new String[] { PrivilegeConstants.JCR_READ }, true);
    Privilege[] privs = entry.getPrivileges();
    assertNotNull(privs);
    assertEquals(1, privs.length);
    assertEquals(privs[0], acMgr.privilegeFromName(PrivilegeConstants.JCR_READ));
    entry = createEntry(new String[] { PrivilegeConstants.REP_WRITE }, true);
    privs = entry.getPrivileges();
    assertNotNull(privs);
    assertEquals(1, privs.length);
    assertEquals(privs[0], acMgr.privilegeFromName(PrivilegeConstants.REP_WRITE));
    entry = createEntry(new String[] { PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES }, true);
    privs = entry.getPrivileges();
    assertNotNull(privs);
    assertEquals(2, privs.length);
    Privilege[] expected = AccessControlUtils.privilegesFromNames(acMgr, PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES);
    assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(privs));
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Privilege(javax.jcr.security.Privilege) Test(org.junit.Test)

Example 30 with ACE

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

the class EntryTest method testGetNonExistingRestrictions.

/**
     * @since OAK 1.0: support for multi-value restrictions
     */
@Test
public void testGetNonExistingRestrictions() throws Exception {
    Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
    ACE ace = createEntry(ImmutableSet.of(nameRestr));
    assertNull(ace.getRestrictions(AccessControlConstants.REP_GLOB));
}
Also used : Restriction(org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction) ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) Test(org.junit.Test)

Aggregations

ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)33 Test (org.junit.Test)25 Restriction (org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction)12 Value (javax.jcr.Value)8 Privilege (javax.jcr.security.Privilege)5 Tree (org.apache.jackrabbit.oak.api.Tree)5 ArrayList (java.util.ArrayList)4 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)4 HashMap (java.util.HashMap)3 AccessControlEntry (javax.jcr.security.AccessControlEntry)3 AccessControlException (javax.jcr.security.AccessControlException)3 Principal (java.security.Principal)2 Nullable (javax.annotation.Nullable)2 JackrabbitAccessControlEntry (org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry)2 JackrabbitAccessControlPolicy (org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy)2 ImmutableACL (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ImmutableACL)2 PrivilegeBits (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits)2 Predicate (com.google.common.base.Predicate)1 CheckForNull (javax.annotation.CheckForNull)1 RepositoryException (javax.jcr.RepositoryException)1