Search in sources :

Example 31 with ACE

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

the class UtilTest method testGenerateNameDifferentAllow.

@Test
public void testGenerateNameDifferentAllow() throws Exception {
    ACE allow = new TestAce(false);
    ACE deny = new TestAce(true);
    assertNotEquals(Util.generateAceName(allow, 0), Util.generateAceName(deny, 0));
    assertNotEquals(Util.generateAceName(allow, 1), Util.generateAceName(deny, 1));
    assertNotEquals(Util.generateAceName(allow, 20), Util.generateAceName(deny, 20));
    assertNotEquals(Util.generateAceName(allow, 0), Util.generateAceName(deny, 1));
    assertNotEquals(Util.generateAceName(allow, 1), Util.generateAceName(deny, 20));
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 32 with ACE

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

the class UtilTest method testGenerateName.

@Test
public void testGenerateName() throws AccessControlException {
    ACE ace = new TestAce(true);
    String name = Util.generateAceName(ace, 0);
    assertTrue(name.startsWith(ALLOW));
    assertEquals(ALLOW, name);
    assertEquals(name, Util.generateAceName(ace, 0));
    name = Util.generateAceName(ace, 1);
    assertTrue(name.startsWith(ALLOW));
    assertEquals(ALLOW + 1, name);
    assertEquals(name, Util.generateAceName(ace, 1));
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 33 with ACE

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

the class ACLTest method testGetEntries.

@Test
public void testGetEntries() throws RepositoryException {
    List<ACE> aces = createTestEntries();
    AbstractAccessControlList acl = createACL(TEST_PATH, aces, getNamePathMapper());
    assertNotNull(acl.getEntries());
    assertNotNull(acl.getAccessControlEntries());
    assertEquals(aces.size(), acl.getEntries().size());
    assertEquals(aces.size(), acl.getAccessControlEntries().length);
    assertTrue(acl.getEntries().containsAll(aces));
    assertTrue(Arrays.asList(acl.getAccessControlEntries()).containsAll(aces));
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) 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