Package org.apache.jetspeed.om.registry

Examples of org.apache.jetspeed.om.registry.SecurityAllow


            assertEquals("Verify action", "view", securityAccess.getAction());

            // Get allows
            Vector securityAllows = securityAccess.getAllows();
            assertNotNull("Got SecurityAllows", securityAllows);
            SecurityAllow securityAllow = (SecurityAllow) securityAllows.firstElement();
            assertNotNull("Got SecurityAllow", securityAllow);
            assertEquals("Verify role", "clerk", securityAllow.getRole());
            assertNull("Verify user" , securityAllow.getUser());

            securityAllow = (SecurityAllow) securityAllows.elementAt(1);
            assertNotNull("Got SecurityAllow", securityAllow);
            assertNull("Verify role", securityAllow.getRole());
            assertEquals("Verify user", "joe", securityAllow.getUser());

            securityAllow = (SecurityAllow) securityAllows.elementAt(2);
            assertNotNull("Got SecurityAllow", securityAllow);
            assertEquals("Verify role", "manager", securityAllow.getRole());
            assertEquals("Verify user", "fred", securityAllow.getUser());

            // test allows
            assertEquals("clerk role can view", true, securityEntry.allowsRole("clerk", "view"));
            assertEquals("manager role can view", true, securityEntry.allowsRole("manager", "view"));
            assertEquals("anonymous role can NOT view", false, securityEntry.allowsRole("anonymous", "view"));
View Full Code Here


                sade.save(conn);
               
                Iterator allows = access.getAllAllows().iterator();
                while (allows.hasNext())
                {
                    SecurityAllow allow = (SecurityAllow)allows.next();
                    SecurityAllowDbEntry sa = new SecurityAllowDbEntry();
                    if (allow.isOwner())
                    {
                        sa.setAllowType(ALLOW_OWNER);
                        sa.setAllowValue(ALLOW_OWNER);
                    }
                    else if (allow.getRole() != null && allow.getGroup() != null)
                    {
                        sa.setAllowType(ALLOW_BOTH);
                        sa.setAllowValue(allow.getRole());                       
                        sa.setAllowGroup(allow.getGroup());
                    }
                    else if (allow.getRole() != null)
                    {
                        sa.setAllowType(ALLOW_ROLE);
                        sa.setAllowValue(allow.getRole());                       
                    }
                    else if (allow.getGroup() != null)
                    {
                        sa.setAllowType(ALLOW_GROUP);
                        sa.setAllowValue(allow.getGroup());                       
                    }
                    else
                    {
                        sa.setAllowType(ALLOW_USER);
                        sa.setAllowValue(allow.getUser());
                    }
                    sa.setAccessId(sade.getId());
                    sa.save(conn);   
                }               
            }           
View Full Code Here

            while (allows.hasNext())
            {
                SecurityAllowDbEntry sa = (SecurityAllowDbEntry)allows.next();
                if (sa.getAllowType().equals(ALLOW_OWNER))
                {
                    SecurityAllow allow = new BaseSecurityAllowOwner(sa.getId());                   
                    allow.setOwner(true);
                    access.getOwnerAllows().add(allow);
                }
                else if (sa.getAllowType().equals(ALLOW_BOTH))
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());
                   
                    allow.setRole(sa.getAllowValue());
                    allow.setGroup(sa.getAllowGroup());
                    access.getAllows().add(allow);               
                }
                else if (sa.getAllowType().equals(ALLOW_ROLE))
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());
                   
                    allow.setRole(sa.getAllowValue());
                    access.getAllows().add(allow);
                }
                else if (sa.getAllowType().equals(ALLOW_GROUP))
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());
                   
                    allow.setGroup(sa.getAllowValue());
                    access.getAllows().add(allow);
                }
                else
                {
                    SecurityAllow allow = new BaseSecurityAllow(sa.getId());                   
                    allow.setUser(sa.getAllowValue());
                    access.getAllows().add(allow);
                }                   
            }
            se.getAccesses().add(access);
        }
View Full Code Here

            if (allows != null)
            {           
                Iterator allAllows = allows.iterator();
                while (allAllows.hasNext())
                {
                    SecurityAllow allow = (SecurityAllow) allAllows.next();
                    if (allow.getRole() != null && allow.getRole().equals(role))
                    {
                        return true;
                    }
                }
            }
View Full Code Here

            if (allows != null)
            {
                Iterator allAllows = allows.iterator();
                while (allAllows.hasNext())
                {
                    SecurityAllow allow = (SecurityAllow) allAllows.next();
                    if (allow.getGroup() != null && allow.getGroup().equals(group))
                    {
                        return true;
                    }
                }
      }
View Full Code Here

            if (allows != null)
            {
          Iterator allAllows = allows.iterator();
          while (allAllows.hasNext())
          {
            SecurityAllow allow = (SecurityAllow) allAllows.next();
            if (allow.getGroup() != null &&
              allow.getGroup().equals(group) &&
              allow.getRole() != null &&
              allow.getRole().equals(role))
            {
              return true;
            }
          }
            }
