Package org.apache.jetspeed.om.registry

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


     * @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;
        Map ownerMap = null; // Map of owner allowed
        Map roleMap = null// Map of roles allowed
        Map userMap = null// Map of users allowed
        String userName = null;

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

        // Add allows to the action Map
        for (Iterator allowIterator = accessElement.getAllAllows().iterator(); allowIterator.hasNext();)
        {
            allowElement = (SecurityAllow) allowIterator.next();
            role = null;
            userName = 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();
            if (role != null)
            {
                roleMap = (Map) accessMap.get(ROLE_MAP);
                if (roleMap == null)
                {
                    roleMap = new HashMap();
                    accessMap.put(ROLE_MAP, roleMap);
                }
                roleMap.put(role, null);
            }

            // Add User
            userName = allowElement.getUser();
            if (userName != null)
            {
                userMap = (Map) accessMap.get(USER_MAP);
                if (userMap == null)
                {
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

     * @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;
        Map ownerMap = null; // Map of owner allowed
        Map roleMap = null// Map of roles allowed
        Map userMap = null// Map of users allowed
        String userName = null;

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

        // Add allows to the action Map
        for (Iterator allowIterator = accessElement.getAllAllows().iterator(); allowIterator.hasNext();)
        {
            allowElement = (SecurityAllow) allowIterator.next();
            role = null;
            userName = 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();
            if (role != null)
            {
                roleMap = (Map) accessMap.get(ROLE_MAP);
                if (roleMap == null)
                {
                    roleMap = new HashMap();
                    accessMap.put(ROLE_MAP, roleMap);
                }
                roleMap.put(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

      System.out.println("Action:" + access.getAction().toString());
     
      Vector allAllows = access.getAllAllows();
      for (Iterator it1 = allAllows.iterator(); it1.hasNext();)
      {
        SecurityAllow allow = (SecurityAllow) it1.next();
        System.out.println("Allow group: " + allow.getGroup() + ", role: " + allow.getRole() + ", user: " + allow.getUser());       
      }
    }   
   
    SecurityReference secRef = new BaseSecurityReference();
    secRef.setParent("powerusers_all-anon_view");
View Full Code Here

        Iterator i = allows.iterator();
        Iterator i2 = obj.getAllows().iterator();
        while (i.hasNext())
        {
            SecurityAllow c1 = (SecurityAllow) i.next();
            SecurityAllow c2 = null;

            if (i2.hasNext())
            {
                c2 = (SecurityAllow) i2.next();
            }
View Full Code Here

    {
        String allowType = rundata.getParameters().getString("allow_type");
        String allowValue = rundata.getParameters().getString("allow_value");
    String allowValue2 = rundata.getParameters().getString("allow_value2");

        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("group"))
        {
            allow = new BaseSecurityAllow();
            allow.setGroup(allowValue);

            securityAccess.getAllows().add(allow);
        }
    else if (allowType.equals("groupRole"))
    {
      allow = new BaseSecurityAllow();
      allow.setGroup(allowValue);
      allow.setRole(allowValue2);

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

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

      System.out.println("Action:" + access.getAction().toString());
     
      Vector allAllows = access.getAllAllows();
      for (Iterator it1 = allAllows.iterator(); it1.hasNext();)
      {
        SecurityAllow allow = (SecurityAllow) it1.next();
        System.out.println("Allow group: " + allow.getGroup() + ", role: " + allow.getRole() + ", user: " + allow.getUser());       
      }
    }   
   
    SecurityReference secRef = new BaseSecurityReference();
    secRef.setParent("powerusers_all-anon_view");
View Full Code Here

        Iterator i = allows.iterator();
        Iterator i2 = obj.getAllows().iterator();
        while (i.hasNext())
        {
            SecurityAllow c1 = (SecurityAllow) i.next();
            SecurityAllow c2 = null;

            if (i2.hasNext())
            {
                c2 = (SecurityAllow) i2.next();
            }
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.