Package org.apache.turbine.om.security

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


                // foreach role in Set
                Iterator rolesIterator = groupRoles.iterator();

                while (rolesIterator.hasNext())
                {
                    Role role = (Role) rolesIterator.next();
                    // get permissions of the role
                    PermissionSet rolePermissions = getPermissions(role);

                    groupPermissions.add(rolePermissions);
                }
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

        assertNotNull(admin);

        Group global = ss.getGroupByName("global");
        assertNotNull(global);

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

        AccessControlList acl = ss.getACL(admin);
        assertFalse(acl.hasRole(app, global));

        ss.grant(admin, global, app);

        AccessControlList acl2 = ss.getACL(admin);
        assertTrue(acl2.hasRole(app, global));

        // Get existing ACL modified?
        assertFalse(acl.hasRole(app, global));

        try
        {
            ss.grant(admin, global, app);
            fail("Role could be granted twice!");
        }
        catch (Exception e)
        {
            //
            // Ugh. DataBackendError? This means that our query actually hit the database and only the "unique key"
            // prevented us from a double entry. This seems to be a bug
            //
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), DataBackendException.class, e.getClass());
        }

        try
        {
            Role unknown = ss.getRoleInstance("unknown");

            ss.grant(admin, global, unknown);
            fail("Nonexisting Role could be granted!");
        }
        catch (Exception e)
View Full Code Here

        assertNotNull(admin);

        Group global = ss.getGroupByName("global");
        assertNotNull(global);

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

        AccessControlList acl = ss.getACL(admin);
        assertTrue(acl.hasRole(app, global));

        ss.revoke(admin, global, app);

        AccessControlList acl2 = ss.getACL(admin);
        assertFalse(acl2.hasRole(app, global));

        // Get existing ACL modified?
        assertTrue(acl.hasRole(app, global));

         try
         {
             Role unknown = ss.getRoleInstance("unknown");
             ss.revoke(admin, global, unknown);
             fail("Nonexisting Role could be revoked!");
         }
         catch (Exception e)
         {
View Full Code Here

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

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

        ss.saveRole(admin);

        try
        {
            Role fake = ss.getRoleInstance("fake");

            ss.saveRole(fake);
            fail("Non Existing Role could be saved!");
        }
        catch (Exception e)
View Full Code Here

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

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

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

        ss.renameRole(test, "fake");

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

//
// Now this is a Turbine Bug...
//
View Full Code Here

    public boolean add(Collection roles)
    {
        boolean res = false;
        for (Iterator it = roles.iterator(); it.hasNext();)
        {
            Role r = (Role) it.next();
            res |= add(r);
        }
        return res;
    }
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.