Search in sources :

Example 1 with AbstractAccessControlList

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

the class ACLTest method testReorderToTheEnd.

@Test
public void testReorderToTheEnd() throws Exception {
    Privilege[] read = privilegesFromNames(JCR_READ, JCR_READ_ACCESS_CONTROL);
    Privilege[] write = privilegesFromNames(JCR_WRITE);
    AbstractAccessControlList acl = createEmptyACL();
    acl.addAccessControlEntry(testPrincipal, read);
    acl.addEntry(testPrincipal, write, false);
    acl.addAccessControlEntry(EveryonePrincipal.getInstance(), write);
    List<? extends JackrabbitAccessControlEntry> entries = acl.getEntries();
    assertEquals(3, entries.size());
    AccessControlEntry first = entries.get(0);
    acl.orderBefore(first, null);
    List<? extends JackrabbitAccessControlEntry> entriesAfter = acl.getEntries();
    assertEquals(first, entriesAfter.get(2));
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) JackrabbitAccessControlEntry(org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry) AccessControlEntry(javax.jcr.security.AccessControlEntry) Privilege(javax.jcr.security.Privilege) Test(org.junit.Test)

Example 2 with AbstractAccessControlList

use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList 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)

Example 3 with AbstractAccessControlList

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

the class ACLTest method testEmptyAcl.

@Test
public void testEmptyAcl() throws RepositoryException {
    AbstractAccessControlList acl = createEmptyACL();
    assertNotNull(acl.getAccessControlEntries());
    assertNotNull(acl.getEntries());
    assertTrue(acl.getAccessControlEntries().length == 0);
    assertEquals(acl.getAccessControlEntries().length, acl.getEntries().size());
    assertEquals(0, acl.size());
    assertTrue(acl.isEmpty());
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) Test(org.junit.Test)

Example 4 with AbstractAccessControlList

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

the class ACLTest method testGetPath.

@Test
public void testGetPath() {
    NameMapper nameMapper = new GlobalNameMapper(Collections.singletonMap("jr", "http://jackrabbit.apache.org"));
    NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
    // map of jcr-path to standard jcr-path
    Map<String, String> paths = new HashMap<String, String>();
    paths.put(null, null);
    paths.put(TEST_PATH, TEST_PATH);
    paths.put("/", "/");
    paths.put("/jr:testPath", "/jr:testPath");
    paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
    for (String path : paths.keySet()) {
        AbstractAccessControlList acl = createACL(path, Collections.<ACE>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getPath());
    }
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) HashMap(java.util.HashMap) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) Test(org.junit.Test)

Example 5 with AbstractAccessControlList

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

the class ACLTest method testGetRestrictionTypeForUnknownName.

@Test
public void testGetRestrictionTypeForUnknownName() throws RepositoryException {
    AbstractAccessControlList acl = createEmptyACL();
    // for backwards compatibility getRestrictionType(String) must return
    // UNDEFINED for a unknown restriction name:
    assertEquals(PropertyType.UNDEFINED, acl.getRestrictionType("unknownRestrictionName"));
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) Test(org.junit.Test)

Aggregations

AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)11 Test (org.junit.Test)11 HashMap (java.util.HashMap)2 AccessControlEntry (javax.jcr.security.AccessControlEntry)2 Privilege (javax.jcr.security.Privilege)2 JackrabbitAccessControlEntry (org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry)2 LocalNameMapper (org.apache.jackrabbit.oak.namepath.LocalNameMapper)2 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)2 NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.NamePathMapperImpl)2 RestrictionDefinition (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition)2 GlobalNameMapper (org.apache.jackrabbit.oak.namepath.GlobalNameMapper)1 NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)1 ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)1