View Full Code Here

     * @param accessMap to receive accessElements
     * @param accessElement to copy to access map
     */
    private void addAllows(Map accessMap, SecurityAccess accessElement)
    {
        SecurityAllow allowElement = null;
        String role = null;
        String group = null;
        Map ownerMap = null; // Map of owner allowed
        Map roleMap = null// Map of roles allowed
    Map groupMap = null// Map of groups allowed       
    Map groupRoleMap = null// Map of group role allowed   
        Map userMap = null// Map of users allowed
        String userName = null;

        List all = accessElement.getAllAllows();
        if (all == null)
        {
            return;
        }

        // Add allows to the action Map
        for (Iterator allowIterator = all.iterator(); allowIterator.hasNext();)
        {
            allowElement = (SecurityAllow) allowIterator.next();
            role = null;
            userName = null;
      group = null;

            // Add Owner
            if (allowElement.isOwner() == true)
            {
                ownerMap = (Map) accessMap.get(OWNER_MAP);
                if (ownerMap == null)
                {
                    ownerMap = new HashMap();
                    accessMap.put(OWNER_MAP, ownerMap);
                }
                ownerMap.put(null, null);
            }

            // Add Role
            role = allowElement.getRole();
      group = allowElement.getGroup();           
            if (role != null)
            {
              // Role map
                roleMap = (Map) accessMap.get(ROLE_MAP);
                if (roleMap == null)
                {
                    roleMap = new HashMap();
                    accessMap.put(ROLE_MAP, roleMap);
                }
                roleMap.put(role, null);
       
        // Group role map               
        groupRoleMap = (Map) accessMap.get(GROUP_ROLE_MAP);
        if (groupRoleMap == null)
        {
          groupRoleMap = new HashMap();
          accessMap.put(GROUP_ROLE_MAP, groupRoleMap);
        }
        if (group == null)
        {
          group = GroupManagement.DEFAULT_GROUP_NAME;
        }
        groupRoleMap.put(group+role, null);
               
            }

      // Add Group
      if (group != null)
      {
        // Group map
        groupMap = (Map) accessMap.get(GROUP_MAP);
        if (groupMap == null)
        {
          groupMap = new HashMap();
          accessMap.put(GROUP_MAP, groupMap);
        }
        groupMap.put(group, null);
       
        // Group role map               
        groupRoleMap = (Map) accessMap.get(GROUP_ROLE_MAP);
        if (groupRoleMap == null)
        {
          groupRoleMap = new HashMap();
          accessMap.put(GROUP_ROLE_MAP, groupRoleMap);
        }
        if (role == null)
        {
          role = RoleManagement.DEFAULT_ROLE_NAME;
        }
        groupRoleMap.put(group+role, null);
       
      }

            // Add User
            userName = allowElement.getUser();
            if (userName != null)
            {
                userMap = (Map) accessMap.get(USER_MAP);
                if (userMap == null)
                {
View Full Code Here

    private void addAllow(RunData rundata, BaseSecurityAccess securityAccess)
    {
        String allowType = rundata.getParameters().getString("allow_type");
        String allowValue = rundata.getParameters().getString("allow_value");

        SecurityAllow allow = null;
        if (allowType.equals("user"))
        {
            allow = new BaseSecurityAllow();
            allow.setUser(allowValue);
            securityAccess.getAllows().add(allow);
        }
        else if (allowType.equals("role"))
        {
            allow = new BaseSecurityAllow();
            allow.setRole(allowValue);

            securityAccess.getAllows().add(allow);
        }
        else if (allowType.equals("owner"))
        {
            allow = new BaseSecurityAllowOwner();
            allow.setOwner(true);

            securityAccess.getOwnerAllows().add(allow);
        }
        else
        {
View Full Code Here

            assertEquals("Verify action", "view", securityAccess.getAction());

            // Get allows
            Vector securityAllows = securityAccess.getAllows();
            assertNotNull("Got SecurityAllows", securityAllows);
            SecurityAllow securityAllow = (SecurityAllow) securityAllows.firstElement();
            assertNotNull("Got SecurityAllow", securityAllow);
            assertEquals("Verify role", "clerk", securityAllow.getRole());
            assertNull("Verify user" , securityAllow.getUser());

            securityAllow = (SecurityAllow) securityAllows.elementAt(1);
            assertNotNull("Got SecurityAllow", securityAllow);
            assertNull("Verify role", securityAllow.getRole());
            assertEquals("Verify user", "joe", securityAllow.getUser());

            securityAllow = (SecurityAllow) securityAllows.elementAt(2);
            assertNotNull("Got SecurityAllow", securityAllow);
            assertEquals("Verify role", "manager", securityAllow.getRole());
            assertEquals("Verify user", "fred", securityAllow.getUser());

            // test allows
            assertEquals("clerk role can view", true, securityEntry.allowsRole("clerk", "view"));
            assertEquals("manager role can view", true, securityEntry.allowsRole("manager", "view"));
            assertEquals("anonymous role can NOT view", false, securityEntry.allowsRole("anonymous", "view"));
View Full Code Here

        if (access.getAllAllows() != null)
        {
            Iterator allAllows = access.getAllows().iterator();
            while (allAllows.hasNext())
            {
                SecurityAllow allow = (SecurityAllow) allAllows.next();
                if (allow.getRole() != null && allow.getRole().equals(role))
                {
                    return true;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.registry.SecurityAllow

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.