Package javax.jcr.security

Examples of javax.jcr.security.AccessControlList


                }
                public Privilege[] getPrivileges() {
                    return privs;
                }
            };
            AccessControlList acl = getList(acMgr, path);
            acl.removeAccessControlEntry(entry);
            fail("AccessControlManager.removeAccessControlEntry with an unknown entry must throw AccessControlException.");
        } catch (AccessControlException e) {
            // ok
        }
    }
View Full Code Here


        }
    }

    public void testAddAccessControlEntryTwice() throws NotExecutableException, RepositoryException {
        checkCanModifyAc(path);
        AccessControlList acl = getList(acMgr, path);
        if (acl.addAccessControlEntry(testPrincipal, privs)) {
            assertFalse("Adding the same ACE twice should not modify the AC-List.",
                    acl.addAccessControlEntry(testPrincipal, privs));
        }
    }
View Full Code Here

    }

    public void testAddAccessControlEntryAgain() throws NotExecutableException, RepositoryException {
        checkCanModifyAc(path);

        AccessControlList list = getList(acMgr, path);
        list.addAccessControlEntry(testPrincipal, privs);
        AccessControlEntry[] entries = list.getAccessControlEntries();
        if (entries.length > 0) {
            assertFalse("Adding an existing entry again must not modify the AC-List",
                    list.addAccessControlEntry(entries[0].getPrincipal(), entries[0].getPrivileges()));
        } else {
            throw new NotExecutableException();
        }
    }
View Full Code Here

        }
        if (twoPrivs.size() < 2) {
            throw new NotExecutableException("At least 2 supported, non-aggregate privileges required at " + path);
        }

        AccessControlList acl = getList(acMgr, path);
        Privilege privilege = twoPrivs.get(0);
        // add first privilege:
        acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege});

        // add a second privilege (but not specifying the privilege added before)
        // -> the first privilege must not be removed.
        Privilege privilege2 = twoPrivs.get(1);
        acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege2});

        List<Privilege> currentPrivileges = currentPrivileges(acl, testPrincipal);
        assertTrue("'AccessControlList.addAccessControlEntry' must not remove privileges added before", currentPrivileges.containsAll(twoPrivs));
    }
View Full Code Here

    }

    private AccessControlList getACL(NodeImpl accessControlledNode, Name policyName, String path) throws RepositoryException {
        // collect the aces of that node.
        NodeImpl aclNode = accessControlledNode.getNode(policyName);
        AccessControlList acl = new ACLTemplate(aclNode, path, allowUnknownPrincipals);

        return new UnmodifiableAccessControlList(acl);
    }
View Full Code Here

        AccessControlManager accessControlManager = session
                .getAccessControlManager();
        AccessControlPolicyIterator acls = accessControlManager
                .getApplicablePolicies(permissionsPath);
        if (acls.hasNext()) {
            AccessControlList acl = (AccessControlList) acls.nextAccessControlPolicy();
            acl.addAccessControlEntry(user.getPrincipal(), accessControlManager
                    .getSupportedPrivileges(permissionsPath));
            accessControlManager.setPolicy(permissionsPath, acl);
        } else {
            throw new Exception("could not set access control for path "
                    + permissionsPath);
View Full Code Here

        plcs2 = acMgr.getEffectivePolicies(childNPath);
        assertFalse(Arrays.equals(plcs, plcs2));
        verifyACEs(plcs2, path, 2);
        // still a single ACE at childNPath. but privileges must be adjusted
        verifyACEs(plcs2, childNPath, 1);
        AccessControlList acl = null;
        for (AccessControlPolicy p : plcs2) {
            if (p instanceof JackrabbitAccessControlList && childNPath.equals(((JackrabbitAccessControlList) p).getPath())) {
                acl = (AccessControlList) p;
            }
        }
        Privilege[] privs = privilegesFromNames(new String[] {Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_REMOVE_CHILD_NODES});
        assertEquals(privs, acl.getAccessControlEntries()[0].getPrivileges());

        // --- test4: remove policy at childNPath ------------------------------
        acMgr.removePolicy(childNPath, acMgr.getPolicies(childNPath)[0]);
        superuser.save();
       
View Full Code Here

            AccessControlPolicy[] plcs = acMgr.getPolicies(null);
            assertNotNull(plcs);
            assertEquals(1, plcs.length);
            assertTrue(plcs[0] instanceof AccessControlList);

            AccessControlList acl = (AccessControlList) plcs[0];
            AccessControlEntry[] aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(2, aces.length);

            assertPrivilege(NameConstants.JCR_NAMESPACE_MANAGEMENT, true);
            assertPermission(Permission.NAMESPACE_MNGMT, true);

            assertPrivilege(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
            assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);

            effective = acMgr.getEffectivePolicies(null);
            assertNotNull(effective);
            assertEquals(1, effective.length);
            assertTrue(effective[0] instanceof AccessControlList);

            acl = (AccessControlList) effective[0];
            aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(2, aces.length);

            // change the policy: removing the second entry in the access control list
            acl = (AccessControlList) acMgr.getPolicies(null)[0];
            AccessControlEntry toRemove = acl.getAccessControlEntries()[1];
            acl.removeAccessControlEntry(toRemove);
            acMgr.setPolicy(null, acl);
            superuser.save();

            acl = (AccessControlList) acMgr.getPolicies(null)[0];
            aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(1, aces.length);

            assertPrivilege(NameConstants.JCR_NAMESPACE_MANAGEMENT, false);
            assertPermission(Permission.NAMESPACE_MNGMT, false);
View Full Code Here

            AccessControlPolicy[] eff = jAcMgr.getEffectivePolicies(principalSet);
            assertNotNull(eff);
            assertEquals(1, eff.length);
            assertTrue(eff[0] instanceof AccessControlList);

            AccessControlList acl = (AccessControlList) eff[0];
            AccessControlEntry[] aces = acl.getAccessControlEntries();
            assertNotNull(aces);
            assertEquals(2, aces.length);
            for (AccessControlEntry ace : aces) {
                assertEquals(testUser.getPrincipal(), ace.getPrincipal());
            }
View Full Code Here

        // if the given node is access-controlled, construct a new ACL and add
        // it to the list
        if (isAccessControlled(node)) {
            // build acl for the access controlled node
            NodeImpl aclNode = node.getNode(N_POLICY);
            AccessControlList acl = systemEditor.getACL(aclNode);
            acls.add(new UnmodifiableAccessControlList(acl));
        }
        // then, recursively look for access controlled parents up the hierarchy.
        if (!rootNodeId.equals(node.getId())) {
            NodeImpl parentNode = (NodeImpl) node.getParent();
View Full Code Here

TOP

Related Classes of javax.jcr.security.AccessControlList

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.