You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/10/02 18:09:19 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/ac2 URLPolicy.java

andreas     2003/10/02 09:09:19

  Modified:    src/java/org/apache/lenya/cms/ac2 URLPolicy.java
  Log:
  Assigning role "visit" or "visitor" when no policy is defined.
  This allows "protection on demand", e.g. for the live area.
  
  Revision  Changes    Path
  1.12      +31 -3     cocoon-lenya/src/java/org/apache/lenya/cms/ac2/URLPolicy.java
  
  Index: URLPolicy.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/URLPolicy.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- URLPolicy.java	7 Aug 2003 10:23:27 -0000	1.11
  +++ URLPolicy.java	2 Oct 2003 16:09:19 -0000	1.12
  @@ -111,8 +111,21 @@
   	public Role[] getRoles(Identity identity) throws AccessControlException {
           obtainPolicies();
           Set roles = new HashSet();
  -        for (int i = 0; i < policies.length; i++) {
  -            addRoles(policies[i], identity, roles);
  +        
  +        // no policies defined: return "visit" or "visitor" role
  +        if (isEmpty()) {
  +            Role visitorRole = getAccreditableManager().getRoleManager().getRole("visit");
  +            if (visitorRole == null) {
  +                visitorRole = getAccreditableManager().getRoleManager().getRole("visitor");
  +            }
  +            if (visitorRole != null) {
  +                roles.add(visitorRole);
  +            }
  +        }
  +        else {
  +            for (int i = 0; i < policies.length; i++) {
  +                addRoles(policies[i], identity, roles);
  +            }
           }
   		return (Role[]) roles.toArray(new Role[roles.size()]);
   	}
  @@ -170,6 +183,21 @@
           }
           
           return ssl;
  +    }
  +
  +    /**
  +     * @see org.apache.lenya.cms.ac2.Policy#isEmpty()
  +     */
  +    public boolean isEmpty() throws AccessControlException {
  +        boolean empty = true;
  +        
  +        int i = 0;
  +        while (empty && i < policies.length) {
  +            empty = empty && policies[i].isEmpty();
  +            i++;
  +        }
  +        
  +        return empty;
       }
       
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org