Package org.apache.jetspeed.security.impl

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


            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


            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

     * </p>
     */
    public void testRemoveRolePrincipal() throws Exception
    {
        initMappedRole();
        rsh.removeRolePrincipal(new RolePrincipalImpl("mappedrole"));
        // The user should still exist.
        assertTrue(ums.userExists("mappedroleuser"));
        // The group should still exist.
        assertTrue(gms.groupExists("mappedgroup"));
        // The permission should still exist.
        assertTrue(pms.permissionExists(new PortletPermission("myportlet", "view")));
        // The user-role mapping should be gone.
        assertFalse(rms.isUserInRole("mappedroleuser", "mappedrole"));
        // The group-role mapping should be gone.
        assertFalse(rms.isGroupInRole("mappedgroup", "mappedroleuser"));
        // The permission-role mapping should be gone.
        Permissions perms = pms.getPermissions(new RolePrincipalImpl("mappedrole"));
        assertFalse(perms.implies(new PortletPermission("myportlet", "view")));
       
        destroyMappedRole();
    }
View Full Code Here

        rms.addRole("mappedrole.role1");
        gms.addGroup("mappedgroup");
       
        Permission perm = new PortletPermission("myportlet", "view");
        pms.addPermission(perm);
        pms.grantPermission(new RolePrincipalImpl("mappedrole"), perm);
       
        rms.addRoleToUser("mappedroleuser", "mappedrole");
        rms.addRoleToGroup("mappedrole", "mappedgroup");   
    }
View Full Code Here

     * @param principalUid The principal uid.
     * @return A group principal object.
     */
    protected Principal makePrincipal(String principalUid)
    {
        return new RolePrincipalImpl(principalUid);
    }
View Full Code Here

        InternalRolePrincipal internalRole = commonQueries
                .getInternalRolePrincipal(RolePrincipalImpl
                        .getFullPathFromPrincipalName(roleFullPathName));
        if (null != internalRole)
        {
            rolePrincipal = new RolePrincipalImpl(RolePrincipalImpl
                    .getPrincipalNameFromFullPath(internalRole.getFullPath()));
        }
        return rolePrincipal;
    }
View Full Code Here

            String path = internalRole.getFullPath();
            if (path == null)
            {
                continue;
            }
            rolePrincipals.add(new RolePrincipalImpl(RolePrincipalImpl
                    .getPrincipalNameFromFullPath(internalRole.getFullPath())));
        }
        return rolePrincipals;
    }
View Full Code Here

        {
            String dn = ldap.lookupByUid(roleUidWithoutSlashes);

            if (!StringUtils.isEmpty(dn))
            {
                return new RolePrincipalImpl(roleFullPathName);
            }
        }
        catch (SecurityException e)
        {
            logSecurityException(e, roleFullPathName);
View Full Code Here

     */
    private void createResolvedRolePrincipalSet(String username, Set rolePrincipals, String[] roles, int i)
    {
        LOG.debug("Group [" + i + "] for user[" + username + "] is [" + roles[i] + "]");

        RolePrincipal role = new RolePrincipalImpl(roles[i]);
        Preferences preferences = Preferences.userRoot().node(role.getFullPath());
        LOG.debug("Group name:" + role.getName());
        String[] fullPaths = roleHierarchyResolver.resolve(preferences);
        for (int n = 0; n < fullPaths.length; n++)
        {
            LOG.debug("Group [" + i + "] for user[" + username + "] is ["
                    + RolePrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n]) + "]");
            rolePrincipals.add(new RolePrincipalImpl(RolePrincipalImpl.getPrincipalNameFromFullPath(fullPaths[n])));
        }
    }
View Full Code Here

        final RequestContext rc =
            new JetspeedRequestContext(request, response, config, null);
       
        Set principals = new HashSet();
        principals.add(new UserPrincipalImpl("admin"));
        principals.add(new RolePrincipalImpl("admin"));
        Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
       
        PipelineException pe = (PipelineException) JSSubject.doAsPrivileged(subject, new PrivilegedAction()
                {
                    public Object run()
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.