Package org.apache.turbine.om.security

Examples of org.apache.turbine.om.security.Role


        {
            Group group = (Group) groupsIterator.next();
            Iterator rolesIterator = getRoles(user, group).iterator();
            while (rolesIterator.hasNext())
            {
                Role role = (Role) rolesIterator.next();
                revoke(user, group, role);
            }
        }
    }
View Full Code Here


        {
            User user = (User) it.next();
            for (Iterator rolesIterator = getRoles(user, group).iterator();
                 rolesIterator.hasNext();)
            {
                Role role = (Role) rolesIterator.next();
                revoke(user, group, role);
            }
        }
    }
View Full Code Here

    public void testGrantPermission()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role admin = ss.getRoleByName("Admin");
        assertNotNull(admin);

        Permission app = ss.getPermissionByName("Application");
        assertNotNull(app);

        PermissionSet ps = admin.getPermissions();
        assertFalse(ps.contains(app));

        ss.grant(admin, app);

        Role admin2 = ss.getRoleByName("Admin");
        assertNotNull(admin2);

        PermissionSet ps2 = admin2.getPermissions();
        assertTrue(ps2.contains(app));

        // Get existing PermissionSet modified?
        assertFalse(ps.contains(app));
View Full Code Here

    public void testRevokePermission()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role admin = ss.getRoleByName("Admin");
        assertNotNull(admin);

        Permission app = ss.getPermissionByName("Application");
        assertNotNull(app);

        PermissionSet ps = admin.getPermissions();
        assertTrue(ps.contains(app));

        ss.revoke(admin, app);

        Role admin2 = ss.getRoleByName("Admin");
        assertNotNull(admin2);

        PermissionSet ps2 = admin2.getPermissions();
        assertFalse(ps2.contains(app));

        // Get existing PermissionSet modified?
        assertTrue(ps.contains(app));
View Full Code Here

    public void testRevokeAll()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role user = ss.getRoleByName("User");
        assertNotNull(user);

        PermissionSet ps = user.getPermissions();
        assertEquals(2, ps.size());

        ss.revokeAll(user);

        Role user2 = ss.getRoleByName("User");
        assertNotNull(user2);

        PermissionSet ps2 = user2.getPermissions();
        assertEquals(0, ps2.size());
    }
View Full Code Here

    public void testRoleByName()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role role = ss.getRoleByName("User");
        assertNotNull(role);
        assertEquals(role.getName(), "User");
    }
View Full Code Here

    public void testRoleById()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role role = ss.getRoleById(2);
        assertNotNull(role);
        assertEquals(role.getName(), "Admin");
    }
View Full Code Here

    public void testRolePermissions()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role role = ss.getRoleByName("User");
        assertNotNull(role);

        PermissionSet ps = ss.getPermissions(role);

        assertEquals(2, ps.size());
View Full Code Here

    public void testAddRole()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Role newbie = ss.getRoleInstance();
        newbie.setName("newbie");

        ss.addRole(newbie);

        assertEquals("Role was not added", 3, ss.getAllRoles().size());

        try
        {
            Role user = ss.getRoleByName("User");

            ss.addRole(user);
            fail("Existing Role could be added!");
        }
        catch (Exception e)
        {
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), EntityExistsException.class, e.getClass());
        }

        try
        {
            Role empty = ss.getRoleInstance();

            ss.addRole(empty);
            fail("Role with empty Rolename could be added!");
        }
        catch (Exception e)
View Full Code Here

    {
        SecurityService ss = TurbineSecurity.getService();

        assertEquals("Role was not added", 3, ss.getAllRoles().size());

        Role newbie = ss.getRoleByName("newbie");
        assertNotNull(newbie);

        ss.removeRole(newbie);

        try
        {
            Role foo = ss.getRoleInstance();
            foo.setName("foo");

            ss.removeRole(foo);
            fail("Non Existing Role could be deleted!");
        }
        catch (Exception e)
View Full Code Here

TOP

Related Classes of org.apache.turbine.om.security.Role

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.