Package org.apache.jetspeed.security.impl

Examples of org.apache.jetspeed.security.impl.GroupPrincipalImpl


    /**
     * @throws Exception
     */
    public void testAddDuplicateGroupPrincipal() throws Exception
    {
        grHandler.setGroupPrincipal(new GroupPrincipalImpl(gpUid1));
        List groups = grHandler.getGroupPrincipals("");
        assertEquals(1,groups.size());
    }
View Full Code Here


    /**
     * @throws Exception
     */
    public void testRemoveExistantUserPrincipal() throws Exception
    {
        GroupPrincipal gp = new GroupPrincipalImpl(gpUid1);
        grHandler.removeGroupPrincipal(gp);
        GroupPrincipal groupPrincipal = grHandler.getGroupPrincipal(gp.getFullPath());
        assertNull("Group was found and should have been removed.", groupPrincipal);
        List groups = grHandler.getGroupPrincipals("");
        assertEquals(0,groups.size());       
    }
View Full Code Here

     * @throws Exception
     */
    public void testRemoveNonExistantUserPrincipal() throws Exception
    {
        String localUid = Integer.toString(rand.nextInt()).toString();
        GroupPrincipal localPrin = new GroupPrincipalImpl(localUid);
        grHandler.removeGroupPrincipal(localPrin);
        List groups = grHandler.getGroupPrincipals("");
        assertEquals(1,groups.size());
    }
View Full Code Here

        {
            LdapDataHelper.seedGroupData(gpUid2);
            assertTrue("getUserPrincipals should have returned more than one user.", grHandler.getGroupPrincipals("*")
                    .size() > 1);

            String fullPath = (new GroupPrincipalImpl(gpUid1)).getFullPath();
            List groups = grHandler.getGroupPrincipals(fullPath);
            assertTrue("getGroupPrincipals should have returned one group.", groups.size() == 1);
            assertTrue("List should have consisted of GroupPrincipal objects.", groups.get(0) instanceof GroupPrincipal);

            String localUid = Integer.toString(rand.nextInt()).toString();
            assertTrue("getGroupPrincipals should not have found any groups with the specified filter.", grHandler
                    .getGroupPrincipals(new GroupPrincipalImpl(localUid).getFullPath()).isEmpty());
        }
        finally
        {
            LdapDataHelper.removeGroupData(gpUid2);
        }
View Full Code Here

       
        // Group or User
        if (fullPath.indexOf("/group/") > -1 )
        {
            name = fullPath.substring(GROUP_PATH.length());
            principal = new GroupPrincipalImpl(name);
        }
        else
        {
            name = fullPath.substring(USER_PATH.length());
            principal = new UserPrincipalImpl(name);
View Full Code Here

       
        // Group or User
        if (fullPath.indexOf("/group/") > -1 )
        {
            name = fullPath.substring(GROUP_PATH.length());
            principal = new GroupPrincipalImpl(name);
        }
        else
        {
            name = fullPath.substring(USER_PATH.length());
            principal = new UserPrincipalImpl(name);
View Full Code Here

        // Add group with no prior groups.
        try
        {
            gms.addUserToGroup("anonuser1", "testusertogroup1.group1");
            Collection principals = ums.getUser("anonuser1").getSubject().getPrincipals();
            assertTrue("anonuser1 should contain testusertogroup1.group1", principals.contains(new GroupPrincipalImpl(
                    "testusertogroup1.group1")));
        }
        catch (SecurityException sex)
        {
            assertTrue("should add user to group. exception caught: " + sex, false);
        }
        // Add group with existing groups.
        try
        {
            gms.addUserToGroup("anonuser1", "testusertogroup1.group2");
            Collection principals = ums.getUser("anonuser1").getSubject().getPrincipals();
            assertTrue("anonuser1 should contain testusertogroup1.group2", principals.contains(new GroupPrincipalImpl(
                    "testusertogroup1.group2")));
        }
        catch (SecurityException sex)
        {
            assertTrue("should add user to group. exception caught: " + sex, false);
View Full Code Here

            // (4 groups + 1 user).
            assertEquals(
                "principal size should be == 5 after removing testgroup1.group1, for principals: " + principals.toString(),
                5,
                principals.size());
            assertFalse("anonuser2 should not contain testgroup1.group1", principals.contains(new GroupPrincipalImpl(
                    "testgroup1.group1")));
        }
        catch (SecurityException sex)
        {
            assertTrue("should remove group. exception caught: " + sex, false);
View Full Code Here

            principal = new UserPrincipalImpl(name);
        }
        else if (fullPath.startsWith(BasePrincipal.PREFS_GROUP_ROOT))
        {
            String name = GroupPrincipalImpl.getPrincipalNameFromFullPath(fullPath);           
            principal = new GroupPrincipalImpl(name);
           
        }
        return principal;
    }
View Full Code Here

    {
        // Init test.
        UserPrincipal user = new UserPrincipalImpl("anon");
        RolePrincipal role1 = new RolePrincipalImpl("anonrole1");
        RolePrincipal role2 = new RolePrincipalImpl("anonrole2");
        GroupPrincipal group1 = new GroupPrincipalImpl("anongroup1");
        GroupPrincipal group2 = new GroupPrincipalImpl("anongroup2");
        PortletPermission perm1 = new PortletPermission("anontestportlet", "view");
        PortletPermission perm2 = new PortletPermission("anontestportlet", "view, edit");
        PortletPermission perm3 = new PortletPermission("anontestportlet", "view, edit, secure");
        PortletPermission perm4 = new PortletPermission("anontestportlet", "view, edit, secure, minimized");
        try
        {
            ums.addUser(user.getName(), "password");
            rms.addRole(role1.getName());
            rms.addRole(role2.getName());
            gms.addGroup(group1.getName());
            gms.addGroup(group2.getName());
            pms.addPermission(perm1);
            pms.addPermission(perm2);
            pms.addPermission(perm3);
            pms.addPermission(perm4);
            pms.grantPermission(role1, perm1);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.impl.GroupPrincipalImpl

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.