Package org.apache.turbine.om.security

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


     * @throws UnknownEntityException if the role does not exist.
     */
    public Role getRoleByName(String name)
            throws DataBackendException, UnknownEntityException
    {
        Role role = getAllRoles().getRoleByName(name);
        if (role == null)
        {
            throw new UnknownEntityException(
                    "The specified role does not exist");
        }
        role.setPermissions(getPermissions(role));
        return role;
    }
View Full Code Here


     */
    public Role getRoleById(int id)
            throws DataBackendException,
                   UnknownEntityException
    {
        Role role = getAllRoles().getRoleById(id);
        if (role == null)
        {
            throw new UnknownEntityException(
                    "The specified role does not exist");
        }
        role.setPermissions(getPermissions(role));
        return 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

                // 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

                {
                    NamingEnumeration values = attr.getAll();

                    while (values.hasMore())
                    {
                        Role role = getRoleInstance(values.next().toString());

                        roles.add(role);
                    }
                }
                else
View Full Code Here

                Attributes attribs = sr.getAttributes();
                Attribute attr = attribs.get("turbineRoleName");

                if (attr != null && attr.get() != null)
                {
                    Role role = getRoleInstance(attr.get().toString());

                    roles.add(role);
                }
                else
                {
View Full Code Here

        {
            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

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.