Package org.apache.jetspeed.om.security

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


     */

    public void testGetRoles() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;
        HashMap map = new HashMap();

        try
        {
            Iterator roles = service.getRoles();
            while (roles.hasNext())
            {
                role = (Role)roles.next();
                map.put(role.getName(), role);
            }
            assertTrue(map.get("user") != null);
            assertTrue(map.get("admin") != null);
        }
        catch (Exception e)
View Full Code Here


     */

    public void testGetRolesForUser() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;
        HashMap map = new HashMap();

        try
        {
            Iterator roles = service.getRoles("turbine");
            while (roles.hasNext())
            {
              GroupRole gr = (GroupRole) roles.next();
                role = gr.getRole();
                map.put(role.getName(), role);
                System.out.println("role = " + role.getName());
            }
            assertTrue(map.get("user") != null);
            assertTrue(map.get("admin") == null);

            map.clear();
            roles = service.getRoles("admin");           
            while (roles.hasNext())
            {
                GroupRole gr = (GroupRole)roles.next();
                role = gr.getRole();
                map.put(role.getName(), role);
                System.out.println("role = " + role.getName());
            }
            assertTrue(map.get("user") != null);
            assertTrue(map.get("admin") != null);
        }
        catch (Exception e)
View Full Code Here

     */

    public void testAddRole() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;

        try
        {
            role = JetspeedRoleFactory.getInstance();
            role.setName("bogus");
            service.addRole(role);
            System.out.println("new role id = " + role.getId());
            assertTrue(role.getId() != null);
        }
        catch(Exception e)
        {
            fail(StringUtils.stackTrace(e));
        }
        try
        {
            role = JetspeedRoleFactory.getInstance();
            role.setName("bogus");
            service.addRole(role);
            fail("Should've thrown a dup key exception on role");
        }
        catch(Exception e)
        {
View Full Code Here

     */

    public void testRemoveRole() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;

        try
        {
            service.removeRole("bogus");
        }
View Full Code Here

    {
        RoleManagement service = getService();

        try
        {
            Role role = service.getRole("user");
            System.out.println("*** role nm = " + role.getName());
            System.out.println("*** role id = " + role.getId());
            assertTrue(role.getName().equals("user"));
        }
        catch (Exception e)
        {
            fail(StringUtils.stackTrace(e));
        }
View Full Code Here

    {
        RoleManagement service = getService();

        try
        {
            Role role = service.getRole("user");
            service.saveRole(role);
        }
        catch(Exception e)
        {
            fail(StringUtils.stackTrace(e));
View Full Code Here

     * @throws Exception
     */
    public void testGrantRole() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;

        try
        {
            service.grantRole("turbine", "admin");
        }
View Full Code Here

     * @throws Exception
     */
    public void testRevokeRole() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;

        try
        {
            service.revokeRole("turbine", "admin");
        }
View Full Code Here

     * @throws Exception
     */
    public void testHasRole() throws Exception
    {
        RoleManagement service = getService();
        Role role = null;

        try
        {
            boolean has = service.hasRole("admin", "admin");
            assertTrue(true == has);
View Full Code Here

    public void setRoleByName( String roleName )
    {
        try
        {
            Role temp = JetspeedSecurity.getRole(roleName);
            if (null != temp)
            {
                role = temp;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.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.