Package javax.jcr.security

Examples of javax.jcr.security.AccessControlPolicyIterator.nextAccessControlPolicy()


        Item item = superuser.getItem(path);
        if (acMgr.getPolicies(path).length == 0) {
            // no policy to remove ->> apply one
            AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
            if (it.hasNext()) {
                AccessControlPolicy policy = it.nextAccessControlPolicy();
                acMgr.setPolicy(path, policy);
                superuser.save();

                // remember for teardown
                addedPolicies.put(path, policy);
View Full Code Here


            throw new NotExecutableException();
        }

        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
        while (it.hasNext()) {
            AccessControlPolicy policy = it.nextAccessControlPolicy();
            acMgr.setPolicy(n.getPath(), policy);

            AccessControlPolicy[] plcs = acMgr.getPolicies(n.getPath());
            assertNotNull("After calling setPolicy the manager must return a non-null policy array for the new Node.", plcs);
            assertTrue("After calling setPolicy the manager must return a policy array with a length greater than zero for the new Node.", plcs.length > 0);
View Full Code Here

    public void testRemoveTransientlyAddedPolicy() throws RepositoryException, AccessDeniedException {
        AccessControlPolicy[] ex = acMgr.getPolicies(path);

        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
        while (it.hasNext()) {
            AccessControlPolicy policy = it.nextAccessControlPolicy();
            acMgr.setPolicy(path, policy);
            acMgr.removePolicy(path, policy);

            String msg = "transiently added AND removing a policy must revert " +
                    "the changes made. " +
View Full Code Here

        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);

        long position = 0;
        while (it.hasNext()) {
            assertEquals("Position must be adjusted during iteration.", position, it.getPosition());
            it.nextAccessControlPolicy();
            assertEquals("Position must be adjusted after calling next.", ++position, it.getPosition());
        }
    }

    public void testSkip() throws NotExecutableException, RepositoryException {
View Full Code Here

        if (size > -1) {
            it.skip(size);
            assertFalse("After skipping all elements 'hasNext()' must return false", it.hasNext());

            try {
                it.nextAccessControlPolicy();
                fail("After skipping all 'nextAccessControlPolicy()' must fail.");
            } catch (NoSuchElementException e) {
                // success
            }
        } else {
View Full Code Here

        // call must succeed without exception
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
        Set<AccessControlPolicy> acps = new HashSet<AccessControlPolicy>();

        while (it.hasNext()) {
            AccessControlPolicy policy = it.nextAccessControlPolicy();
            if (!acps.add(policy)) {
                fail("The applicable policies present should be unique among the choices. Policy " + policy + " occured multiple times.");
            }
        }
    }
View Full Code Here

        checkCanReadAc(path);
        // call must succeed without exception
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
        Set<AccessControlPolicy> acps = new HashSet<AccessControlPolicy>();
        while (it.hasNext()) {
            acps.add(it.nextAccessControlPolicy());
        }

        AccessControlPolicy[] policies = acMgr.getPolicies(path);
        for (int i = 0; i < policies.length; i++) {
            assertFalse("The applicable policies obtained should not be present among the policies obtained through AccessControlManager.getPolicies.", acps.contains(policies[i]));
View Full Code Here

    public void testSetPolicy() throws RepositoryException, AccessDeniedException, NotExecutableException {
        checkCanModifyAc(path);
        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
        if (it.hasNext()) {
            AccessControlPolicy policy = it.nextAccessControlPolicy();
            acMgr.setPolicy(path, policy);
        } else {
            throw new NotExecutableException();
        }
    }
View Full Code Here

        AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
        if (!it.hasNext()) {
            throw new NotExecutableException();
        }
        while (it.hasNext()) {
            acMgr.setPolicy(path, it.nextAccessControlPolicy());
        }
        // all policies have been set -> no additional applicable policies.
        it = acMgr.getApplicablePolicies(path);
        assertFalse("After having set all applicable policies AccessControlManager.getApplicablePolicies should return an empty iterator.",
                it.hasNext());
View Full Code Here

     */
    public static JackrabbitAccessControlList getAccessControlList(AccessControlManager accessControlManager, String absPath) throws RepositoryException {
        // try applicable (new) ACLs
        AccessControlPolicyIterator itr = accessControlManager.getApplicablePolicies(absPath);
        while (itr.hasNext()) {
            AccessControlPolicy policy = itr.nextAccessControlPolicy();
            if (policy instanceof JackrabbitAccessControlList) {
                return (JackrabbitAccessControlList) policy;
            }
        }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.