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

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


        }
        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


        assertTrue(gr.isMember(umgr.getAuthorizable(uID)));
    }

    public void testCreateUser() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        UserImpl u = null;
        // create a new user -> must succeed and user must be create below 'other'
        try {
            Principal p = getTestPrincipal();
            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p));
            save(uSession);
            fail("Group administrator should not be allowed to create a new user.");
        } catch (AccessDeniedException e) {
            // success
        } finally {
View Full Code Here

            }
        }
    }

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

        Authorizable himself = umgr.getAuthorizable(uID);
        try {
            himself.remove();
            save(uSession);
            fail("A GroupAdministrator should not be allowed to remove the own authorizable.");
        } catch (AccessDeniedException e) {
View Full Code Here

            // success
        }
    }

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

        Authorizable groupAdmin = umgr.getAuthorizable(grID);
        try {
            groupAdmin.remove();
            save(uSession);
            fail("A GroupAdministrator should not be allowed to remove the group admin.");
        } catch (AccessDeniedException e) {
View Full Code Here

            // success
        }
    }

    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();
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();
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);
View Full Code Here

            save(uSession);
        }
    }

    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

        assertTrue(gr.removeMember(cU));
        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) {
View Full Code Here

            }
        }
    }

    public void testAddMembersUserAdmins() throws RepositoryException, NotExecutableException {
        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);
View Full Code Here

TOP

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

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.