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

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


        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


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

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

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

            assertTrue(g1.isMember(admin));

            boolean found = false;
            for (Iterator<Group> it = admin.declaredMemberOf(); it.hasNext() && !found;) {
                found = "g1".equals(it.next().getID());
            }
View Full Code Here

    public void testCreatingGroupWithNameMatchingExistingUserId() throws RepositoryException, NotExecutableException {
        Principal p = getTestPrincipal();
        String uid = getTestUserId(p);

        User u = null;
        Group gr = null;
        try {
            u = userMgr.createUser(uid, buildPassword(uid, true), p, null);
            save(superuser);
            gr = userMgr.createGroup(new TestPrincipal(uid));
            save(superuser);

            String msg = "Creating a Group with a principal-name that exists as UserID -> must create new GroupID but keep PrincipalName.";
            assertFalse(msg, gr.getID().equals(gr.getPrincipal().getName()));
            assertFalse(msg, gr.getID().equals(uid));
            assertFalse(msg, gr.getID().equals(u.getID()));
            assertEquals(msg, uid, gr.getPrincipal().getName());
        } finally {
            if (u != null) {
                u.remove();
                save(superuser);
            }
            if (gr != null) {
                gr.remove();
                save(superuser);
            }
        }
    }
View Full Code Here

            }
        }
    }

    public void testFindGroup() throws RepositoryException, NotExecutableException {
        Group gr = null;
        try {
            Principal p = getTestPrincipal();
            gr = userMgr.createGroup(p);
            save(superuser);

            boolean found = false;
            Iterator<Authorizable> it = userMgr.findAuthorizables(pPrincipalName, null, UserManager.SEARCH_TYPE_GROUP);
            while (it.hasNext() && !found) {
                Group ng = (Group) it.next();
                found = ng.getPrincipal().getName().equals(p.getName());
            }
            assertTrue("Searching for \"\" must find the created group.", found);

            it = userMgr.findAuthorizables(pPrincipalName, p.getName(), UserManager.SEARCH_TYPE_GROUP);
            assertTrue(it.hasNext());
            Group ng = (Group) it.next();
            assertEquals("Searching for principal-name must find the created group.", p.getName(), ng.getPrincipal().getName());
            assertFalse("Only a single group must be found for a given principal name.", it.hasNext());

            // but search users should not find anything
            it = userMgr.findAuthorizables(pPrincipalName, p.getName(), UserManager.SEARCH_TYPE_USER);
            assertFalse(it.hasNext());
View Full Code Here

            // success.
        }
    }

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

        /* add privileges for the Group the test-user is member of */
        Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);
        givePrivileges(path, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path));

        /* testuser must get the permissions/privileges inherited from
           the group it is member of.
         */
        String actions = javax.jcr.Session.ACTION_SET_PROPERTY + "," + javax.jcr.Session.ACTION_READ;
View Full Code Here

        Privilege[] privs = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);
        assertTrue(testAcMgr.hasPrivileges(path, privs));
    }

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

        /* explicitly withdraw MODIFY_PROPERTIES for the user */
        Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);
        withdrawPrivileges(path, testUser.getPrincipal(), privileges, getRestrictions(superuser, path));
        /* give MODIFY_PROPERTIES privilege for a Group the test-user is member of */
        givePrivileges(path, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path));
        /*
         since user-permissions overrule the group permissions, testuser must
         not have set_property action / modify_properties privilege.
         */
        String actions = javax.jcr.Session.ACTION_SET_PROPERTY;
View Full Code Here

        assertFalse(getTestSession().hasPermission(path, actions));
        assertFalse(testAcMgr.hasPrivileges(path, privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES)));
    }
   
    public void testInheritanceAndMixedUserGroupPermissions() throws RepositoryException, NotExecutableException {
        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 for the user at 'path' */
        withdrawPrivileges(path, testUser.getPrincipal(), privileges, getRestrictions(superuser, path));

        /*
         since user-permissions overrule the group permissions, testuser must
         not have set_property action / modify_properties privilege.
         */
        assertFalse(testAcMgr.hasPrivileges(path, privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES)));

        /*
         give MODIFY_PROPERTIES privilege for everyone at 'childNPath'
         -> user-privileges still overrule group privileges
         */
        givePrivileges(childNPath, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path));
        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

        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

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

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

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

            assertTrue(g1.isMember(admin));

            boolean found = false;
            for (Iterator<Group> it = admin.declaredMemberOf(); it.hasNext() && !found;) {
                found = "g1".equals(it.next().getID());
            }
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.