Search in sources :

Example 56 with AccessDeniedException

use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.

the class ReadPropertyTest method testGetParent.

@Test
public void testGetParent() throws Exception {
    deny(path, privilegesFromName(PrivilegeConstants.REP_READ_NODES));
    List<String> propertyPaths = new ArrayList<String>();
    propertyPaths.add(childPPath);
    propertyPaths.add(childchildPPath);
    propertyPaths.add(path + "/jcr:primaryType");
    for (String pPath : propertyPaths) {
        Property p = testSession.getProperty(pPath);
        try {
            Node n = p.getParent();
            fail();
        } catch (AccessDeniedException e) {
        // success
        }
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) Property(javax.jcr.Property) Test(org.junit.Test)

Example 57 with AccessDeniedException

use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.

the class IndexManagementTest method testAddIndexDefinitionWithoutPermission.

public void testAddIndexDefinitionWithoutPermission() throws Exception {
    superuser.getNode(path).addNode(IndexConstants.INDEX_DEFINITIONS_NAME);
    superuser.save();
    allow(path, privilegesFromName(PrivilegeConstants.REP_WRITE));
    try {
        Node n = testSession.getNode(path).getNode(IndexConstants.INDEX_DEFINITIONS_NAME).addNode("myIndex", IndexConstants.INDEX_DEFINITIONS_NODE_TYPE);
        n.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "myType");
        testSession.save();
        fail("AccessDeniedException expected. Test session is not allowed to add index definition node.");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) Node(javax.jcr.Node)

Example 58 with AccessDeniedException

use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.

the class IndexManagementTest method testRemoveOakIndexWithoutPermission.

public void testRemoveOakIndexWithoutPermission() throws Exception {
    Node indexDef = superuser.getNode(path).addNode(IndexConstants.INDEX_DEFINITIONS_NAME).addNode("myIndex", IndexConstants.INDEX_DEFINITIONS_NODE_TYPE);
    indexDef.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "myType");
    superuser.save();
    allow(path, privilegesFromName(PrivilegeConstants.REP_WRITE));
    try {
        Node n = testSession.getNode(path).getNode(IndexConstants.INDEX_DEFINITIONS_NAME);
        n.remove();
        testSession.save();
        fail("AccessDeniedException expected. Test session is not allowed to remove oak:index.");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) Node(javax.jcr.Node)

Example 59 with AccessDeniedException

use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.

the class IndexManagementTest method testVersionableIndexDefinition.

public void testVersionableIndexDefinition() throws Exception {
    allow(path, privilegesFromNames(new String[] { PrivilegeConstants.REP_INDEX_DEFINITION_MANAGEMENT, PrivilegeConstants.JCR_NODE_TYPE_MANAGEMENT }));
    try {
        Node n = testSession.getNode(path).addNode(IndexConstants.INDEX_DEFINITIONS_NAME).addNode("myIndex", IndexConstants.INDEX_DEFINITIONS_NODE_TYPE);
        n.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "myType");
        n.addMixin(JcrConstants.MIX_VERSIONABLE);
        testSession.save();
        fail("Missing rep:versionManagement privilege");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) Node(javax.jcr.Node)

Example 60 with AccessDeniedException

use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.

the class NamespaceManagementTest method testRegisterNamespace.

@Test
public void testRegisterNamespace() throws Exception {
    try {
        Workspace testWsp = testSession.getWorkspace();
        testWsp.getNamespaceRegistry().registerNamespace(getNewNamespacePrefix(testWsp), getNewNamespaceURI(testWsp));
        fail("Namespace registration should be denied.");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) Workspace(javax.jcr.Workspace) Test(org.junit.Test)

Aggregations

AccessDeniedException (javax.jcr.AccessDeniedException)189 Node (javax.jcr.Node)80 Test (org.junit.Test)68 Session (javax.jcr.Session)33 RepositoryException (javax.jcr.RepositoryException)23 Privilege (javax.jcr.security.Privilege)22 UserManager (org.apache.jackrabbit.api.security.user.UserManager)19 Workspace (javax.jcr.Workspace)18 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)15 ItemNotFoundException (javax.jcr.ItemNotFoundException)13 PathNotFoundException (javax.jcr.PathNotFoundException)13 Path (org.apache.jackrabbit.spi.Path)13 Principal (java.security.Principal)11 User (org.apache.jackrabbit.api.security.user.User)11 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)10 AccessControlManager (javax.jcr.security.AccessControlManager)9 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)9 Property (javax.jcr.Property)8 JackrabbitWorkspace (org.apache.jackrabbit.api.JackrabbitWorkspace)8 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)7