Package org.apache.jetspeed.security

Examples of org.apache.jetspeed.security.RolePrincipal


     * @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 testGetNonExistingRolePrincipal() throws Exception
    {
        RolePrincipal role = roleHandler.getRolePrincipal(roleUid1 + "FAKE");
        assertNull(role);
    }
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

        Iterator roles = currentSubject.getPrincipals(RolePrincipalImpl.class).iterator();
        StringBuffer combo = new StringBuffer();
        int count = 0;
        while (roles.hasNext())
        {
            RolePrincipal role = (RolePrincipal)roles.next();
            if (count > 0)
            {
                combo.append("-");
            }
            combo.append(role.getName());
            count++;                       
        }
        Set principals = new HashSet();
        principals.add(SecurityHelper.getBestPrincipal(currentSubject, UserPrincipal.class));
        principals.add(new RolePrincipalImpl(combo.toString()));
View Full Code Here

        if (roleExists(roleFullPathName))
        {
            throw new SecurityException(SecurityException.ROLE_ALREADY_EXISTS.create(roleFullPathName));
        }

        RolePrincipal rolePrincipal = new RolePrincipalImpl(roleFullPathName);
        String fullPath = rolePrincipal.getFullPath();
        // Add the preferences.
        Preferences preferences = Preferences.userRoot().node(fullPath);
        if (log.isDebugEnabled())
        {
            log.debug("Added role preferences node: " + fullPath);
        }
        try
        {
            if ((null != preferences) && preferences.absolutePath().equals(fullPath))
            {
                // Add role principal.
                roleSecurityHandler.setRolePrincipal(rolePrincipal);
                if (log.isDebugEnabled())
                {
                    log.debug("Added role: " + fullPath);
                }
            }
        }
        catch (SecurityException se)
        {
            KeyedMessage msg =
                SecurityException.UNEXPECTED.create("RoleManager.addRole",
                                                    "RoleSecurityHandler.setRolePrincipal("+rolePrincipal.getName()+")",
                                                    se.getMessage());
            log.error(msg, se);

            // Remove the preferences node.
            try
View Full Code Here

        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 testGetNonExistingRolePrincipal() throws Exception
    {
        RolePrincipal role = roleHandler.getRolePrincipal(roleUid1 + "FAKE");
        assertNull(role);
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.RolePrincipal

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.