You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by pn...@apache.org on 2004/01/14 16:56:07 UTC

cvs commit: jakarta-slide/src/share/org/apache/slide/security ACLSecurityImpl.java

pnever      2004/01/14 07:56:07

  Modified:    src/share/org/apache/slide/security ACLSecurityImpl.java
  Log:
  Changed/added hasRole() and getRoles().
  
  Revision  Changes    Path
  1.6       +33 -36    jakarta-slide/src/share/org/apache/slide/security/ACLSecurityImpl.java
  
  Index: ACLSecurityImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/ACLSecurityImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ACLSecurityImpl.java	1 Dec 2003 12:10:49 -0000	1.5
  +++ ACLSecurityImpl.java	14 Jan 2004 15:56:07 -0000	1.6
  @@ -63,6 +63,7 @@
   package org.apache.slide.security;
   
   import java.util.Enumeration;
  +import java.util.Vector;
   import org.apache.slide.common.Namespace;
   import org.apache.slide.common.NamespaceConfig;
   import org.apache.slide.common.ServiceAccessException;
  @@ -76,9 +77,7 @@
   import org.apache.slide.structure.ObjectNode;
   import org.apache.slide.structure.ObjectNotFoundException;
   import org.apache.slide.structure.SubjectNode;
  -import org.apache.slide.util.XMLValue;
   import org.apache.slide.util.logger.Logger;
  -import org.jdom.JDOMException;
   
   /**
    * WebDAV/ACL compliant security helper implementation (draft-12)
  @@ -89,6 +88,7 @@
   public final class ACLSecurityImpl extends SecurityImpl {
       
       private static final String LOG_CHANNEL = ACLSecurityImpl.class.getName();
  +    private static final Vector EMPTY_VECTOR = new Vector();
       
       /**
        * Constructor.
  @@ -160,42 +160,39 @@
           return evaluateAcl(token, objectNode, actionNode, permissions);
       }
       
  -
  +    // overwrites super
       public boolean hasRole(SlideToken token, String role) throws ServiceAccessException, ObjectNotFoundException {
  -
  -        ObjectNode subject = getPrincipal(token);
  -
  -        if (role.equals(NamespaceConfig.NOBODY)) {
  -            return true;
  -        } else {
  -            try {
  -                Uri roleUri = namespace.getUri(token, namespaceConfig.getRolesPath() + "/" + role);
  -                
  -                NodeRevisionDescriptor nrd =
  -                roleUri.getStore().retrieveRevisionDescriptor(roleUri, new NodeRevisionNumber());
  -                NodeProperty membersetProp = nrd.getProperty("group-member-set");
  -                if (membersetProp != null && membersetProp.getValue() != null) {
  -                    XMLValue xmlVal = new XMLValue((String) membersetProp.getValue());
  -                    return xmlVal.getHrefNodes().contains(subject);
  -                } else {
  -                    return false;
  -                }
  -            } catch (RevisionDescriptorNotFoundException e) {
  -                return false;
  -            } catch (ServiceAccessException e) {
  -                throw e;
  -            } catch (JDOMException e) {
  -                e.printStackTrace();
  -                return false;
  -            }
  -        }
  +        SubjectNode subjectNode = (SubjectNode)getPrincipal(token);
  +        SubjectNode roleNode = SubjectNode.getSubjectNode(namespaceConfig.getRolesPath()+"/"+role);
  +        return matchPrincipal(token, subjectNode, roleNode);
       }
       
  +    // overwrites super
       public boolean hasRole(ObjectNode object, String role) throws ServiceAccessException, ObjectNotFoundException {
  -
           throw new UnsupportedOperationException("Please use alternate signature: hasRole(SlideToken token, String role)");
       }
  -        
  +    
  +    // overwrites super
  +    public Enumeration getRoles(SlideToken token) throws ServiceAccessException, ObjectNotFoundException {
  +        Vector result = new Vector();
  +        Uri rolesUri = namespace.getUri(token, namespaceConfig.getRolesPath());
  +        ObjectNode rolesNode = rolesUri.getStore().retrieveObject(rolesUri);
  +        Enumeration rolesEnum = rolesNode.enumerateBindings();
  +        while (rolesEnum.hasMoreElements()) {
  +            ObjectNode.Binding b = (ObjectNode.Binding)rolesEnum.nextElement();
  +            String role = b.getName();
  +            if (hasRole(token, role)) {
  +                result.add(role);
  +            }
  +        }
  +        return result.elements();
  +    }
  +    
  +    // overwrites super
  +    public Enumeration getRoles(ObjectNode object) {
  +        return EMPTY_VECTOR.elements();
  +    }
  +    
       /**
        * Evaluates speified ACL by first-match principle
        */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org