Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.Root


    @Test
    public void testCreateInvalidJcrUuid() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);

        try {
            Root testRoot = getTestRoot();
            testRoot.refresh();

            NodeUtil a = new NodeUtil(testRoot.getTree("/a"));
            NodeUtil test = a.addChild("referenceable2", NT_NAME);
            test.setString(JcrConstants.JCR_UUID, "not a uuid");
            testRoot.commit();
            fail("Creating a referenceable node with an invalid uuid must fail.");
        } catch (CommitFailedException e) {
            assertTrue(e.isConstraintViolation());
            assertEquals(12, e.getCode());
        }
View Full Code Here


        Tree rootBefore = new ImmutableTree(before);
        Tree rootAfter = new ImmutableTree(after);

        RestrictionProvider restrictionProvider = getConfig(AuthorizationConfiguration.class).getRestrictionProvider();

        Root root = new ImmutableRoot(before);
        Map<String, Privilege> privileges = getPrivileges(root);
        PrivilegeBitsProvider privilegeBitsProvider = new PrivilegeBitsProvider(root);
        ReadOnlyNodeTypeManager ntMgr = ReadOnlyNodeTypeManager.getInstance(before);

        return new AccessControlValidator(rootBefore, rootAfter, privileges, privilegeBitsProvider, restrictionProvider, ntMgr);
View Full Code Here

    @Test
    public void testCreateBooleanJcrUuid() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);

        try {
            Root testRoot = getTestRoot();
            testRoot.refresh();

            NodeUtil a = new NodeUtil(testRoot.getTree("/a"));
            NodeUtil test = a.addChild("referenceable2", NT_NAME);
            test.setBoolean(JcrConstants.JCR_UUID, false);
            testRoot.commit();
            fail("Creating a referenceable node with an boolean uuid must fail.");
        } catch (CommitFailedException e) {
            assertTrue(e.isConstraintViolation());
        }
    }
View Full Code Here

    @Test
    public void testCreateNonReferenceableJcrUuid() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);

        try {
            Root testRoot = getTestRoot();
            NodeUtil a = new NodeUtil(testRoot.getTree("/a"));
            a.setString(JCR_UUID, IdentifierManager.generateUUID());
            testRoot.commit();
            fail("Creating a jcr:uuid property for an unstructured node without ADD_PROPERTY permission must fail.");
        } catch (CommitFailedException e) {
            assertTrue(e.isAccessViolation());
        }
    }
View Full Code Here

    @Test
    public void testModifyJcrUuid() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ, PrivilegeConstants.REP_WRITE);

        try {
            Root testRoot = getTestRoot();
            Tree test = testRoot.getTree(referenceablePath);
            test.setProperty(JCR_UUID, "anothervalue");
            testRoot.commit();
            fail("An attempt to change the jcr:uuid property must fail");
        } catch (CommitFailedException e) {
            assertTrue(e.isConstraintViolation());
            assertEquals(12, e.getCode());
        }
View Full Code Here

        NodeUtil a = new NodeUtil(root.getTree("/a"));
        a.setString(JCR_UUID, "some-value");
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);

        try {
            Root testRoot = getTestRoot();
            a = new NodeUtil(testRoot.getTree("/a"));
            assertNotNull(a.getString(JCR_UUID, null));
            a.setString(JCR_UUID, IdentifierManager.generateUUID());
            testRoot.commit();
            fail("Modifying a jcr:uuid property for an unstructured node without MODIFY_PROPERTY permission must fail.");
        } catch (CommitFailedException e) {
            assertTrue(e.isAccessViolation());
        }
    }
View Full Code Here

    @Test
    public void testRemoveJcrUuid() throws Exception {
        setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ);

        try {
            Root testRoot = getTestRoot();
            Tree test = testRoot.getTree(referenceablePath);
            test.removeProperty(JCR_UUID);
            testRoot.commit();
            fail("Removing the jcr:uuid property of a referenceable node must fail.");
        } catch (CommitFailedException e) {
            assertTrue(e.isConstraintViolation());
            assertEquals(22, e.getCode());
        }
View Full Code Here

        // grant 'testUser' READ + READ_AC privileges at 'path'
        Privilege[] privileges = privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL);
        setupPolicy(testPath, privileges);
        root.commit();

        Root testRoot = getTestRoot();
        testRoot.refresh();
        AccessControlManager testAcMgr = getTestAccessControlManager();

        assertTrue(testAcMgr.hasPrivileges(testPath, privileges));

        // diff to jr core: getEffectivePolicies will just return the policies
View Full Code Here

        setupPolicy(testPath, privilegesFromNames(PrivilegeConstants.JCR_READ));
        setupPolicy(childPath, privilegesFromNames(PrivilegeConstants.JCR_READ_ACCESS_CONTROL));
        root.commit();

        Root testRoot = getTestRoot();
        testRoot.refresh();
        AccessControlManager testAcMgr = getTestAccessControlManager();

        assertTrue(testAcMgr.hasPrivileges(childPath, privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_READ_ACCESS_CONTROL)));

        // diff to jr core: getEffectivePolicies will just return the policies
View Full Code Here

        // grant 'testUser' READ + READ_AC privileges at 'path'
        Privilege[] privileges = privilegesFromNames(PrivilegeConstants.JCR_READ);
        setupPolicy(testPath, privileges);
        root.commit();

        Root testRoot = getTestRoot();
        testRoot.refresh();
        AccessControlManager testAcMgr = getTestAccessControlManager();

        List<String> paths = ImmutableList.of(testPath, NodeTypeConstants.NODE_TYPES_PATH);
        for (String path : paths) {
            assertFalse(testAcMgr.hasPrivileges(path, privilegesFromNames(PrivilegeConstants.JCR_READ_ACCESS_CONTROL)));
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.Root

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.