Package org.apache.jetspeed.security.impl

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


        grHandler.setGroupPrincipal(gp);
    }
   
    public static void seedRoleData(String roleUid) throws Exception
    {
        RolePrincipal rp = new RolePrincipalImpl(roleUid);
        roleHandler.setRolePrincipal(rp);
    }
View Full Code Here


        grHandler.removeGroupPrincipal(gp);
    }
   
    public static void removeRoleData(String roleUid) throws Exception
    {
        RolePrincipal rp = new RolePrincipalImpl(roleUid);
        roleHandler.removeRolePrincipal(rp);
    }   
View Full Code Here

    /**
     * @throws Exception
     */
    public void testGetRolePrincipal() throws Exception
    {
        String fullPath = (new RolePrincipalImpl(roleUid1)).getFullPath();
        RolePrincipal rolePrincipal = roleHandler.getRolePrincipal(roleUid1);
        assertNotNull("Role was not found.", rolePrincipal);
        assertEquals(roleUid1,rolePrincipal.getName());
        assertEquals(fullPath,rolePrincipal.getFullPath());
    }
View Full Code Here

    /**
     * @throws Exception
     */
    public void testAddDuplicateRolePrincipal() throws Exception
    {
      roleHandler.setRolePrincipal(new RolePrincipalImpl(roleUid1));
        List roles = roleHandler.getRolePrincipals("");
        assertEquals(1,roles.size());
    }
View Full Code Here

    /**
     * @throws Exception
     */
    public void testRemoveExistantUserPrincipal() throws Exception
    {
        RolePrincipal gp = new RolePrincipalImpl(roleUid1);
        roleHandler.removeRolePrincipal(gp);
        RolePrincipal rolePrincipal = roleHandler.getRolePrincipal(gp.getFullPath());
        assertNull("Role was found and should have been removed.", rolePrincipal);
        List roles = roleHandler.getRolePrincipals("");
        assertEquals(0,roles.size());       
    }
View Full Code Here

     * @throws Exception
     */
    public void testRemoveNonExistantUserPrincipal() throws Exception
    {
        String localUid = Integer.toString(rand.nextInt()).toString();
        RolePrincipal localPrin = new RolePrincipalImpl(localUid);
        roleHandler.removeRolePrincipal(localPrin);
        List roles = roleHandler.getRolePrincipals("");
        assertEquals(1,roles.size());
    }
View Full Code Here

        {
            LdapDataHelper.seedRoleData(gpUid2);
            assertTrue("getUserPrincipals should have returned more than one user.", roleHandler.getRolePrincipals("*")
                    .size() > 1);

            String fullPath = (new RolePrincipalImpl(roleUid1)).getFullPath();
            List roles = roleHandler.getRolePrincipals(fullPath);
            assertTrue("getRolePrincipals should have returned one role.", roles.size() == 1);
            assertTrue("List should have consisted of RolePrincipal objects.", roles.get(0) instanceof RolePrincipal);

            String localUid = Integer.toString(rand.nextInt()).toString();
            assertTrue("getRolePrincipals should not have found any roles with the specified filter.", roleHandler
                    .getRolePrincipals(new RolePrincipalImpl(localUid).getFullPath()).isEmpty());
        }
        finally
        {
            LdapDataHelper.removeRoleData(gpUid2);
        }
View Full Code Here

            Collection principals = getPrincipals(subject, RolePrincipal.class);
            assertEquals("shoud have one principal;", 1 , principals.size());
           
            assertTrue(
                    "should contain rootrole",
                    principals.contains(new RolePrincipalImpl("rootrole")));
           
            rms.removeRoleFromUser("test","rootrole");
           
            user = ums.getUser("test");
            principals= getPrincipals(user.getSubject(),RolePrincipal.class);
            assertEquals("shoud not have any principals;", 0,principals.size());
           
        }
        catch (SecurityException sex)
        {
            assertTrue("test with parent role "+sex.getMessage(), false);
        }
       
        try
        {
            rms.addRoleToUser("test","rootrole.childrole1");
       
            user = ums.getUser("test");
            Subject subject = user.getSubject();
            assertNotNull("subject is null", subject);
            Collection principals=getPrincipals(subject,RolePrincipal.class);
            assertEquals("expected 2 principals;", 2,principals.size());
           
            assertTrue(
                    "should contain rootrole",
                    principals.contains(new RolePrincipalImpl("rootrole")));
           
            assertTrue(
                    "should contain rootrole",
                    principals.contains(new RolePrincipalImpl("rootrole.childrole1")));
          
            rms.removeRoleFromUser("test","rootrole.childrole1");
           
            user = ums.getUser("test");
            principals=getPrincipals(user.getSubject(),RolePrincipal.class);
View Full Code Here

    {
        Principal principal = null;
        if (fullPath.startsWith(BasePrincipal.PREFS_ROLE_ROOT))
        {
            String name = RolePrincipalImpl.getPrincipalNameFromFullPath(fullPath);           
            principal = new RolePrincipalImpl(name);
        }
        else if (fullPath.startsWith(BasePrincipal.PREFS_USER_ROOT))
        {
            String name = UserPrincipalImpl.getPrincipalNameFromFullPath(fullPath);
            principal = new UserPrincipalImpl(name);
View Full Code Here

            user = ums.getUser("test");
            Subject subject = user.getSubject();
            assertNotNull("subject is null", subject);
            Collection principals = getPrincipals(subject, RolePrincipal.class);
            assertEquals("should have 3 principals;", 3, principals.size());
            assertTrue("should contain rootrole", principals.contains(new RolePrincipalImpl("rootrole")));
            assertTrue("should contain rootrole.childrole1", principals.contains(new RolePrincipalImpl(
                    "rootrole.childrole1")));
            assertTrue("should contain rootrole.childrole2", principals.contains(new RolePrincipalImpl(
                    "rootrole.childrole2")));

            rms.removeRoleFromUser("test", "rootrole");

            user = ums.getUser("test");
            principals = getPrincipals(user.getSubject(), RolePrincipal.class);
            assertEquals("should not have any principals;", 0, principals.size());

        }
        catch (SecurityException sex)
        {
            assertTrue("test with parent role " + sex.getMessage(), false);
        }

        try
        {
            rms.addRoleToUser("test", "rootrole.childrole1");

            user = ums.getUser("test");
            Subject subject = user.getSubject();
            assertNotNull("subject is null", subject);
            Collection principals = getPrincipals(subject, RolePrincipal.class);
            assertEquals("shoud have 1 principal;", 1, principals.size());

            assertTrue("should contain rootrole.childrole1", principals.contains(new RolePrincipalImpl(
                    "rootrole.childrole1")));

            rms.removeRoleFromUser("test", "rootrole.childrole1");

            user = ums.getUser("test");
View Full Code Here

TOP

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

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.