Search in sources :

Example 6 with AbstractAccessControlList

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

the class ACLTest method testGetOakPath.

@Test
public void testGetOakPath() {
    NamePathMapper npMapper = new NamePathMapperImpl(new LocalNameMapper(singletonMap("oak", "http://jackrabbit.apache.org"), singletonMap("jcr", "http://jackrabbit.apache.org")));
    // map of jcr-path to oak path
    Map<String, String> paths = new HashMap();
    paths.put(null, null);
    paths.put(TEST_PATH, TEST_PATH);
    paths.put("/", "/");
    String oakPath = "/oak:testPath";
    String jcrPath = "/jcr:testPath";
    paths.put(jcrPath, oakPath);
    jcrPath = "/{http://jackrabbit.apache.org}testPath";
    paths.put(jcrPath, oakPath);
    // test if oak-path is properly set.
    for (String path : paths.keySet()) {
        AbstractAccessControlList acl = createACL(path, Collections.<ACE>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getOakPath());
    }
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) HashMap(java.util.HashMap) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) Test(org.junit.Test)

Example 7 with AbstractAccessControlList

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

the class ACLTest method testSize.

@Test
public void testSize() throws RepositoryException {
    AbstractAccessControlList acl = createACL(createTestEntries());
    assertEquals(3, acl.size());
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) Test(org.junit.Test)

Example 8 with AbstractAccessControlList

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

the class ACLTest method testGetRestrictionNames.

@Test
public void testGetRestrictionNames() throws RepositoryException {
    AbstractAccessControlList acl = createEmptyACL();
    String[] restrNames = acl.getRestrictionNames();
    assertNotNull(restrNames);
    List<String> names = Lists.newArrayList(restrNames);
    for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(TEST_PATH)) {
        assertTrue(names.remove(getNamePathMapper().getJcrName(def.getName())));
    }
    assertTrue(names.isEmpty());
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) RestrictionDefinition(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition) Test(org.junit.Test)

Example 9 with AbstractAccessControlList

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

the class ACLTest method testIsEmpty.

@Test
public void testIsEmpty() throws RepositoryException {
    AbstractAccessControlList acl = createACL(createTestEntries());
    assertFalse(acl.isEmpty());
}
Also used : AbstractAccessControlList(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList) Test(org.junit.Test)

Example 10 with AbstractAccessControlList

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

the class ACLTest method testReorder.

@Test
public void testReorder() 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);
    AccessControlEntry[] entries = acl.getAccessControlEntries();
    assertEquals(3, entries.length);
    AccessControlEntry first = entries[0];
    AccessControlEntry second = entries[1];
    AccessControlEntry third = entries[2];
    // reorder 'second' to the first position
    acl.orderBefore(second, first);
    assertEquals(second, acl.getEntries().get(0));
    assertEquals(first, acl.getEntries().get(1));
    assertEquals(third, acl.getEntries().get(2));
    // reorder 'third' before 'first'
    acl.orderBefore(third, first);
    assertEquals(second, acl.getEntries().get(0));
    assertEquals(third, acl.getEntries().get(1));
    assertEquals(first, acl.getEntries().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)

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