Package org.apache.turbine.om.security

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


        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

     * @return <code>true</code> if the user is assigned the Role in any of
     *         the given Groups.
     */
    public boolean hasRole(String rolename, GroupSet groupset)
    {
        Role role;
        try
        {
            role = TurbineSecurity.getRoleByName(rolename);
        }
        catch (TurbineSecurityException e)
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

    public boolean add(RoleSet roleSet)
    {
        boolean res = false;
        for( Iterator it = roleSet.iterator(); it.hasNext();)
        {
            Role r = (Role) it.next();
            res |= add(r);
        }
        return res;
    }
View Full Code Here

        StringBuffer sb = new StringBuffer();
        sb.append("RoleSet: ");

        for(Iterator it = iterator(); it.hasNext();)
        {
            Role r = (Role) it.next();
            sb.append('[');
            sb.append(r.getName());
            sb.append(" -> ");
            sb.append(r.getIdAsObj());
            sb.append(']');
            if (it.hasNext())
            {
                sb.append(", ");
            }
View Full Code Here

     * @throws UnknownEntityException if the object could not be instantiated.
     */
    public Role getRoleInstance()
            throws UnknownEntityException
    {
        Role role;

        try
        {
            role = (Role) getRoleClass().newInstance();
        }
View Full Code Here

     * @throws UnknownEntityException if the object could not be instantiated.
     */
    public Role getRoleInstance(String roleName)
            throws UnknownEntityException
    {
        Role role = getRoleInstance();
        role.setName(roleName);
        return 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.