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

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


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

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

        // removing himself from group. should succeed.
        assertTrue(gr.removeMember(user));
    }
View Full Code Here


    public void testAddOwnAuthorizableToForeignGroup() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Authorizable self = umgr.getAuthorizable(uID);

        Group gr = userMgr.createGroup(getTestPrincipal());
        save(superuser);

        try {
            assertTrue(((Group) umgr.getAuthorizable(gr.getID())).addMember(self));
            save(uSession);
            assertTrue(((Group) umgr.getAuthorizable(gr.getID())).removeMember(self));
            save(uSession);
        } finally {
            gr.remove();
            save(superuser);
        }
    }
View Full Code Here

            save(superuser);
        }
    }

    public void testRemoveMembersOfForeignGroup() throws RepositoryException, NotExecutableException {
        Group nGr = null;
        User nUs = null;
        User nUs2 = null;

        try {
            // let superuser create a group and a user a make user member of group
            nGr = userMgr.createGroup(getTestPrincipal());
            save(superuser);

            Principal p = getTestPrincipal();
            nUs = userMgr.createUser(p.getName(), buildPassword(p));
            save(superuser);

            p = getTestPrincipal();
            nUs2 = userMgr.createUser(p.getName(), buildPassword(p));
            save(superuser);
            nGr.addMember(nUs);
            nGr.addMember(nUs2);
            save(superuser);

            UserManager umgr = getUserManager(uSession);
            Group gr = (Group) umgr.getAuthorizable(nGr.getID());

            // removing any member must fail unless the testuser is user-admin
            Iterator<Authorizable> it = gr.getMembers();
            if (it.hasNext()) {
                Authorizable auth = it.next();

                String msg = "GroupAdmin must be able to modify group membership.";
                assertTrue(msg, gr.removeMember(auth));
                save(uSession);
            } else {
                fail("Must contain members....");
            }
View Full Code Here

            save(superuser);
        }
    }

    public void testRemoveAllMembersOfForeignGroup() throws RepositoryException, NotExecutableException {
        Group nGr = null;
        User nUs = null;

        try {
            // let superuser create a group and a user a make user member of group
            nGr = userMgr.createGroup(getTestPrincipal());
            save(superuser);
            Principal p = getTestPrincipal();
            nUs = userMgr.createUser(p.getName(), buildPassword(p));
            nGr.addMember(nUs);
            save(superuser);

            UserManager umgr = getUserManager(uSession);
            Group gr = (Group) umgr.getAuthorizable(nGr.getID());

            // since only 1 single member -> removal rather than modification.
            // since uSession is not user-admin this must fail.
            for (Iterator<Authorizable> it = gr.getMembers(); it.hasNext();) {
                Authorizable auth = it.next();

                String msg = "GroupAdmin must be able to remove a member of another group.";
                assertTrue(msg, gr.removeMember(auth));
                save(uSession);
            }
        } catch (AccessDeniedException e) {
            // fine as well.
        } finally {
View Full Code Here

        assertFalse(impers.allows(buildSubject(selfPrinc)));
    }

    public void testPersisted() throws NotExecutableException, RepositoryException {
        UserManager umgr = getUserManager(uSession);
        Group gr = null;
        try {
            Principal p = getTestPrincipal();
            gr = umgr.createGroup(p);
            save(uSession);

            // must be visible for the user-mgr attached to another session.
            Authorizable az = userMgr.getAuthorizable(gr.getID());
            assertNotNull(az);
            assertEquals(gr.getID(), az.getID());
        } finally {
            if (gr != null) {
                gr.remove();
                save(uSession);
            }
        }
    }
View Full Code Here

            } catch (RepositoryException e) {
                // success
            }
        }
       
        Group g = getTestGroup(superuser);
        for (String pName : protectedGroupProps) {
            try {
                g.setProperty(pName, v);
                save(superuser);
                fail("changing the '" + pName + "' property on a Group should fail.");
            } catch (RepositoryException e) {
                // success
            }
View Full Code Here

                fail("removing the '" + pName + "' property on a User should fail.");
            } catch (RepositoryException e) {
                // success
            }
        }
        Group g = getTestGroup(superuser);
        for (String pName : protectedGroupProps) {
            try {
                g.removeProperty(pName);
                save(superuser);
                fail("removing the '" + pName + "' property on a Group should fail.");
            } catch (RepositoryException e) {
                // success
            }
View Full Code Here

        // remove_child_node privilege is missing on the direct ancestor.
        assertFalse(testSession.hasPermission(gcPath, Session.ACTION_REMOVE));
    }

    public void testInheritedGroupPermissions() throws NotExecutableException, RepositoryException {
        Group testGroup = getTestGroup();
        AccessControlManager testAcMgr = getTestACManager();
        /*
         precondition:
         testuser must have READ-only permission on test-node and below
        */
        checkReadOnly(path);

        Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);

        /* give MODIFY_PROPERTIES privilege for testGroup at 'path' */
        givePrivileges(path, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path));
        /*
         withdraw MODIFY_PROPERTIES privilege for everyone at 'childNPath'
         */
        withdrawPrivileges(childNPath, EveryonePrincipal.getInstance(), privileges, getRestrictions(superuser, path));

View Full Code Here

        // result at 'child path' must be deny
        assertFalse(testAcMgr.hasPrivileges(childNPath, privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES)));   
    }

    public void testInheritedGroupPermissions2() throws NotExecutableException, RepositoryException {
        Group testGroup = getTestGroup();
        AccessControlManager testAcMgr = getTestACManager();
        /*
         precondition:
         testuser must have READ-only permission on test-node and below
        */
        checkReadOnly(path);

        Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);

        // NOTE: same as testInheritedGroupPermissions above but using
        // everyone on path, testgroup on childpath -> result must be the same

        /* give MODIFY_PROPERTIES privilege for everyone at 'path' */
        givePrivileges(path, EveryonePrincipal.getInstance(), privileges, getRestrictions(superuser, path));
        /*
         withdraw MODIFY_PROPERTIES privilege for testGroup at 'childNPath'
         */
        withdrawPrivileges(childNPath, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path));

        // result at 'child path' must be deny
        assertFalse(testAcMgr.hasPrivileges(childNPath, privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES)));
    }
View Full Code Here

        NodeImpl target = (NodeImpl) sImpl.getNode(umgr.getGroupsPath());
        try {
            doImport(target, xml);

            Group g = (Group) umgr.getAuthorizable("g");
            assertNotNull(g);
            Group g1 = (Group) umgr.getAuthorizable("g1");
            assertNotNull(g1);

            NodeImpl n = ((AuthorizableImpl) g1).getNode();
            assertTrue(n.hasProperty(UserConstants.P_MEMBERS));

            // getWeakReferences only works upon save.
            sImpl.save();

            assertTrue(g1.isMember(g));          

        } finally {
            sImpl.refresh(false);
            target.getNode("gFolder").remove();
            sImpl.save();
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.