Package org.apache.jackrabbit.api.security.user

Examples of org.apache.jackrabbit.api.security.user.Group


        try {
            String groupID = getGroupId(principal.getName());
            NodeImpl groupNode = (NodeImpl) nodeCreator.createGroupNode(groupID, intermediatePath);
            setPrincipal(groupNode, principal);

            Group group = createGroup(groupNode);
            if (isAutoSave()) {
                session.save();
            }

            log.debug("Group created: " + groupID + "; " + groupNode.getPath());
View Full Code Here


        return otherUID2;
    }

    public void testIsGroupAdmin() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Group gr = (Group) umgr.getAuthorizable(grID);

        assertTrue(gr.isMember(umgr.getAuthorizable(uID)));
    }
View Full Code Here

        }
    }

    public void testCreateGroup() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Group testGroup = null;
        try {
            testGroup = umgr.createGroup(getTestPrincipal());
            save(uSession);
            assertTrue(Text.isDescendant(groupsPath, ((GroupImpl)testGroup).getNode().getPath()));
        } finally {
            if (testGroup != null) {
                testGroup.remove();
                save(uSession);
            }
        }
    }
View Full Code Here

        }
    }

    public void testCreateGroupWithIntermediatePath() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Group testGroup = null;
        try {
            testGroup = umgr.createGroup(getTestPrincipal(), "/any/intermediate/path");
            save(uSession);
            assertTrue(Text.isDescendant(groupsPath + "/any/intermediate/path", ((GroupImpl)testGroup).getNode().getPath()));
        } finally {
            if (testGroup != null) {
                testGroup.remove();
                save(uSession);
            }
        }
    }
View Full Code Here

    }

    public void testAddToGroup() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Authorizable cU = umgr.getAuthorizable(getYetAnotherID());
        Group gr = (Group) umgr.getAuthorizable(grID);

        // adding and removing the test user as member of a group must succeed.
        try {
            assertTrue("Modifying group membership requires GroupAdmin membership.",gr.addMember(cU));
            save(uSession);
        } finally {
            gr.removeMember(cU);
            save(uSession);
        }
    }
View Full Code Here

    public void testAddToGroup2() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Authorizable cU = umgr.getAuthorizable(getYetAnotherID());

        Group gr = (Group) umgr.getAuthorizable(groupAdmin.getID());
        assertTrue(gr.addMember(cU));
        save(uSession);
        assertTrue(gr.removeMember(cU));
        save(uSession);
    }
View Full Code Here

        save(uSession);
    }

    public void testAddMembersToCreatedGroup() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Group testGroup = null;
        User self = (User) umgr.getAuthorizable(uID);
        try {
            // let groupadmin create a new group
            testGroup = umgr.createGroup(getTestPrincipal(), "/a/b/c/d");
            save(uSession);

            // editing session adds itself to that group -> must succeed.
            assertTrue(testGroup.addMember(self));
            save(uSession);

            // add child-user to test group
            Authorizable testUser = umgr.getAuthorizable(getYetAnotherID());
            assertFalse(testGroup.isMember(testUser));
            assertTrue(testGroup.addMember(testUser));
            save(uSession);
        } finally {
            if (testGroup != null) {
                for (Iterator<Authorizable> it = testGroup.getDeclaredMembers(); it.hasNext();) {
                    testGroup.removeMember(it.next());
                }
                testGroup.remove();
                save(uSession);
            }
        }
    }
View Full Code Here

        UserManager umgr = getUserManager(uSession);
        Authorizable auth = umgr.getAuthorizable(UserConstants.USER_ADMIN_GROUP_NAME);
        if (auth == null || !auth.isGroup()) {
            throw new NotExecutableException("Cannot execute test. No User-Admin group found.");
        }
        Group userAdmin = (Group) auth;
        Group testGroup = null;
        User self = (User) umgr.getAuthorizable(uID);
        try {

            userAdmin.addMember(self);
            save(uSession);

            userAdmin.removeMember(self);
            save(uSession);
            fail("Group admin cannot add member to user-admins");
        } catch (AccessDeniedException e) {
            // success
        }

        try {
            // let groupadmin create a new group
            testGroup = umgr.createGroup(getTestPrincipal(), "/a/b/c/d");
            save(uSession);

            userAdmin.addMember(testGroup);
            save(uSession);
            userAdmin.removeMember(testGroup);
            save(uSession);
            fail("Group admin cannot add member to user-admins");
        } catch (AccessDeniedException e) {
            // success
        } finally {
            if (testGroup != null) {
                testGroup.remove();
                save(uSession);
            }
        }
    }
View Full Code Here

    public void testAddOtherUserToGroup() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);

        Authorizable pU = umgr.getAuthorizable(otherUID);
        Group gr = (Group) umgr.getAuthorizable(groupAdmin.getID());

        try {
            assertTrue(gr.addMember(pU));
            save(uSession);
        } finally {
            gr.removeMember(pU);
            save(uSession);
        }
    }
View Full Code Here

    public void testAddOwnAuthorizableAsGroupAdmin() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);

        Authorizable user = umgr.getAuthorizable(uID);
        Group gr = (Group) umgr.getAuthorizable(groupAdmin.getID());

        // user is already group-admin -> adding must return false.
        // but should not throw exception.
        assertFalse(gr.addMember(user));
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.security.user.Group

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.