Search in sources :

Example 11 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl in project jackrabbit-oak by apache.

the class PrivilegeManagerImplTest method testGetPrivilegeRemappedNamespace.

@Test
public void testGetPrivilegeRemappedNamespace() throws Exception {
    NamePathMapper mapper = new NamePathMapperImpl(new LocalNameMapper(root, ImmutableMap.of("prefix", NamespaceRegistry.NAMESPACE_JCR)));
    Privilege p = create(root, mapper).getPrivilege("prefix:read");
    assertNotNull(p);
    assertNotEquals(Privilege.JCR_READ, p.getName());
    assertNotEquals(PrivilegeConstants.JCR_READ, p.getName());
    assertEquals("prefix:read", p.getName());
}
Also used : NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl) Privilege(javax.jcr.security.Privilege) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 12 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method before.

@Override
@Before
public void before() throws Exception {
    super.before();
    registerNamespace(TEST_PREFIX, TEST_URI);
    NameMapper nameMapper = new GlobalNameMapper(root);
    npMapper = new NamePathMapperImpl(nameMapper);
    acMgr = new AccessControlManagerImpl(root, npMapper, getSecurityProvider());
    NodeUtil rootNode = new NodeUtil(root.getTree("/"), getNamePathMapper());
    rootNode.addChild(testName, JcrConstants.NT_UNSTRUCTURED);
    root.commit();
    valueFactory = new ValueFactoryImpl(root, npMapper);
    testPrivileges = privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_READ);
    testPrincipal = getTestUser().getPrincipal();
}
Also used : GlobalNameMapper(org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Before(org.junit.Before)

Example 13 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl 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.impl.NamePathMapperImpl) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) Test(org.junit.Test)

Example 14 with NamePathMapperImpl

use of org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl 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.impl.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl) Test(org.junit.Test)

Aggregations

NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.impl.NamePathMapperImpl)14 LocalNameMapper (org.apache.jackrabbit.oak.namepath.impl.LocalNameMapper)11 Test (org.junit.Test)11 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)10 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)7 GlobalNameMapper (org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper)6 Privilege (javax.jcr.security.Privilege)4 NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)2 ValueFactoryImpl (org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl)2 AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ParseException (java.text.ParseException)1 NamespaceRegistry (javax.jcr.NamespaceRegistry)1 ValueFactory (javax.jcr.ValueFactory)1 NodeTypeDefinition (javax.jcr.nodetype.NodeTypeDefinition)1 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)1