cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/webapp/samples/slide rdf2html.xsl slide.xconf
Date Mon, 01 Jul 2002 16:41:55 GMT
stephan     2002/07/01 09:41:55

  Modified:    src/scratchpad/src/org/apache/cocoon/components/source
                        RestrictableSource.java
               src/scratchpad/src/org/apache/cocoon/components/source/helpers
                        SourcePermission.java
               src/scratchpad/src/org/apache/cocoon/components/source/impl
                        SlideSource.java WebDAVSource.java
               src/scratchpad/src/org/apache/cocoon/generation
                        SourceDescriptionGenerator.java
               src/scratchpad/webapp/samples/slide rdf2html.xsl slide.xconf
  Log:
  Change the interface RestrictableSource to create the possibility
  to grant permission.
  Add the implementation to SlideSource.
  
  Revision  Changes    Path
  1.4       +7 -6      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/RestrictableSource.java
  
  Index: RestrictableSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/RestrictableSource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RestrictableSource.java	30 Jun 2002 19:53:40 -0000	1.3
  +++ RestrictableSource.java	1 Jul 2002 16:41:54 -0000	1.4
  @@ -56,6 +56,7 @@
   package org.apache.cocoon.components.source;
   
   import org.apache.cocoon.components.source.helpers.SourceCredential;
  +import org.apache.cocoon.components.source.helpers.SourcePermission;
   
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
  @@ -78,20 +79,20 @@
        */
       public void setSourceCredential(SourceCredential sourcecredential) throws SourceException;
   
  -    /*
  +    /**
        * Set a permission to this source
        *
        * @param sourcepermission Permission, which should be set
        *
        * @throws SourceException If an exception occurs during this operation
  -     *
  +     */
       public void setSourcePermission(SourcePermission sourcepermission) throws SourceException;
   
  -    /*
  +    /**
        * Returns a list of the existing permissions
        *
        * @return Array of SourcePermission
  -     *
  -    public SourcePermission[] getSourcePermissions() throws SourceException;*/
  +     */
  +    public SourcePermission[] getSourcePermissions() throws SourceException;
   }
   
  
  
  
  1.3       +3 -3      xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/helpers/SourcePermission.java
  
  Index: SourcePermission.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/helpers/SourcePermission.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SourcePermission.java	30 Jun 2002 19:53:40 -0000	1.2
  +++ SourcePermission.java	1 Jul 2002 16:41:55 -0000	1.3
  @@ -71,8 +71,8 @@
       public final static String PRIVILEGE_READ              = "read";
       public final static String PRIVILEGE_WRITE             = "write";
   
  -    //public final static String PRIVILEGE_READ_ACL          = "read-acl";
  -    //public final static String PRIVILEGE_WRITE_ACL         = "write-acl";
  +    public final static String PRIVILEGE_READ_ACL          = "read-acl";
  +    public final static String PRIVILEGE_WRITE_ACL         = "write-acl";
   
       public final static String PRIVILEGE_READ_SOURCE       = "read-source";
       public final static String PRIVILEGE_CREATE_SOURCE     = "create-source";
  
  
  
  1.8       +319 -27   xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SlideSource.java
  
  Index: SlideSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/SlideSource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SlideSource.java	30 Jun 2002 23:14:55 -0000	1.7
  +++ SlideSource.java	1 Jul 2002 16:41:55 -0000	1.8
  @@ -87,6 +87,7 @@
   import org.apache.slide.authenticate.SecurityToken;
   import org.apache.slide.common.EmbeddedDomain;
   import org.apache.slide.common.NamespaceAccessToken;
  +import org.apache.slide.common.NamespaceConfig;
   import org.apache.slide.common.SlideException;
   import org.apache.slide.common.SlideToken;
   import org.apache.slide.common.SlideTokenImpl;
  @@ -117,6 +118,7 @@
   import java.io.OutputStream;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.ArrayList;
   import java.util.Date;
   import java.util.Enumeration;
   import java.util.Iterator;
  @@ -457,7 +459,7 @@
   
                   // Owner
                   //revisionDescriptor.setOwner(
  -                //    slideToken.getCredentialsToken().getPublicCredentials());
  +                //    slideToken.getCredentialthis.slideToken().getPublicCredentials());
   
                   // Creating revisionDescriptor associated with the object
                   NodeRevisionContent revisionContent =
  @@ -650,42 +652,332 @@
        * @throws SourceException If an exception occurs during this operation
        **/
       public void setSourcePermission(SourcePermission sourcepermission) throws SourceException
{
  -        /*NodePermission permission = 
  -            new NodePermission(this.uri, sourcepermission.getSubject(), action, 
  -                               sourcepermission.isInheritable(),
  -                               sourcepermission.isNegative());
  -        this.security.grantPermission(this.slideToken, permission);*/
   
  -        throw new SourceException("Operation not yet supported");
  +        NamespaceConfig config = this.nat.getNamespaceConfig();
  +
  +        String principal = config.getUsersPath()+"/"+sourcepermission.getPrincipal();
  +        boolean negative = sourcepermission.isNegative();
  +        boolean inheritable = sourcepermission.isInheritable();
  +
  +        if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_ALL)) {
  +            addPermission(principal, "/", negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ))
{ 
  +            addPermission(principal, config.getReadObjectAction().getUri(), negative, inheritable);
  +            addPermission(principal, config.getReadLocksAction().getUri(), negative, inheritable);
  +            addPermission(principal, config.getReadRevisionMetadataAction().getUri(), negative,
inheritable);
  +            addPermission(principal, config.getReadRevisionContentAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_SOURCE))
{
  +            addPermission(principal, config.getReadObjectAction().getUri(), negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_LOCKS))
{
  +            addPermission(principal, config.getReadLocksAction().getUri(), negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_PROPERTY))
{
  +            addPermission(principal, config.getReadRevisionMetadataAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_CONTENT))
{
  +            addPermission(principal, config.getReadRevisionContentAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE))
{
  +            addPermission(principal, config.getCreateObjectAction().getUri(), negative,
inheritable);
  +            addPermission(principal, config.getRemoveObjectAction().getUri(), negative,
inheritable);
  +            addPermission(principal, config.getLockObjectAction().getUri(), negative, inheritable);
  +            addPermission(principal, config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
  +            addPermission(principal, config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
  +            addPermission(principal, config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
  +            addPermission(principal, config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
  +            addPermission(principal, config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
  +            addPermission(principal, config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_SOURCE))
{
  +            addPermission(principal, config.getCreateObjectAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_SOURCE))
{
  +            addPermission(principal, config.getRemoveObjectAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_LOCK_SOURCE))
{
  +            addPermission(principal, config.getLockObjectAction().getUri(), negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_PROPERTY))
{
  +            addPermission(principal, config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_PROPERTY))
{
  +            addPermission(principal, config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_PROPERTY))
{
  +            addPermission(principal, config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_CONTENT))
{
  +            addPermission(principal, config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_CONTENT))
{
  +            addPermission(principal, config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_CONTENT))
{
  +            addPermission(principal, config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_ACL))
{
  +            addPermission(principal, config.getReadPermissionsAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE_ACL))
{
  +            addPermission(principal, config.getGrantPermissionAction().getUri(), negative,
inheritable);
  +            addPermission(principal, config.getRevokePermissionAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_GRANT_PERMISSION))
{
  +            addPermission(principal, config.getGrantPermissionAction().getUri(), negative,
inheritable);
  +        } else if (sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REVOKE_PERMISSION))
{
  +            addPermission (principal, config.getRevokePermissionAction().getUri(), negative,
inheritable);
  +        }
       }
   
       /**
  -     * Returns a list of the existing permissions
  +     * Add permission to the list of permissions to set.
  +     */
  +    private void addPermission(String principal, String action,
  +                               boolean negative, boolean inheritable) throws SourceException
{
  +        try {
  +            NodePermission permission = new NodePermission
  +                (this.uri, principal, action, inheritable, negative);
  +            this.security.grantPermission(this.slideToken, permission);
  +        } catch (SlideException se) {
  +            getLogger().warn("Couldn't grant permission", se);
  +            throw new SourceException("Couldn't grant permission", se);
  +        }
  +    }
  +
  +    /**
  +     * Returns a list of the existing permissions.
  +     * Based on the implementation of org.apache.slide.webdav.util.PropertyHelper .
        *
        * @return Array of SourcePermission
        **/
       public SourcePermission[] getSourcePermissions() throws SourceException {
  -        /*try {
  -            Vector sourcepermissions = new Vector();
  +        try {
   
  -            NodePermission permission;
  -            for(Enumeration permissions = this.security.enumeratePermissions(this.slideToken,
this.uri);
  -                permissions.hasMoreElements();) {
  -
  -                permission = (NodePermission) permissions.nextElement();
  -
  -                sourcepermissions.addElement(new SourcePermission(permission.getSubjectUri(),
  -                                                                  permission.getActionUri(),
  -                                                                  permission.isInheritable(),
  -                                                                  permission.isNegative()));
  -            }
  +            NamespaceConfig config = this.nat.getNamespaceConfig();
   
  -            return sourcepermissions.elements();
  -        } catch (SlideException se) {
  -            throw new SourceException("Could not retrieve permissions", se);
  -        }*/
  +            ObjectNode current = structure.retrieve(this.slideToken, this.uri);
  +
  +            security.checkCredentials(this.slideToken, current, config.getReadPermissionsAction());
  +
  +            String userspath = config.getUsersPath();
  +
  +            // read
  +            String readObjectUri = config.getReadObjectAction().getUri();
  +            String readRevisionMetadataUri =
  +                config.getReadRevisionMetadataAction().getUri();
  +            String readRevisionContentUri =
  +                config.getReadRevisionContentAction().getUri();
  +
  +            // write
  +            String createObjectUri = config.getCreateObjectAction().getUri();
  +            String removeObjectUri = config.getRemoveObjectAction().getUri();
  +            String lockObjectUri = config.getLockObjectAction().getUri();
  +            String readLocksUri = config.getReadLocksAction().getUri();
  +            String createRevisionMetadataUri =
  +                config.getCreateRevisionMetadataAction().getUri();
  +            String modifyRevisionMetadataUri =
  +                config.getModifyRevisionMetadataAction().getUri();
  +            String removeRevisionMetadataUri =
  +                config.getRemoveRevisionMetadataAction().getUri();
  +            String createRevisionContentUri =
  +                config.getCreateRevisionContentAction().getUri();
  +            String modifyRevisionContentUri =
  +                config.getModifyRevisionContentAction().getUri();
  +            String removeRevisionContentUri =
  +                config.getRemoveRevisionContentAction().getUri();
  +
  +            // read-acl
  +            String readPermissionsUri = config.getReadPermissionsAction().getUri();
  +
  +            // write-acl
  +            String grantPermissionUri = config.getGrantPermissionAction().getUri();
  +            String revokePermissionUri =
  +                config.getRevokePermissionAction().getUri();
   
  -        throw new SourceException("Operation not yet supported");
  +            boolean inheritedPermissions = false;
  +            Vector permissions = new Vector();
  +
  +            ArrayList sourcepermissions = new ArrayList();
  +
  +            while (current != null) {
  +            
  +                try {
  +                    // put all permissions in a list
  +                    permissions.clear();
  +                    Enumeration aclList = security.enumeratePermissions(this.slideToken,
current);
  +                    while (aclList.hasMoreElements()) {
  +                    
  +                        NodePermission permission = (NodePermission) aclList.nextElement();
  +    
  +                        // if we are processing inheritedPermissions (from parent and up)
  +                        // then the permission should be inheritable
  +                        if (inheritedPermissions && !permission.isInheritable())
{
  +                            // continue with next permission
  +                            continue;
  +                        }
  +                        permissions.add(permission);
  +                    }
  +
  +                    // start combining and writing the permissions
  +                    while (permissions.size()>0) {
  +                    
  +                        NodePermission permission = (NodePermission) permissions.get(0);
  +                        permissions.remove(0);
  +
  +                        String principal = permission.getSubjectUri();
  +                        boolean negative = permission.isNegative();
  +
  +                        String action    = permission.getActionUri();
  +
  +                        // read
  +                        boolean isReadObject           = readObjectUri.startsWith(action);
  +                        boolean isReadLocks            = readLocksUri.startsWith(action);
  +                        boolean isReadRevisionMetadata = readRevisionMetadataUri.startsWith(action);
  +                        boolean isReadRevisionContent  = readRevisionContentUri.startsWith(action);
  +
  +                        // write
  +                        boolean isCreateObject           = createObjectUri.startsWith(action);
  +                        boolean isRemoveObject           = removeObjectUri.startsWith(action);
  +                        boolean isLockObject             = lockObjectUri.startsWith(action);
  +                        boolean isCreateRevisionMetadata = createRevisionMetadataUri.startsWith(action);
  +                        boolean isModifyRevisionMetadata = modifyRevisionMetadataUri.startsWith(action);
  +                        boolean isRemoveRevisionMetadata = removeRevisionMetadataUri.startsWith(action);
  +                        boolean isCreateRevisionContent  = createRevisionContentUri.startsWith(action);
  +                        boolean isModifyRevisionContent  = modifyRevisionContentUri.startsWith(action);
  +                        boolean isRemoveRevisionContent  = removeRevisionContentUri.startsWith(action);
  +
  +                        //read-acl
  +                        boolean isReadPermissions = readPermissionsUri.startsWith(action);
  +
  +                        // write-acl
  +                        boolean isGrantPermission  = grantPermissionUri.startsWith(action);
  +                        boolean isRevokePermission = revokePermissionUri.startsWith(action);
  +
  +                        // check the other permissions to combine them
  +                        // (if they are for the same principal/negative)
  +                        for (int i=0; i<permissions.size() ; i++) {
  +                            NodePermission otherPermission = (NodePermission) permissions.get(i);
  +                            if (principal.equals(otherPermission.getSubjectUri()) &&
  +                                (negative==otherPermission.isNegative())) {
  +
  +                                permissions.remove(i);
  +                                i--; // because we removed the current one
  +
  +                                action    = otherPermission.getActionUri();
  +
  +                                // read
  +                                isReadObject           |= readObjectUri.startsWith(action);
  +                                isReadLocks            |= readLocksUri.startsWith(action);
  +                                isReadRevisionMetadata |= readRevisionMetadataUri.startsWith(action);
  +                                isReadRevisionContent  |= readRevisionContentUri.startsWith(action);
  +
  +                                // write
  +                                isCreateObject           |= createObjectUri.startsWith(action);
  +                                isRemoveObject           |= removeObjectUri.startsWith(action);
  +                                isLockObject             |= lockObjectUri.startsWith(action);
  +                                isCreateRevisionMetadata |= createRevisionMetadataUri.startsWith(action);
  +                                isModifyRevisionMetadata |= modifyRevisionMetadataUri.startsWith(action);
  +                                isRemoveRevisionMetadata |= removeRevisionMetadataUri.startsWith(action);
  +                                isCreateRevisionContent  |= createRevisionContentUri.startsWith(action);
  +                                isModifyRevisionContent  |= modifyRevisionContentUri.startsWith(action);
  +                                isRemoveRevisionContent  |= removeRevisionContentUri.startsWith(action);
  +
  +                                //read-acl
  +                                isReadPermissions |= readPermissionsUri.startsWith(action);
  +
  +                                // write-acl
  +                                isGrantPermission  |= grantPermissionUri.startsWith(action);
  +                                isRevokePermission |= revokePermissionUri.startsWith(action);
  +                            }
  +                        }
  +
  +                        // WebDAV privileges
  +                        boolean isRead = isReadObject && isReadLocks &&
  +                            isReadRevisionMetadata && isReadRevisionContent;
  +
  +                        boolean isWrite = isCreateObject && isRemoveObject &&
isLockObject &&
  +                            isCreateRevisionMetadata  && isModifyRevisionMetadata
&&
  +                            isRemoveRevisionMetadata &&
  +                            isCreateRevisionContent && isModifyRevisionContent
&&
  +                            isRemoveRevisionContent;
  +
  +                        boolean isReadAcl = isReadPermissions;
  +      
  +                        boolean isWriteAcl = isGrantPermission && isRevokePermission;
  +
  +                        boolean isAll = isRead && isWrite && isReadAcl
&& isWriteAcl;
  +
  +
  +                        SourcePermission sourcepermission = new SourcePermission(null,
null,
  +                                                                                 inheritedPermissions,
negative);
  +
  +                        if (principal.equals("~"))
  +                            sourcepermission.setPrincipal(SourcePermission.PRINCIPAL_SELF);
  +                        else if (principal.equals("nobody")) 
  +                            sourcepermission.setPrincipal(SourcePermission.PRINCIPAL_GUEST);
  +                        else if (principal.startsWith(userspath+"/"))
  +                            sourcepermission.setPrincipal(principal.substring(userspath.length()+1));
  +                        else
  +                            sourcepermission.setPrincipal(principal);
  +
  +                        if (isAll) {
  +                            sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_ALL);
  +                        } else {
  +                            if (isRead) {
  +                                sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ);
  +                            } else {
  +                                if (isReadObject)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_SOURCE);
  +                                if (isReadLocks)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_LOCKS);
  +                                if (isReadRevisionMetadata)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_PROPERTY);
  +                                if (isReadRevisionContent)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_CONTENT);
  +                            }
  +                            if (isWrite) {
  +                                sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_WRITE);
  +                            } else {
  +                                if (isCreateObject)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_SOURCE);
  +                                if (isRemoveObject)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_SOURCE);
  +                                if (isLockObject)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_LOCK_SOURCE);
  +                                if (isCreateRevisionMetadata)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_PROPERTY);
  +                                if (isModifyRevisionMetadata)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_MODIFY_PROPERTY);
  +                                if (isRemoveRevisionMetadata)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_PROPERTY);
  +                                if (isCreateRevisionContent)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_CONTENT);
  +                                if (isModifyRevisionContent)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_MODIFY_CONTENT);
  +                                if (isRemoveRevisionContent)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_CONTENT);
  +                            }
  +                            if (isReadAcl) {
  +                                sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_ACL);
  +                            }
  +                            if (isWriteAcl) {
  +                                sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_WRITE_ACL);
  +                            } else {
  +                                if (isGrantPermission)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_GRANT_PERMISSION);
  +                                if (isRevokePermission)
  +                                    sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REVOKE_PERMISSION);
  +                            }
  +                        }
  +
  +                        sourcepermissions.add(sourcepermission);
  +                    }
  +                } catch (SlideException se) {
  +                    getLogger().error("Exception eccurs while retrieveing source permission",
se);
  +                    throw new SourceException("Exception eccurs while retrieveing source
permission", se);
  +                }
  +
  +                inheritedPermissions = true;
  +  
  +                try {
  +                    current = structure.getParent(this.slideToken, current);
  +                } catch (SlideException e) {
  +                    break;
  +                }
  +            } 
  +
  +            SourcePermission[] sourcepermissionArray = new SourcePermission[sourcepermissions.size()];
  +            return (SourcePermission[]) sourcepermissions.toArray((Object[])sourcepermissionArray);
  +
  +        } catch (SlideException se) {
  +            getLogger().error("Exception eccurs while retrieveing source permission", se);
  +            throw new SourceException("Exception eccurs while retrieveing source permission",
se);
  +        }
       }
   
       /**
  
  
  
  1.2       +22 -1     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/WebDAVSource.java
  
  Index: WebDAVSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/impl/WebDAVSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebDAVSource.java	21 Jun 2002 13:39:43 -0000	1.1
  +++ WebDAVSource.java	1 Jul 2002 16:41:55 -0000	1.2
  @@ -60,6 +60,7 @@
   import org.apache.cocoon.components.source.RestrictableSource;
   import org.apache.cocoon.components.source.WriteableSource;
   import org.apache.cocoon.components.source.helpers.SourceCredential;
  +import org.apache.cocoon.components.source.helpers.SourcePermission;
   
   import org.apache.commons.httpclient.HttpException;
   
  @@ -271,6 +272,26 @@
           } catch (IOException ioe) {
               throw new IllegalStateException(ioe.getMessage());
           }
  +    }
  +
  +    /**
  +     * Set a permission to this source
  +     *
  +     * @param sourcepermission Permission, which should be set
  +     *
  +     * @throws SourceException If an exception occurs during this operation
  +     */
  +    public void setSourcePermission(SourcePermission sourcepermission) throws SourceException
{
  +        throw new SourceException("Operation not supported");
  +    }
  +
  +    /**
  +     * Returns a list of the existing permissions
  +     *
  +     * @return Array of SourcePermission
  +     */
  +    public SourcePermission[] getSourcePermissions() throws SourceException {
  +        throw new SourceException("Operation not supported");
       }
   
       public class WebDAVSourceOutputStream extends ByteArrayOutputStream {
  
  
  
  1.6       +22 -20    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java
  
  Index: SourceDescriptionGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SourceDescriptionGenerator.java	29 Jun 2002 21:04:12 -0000	1.5
  +++ SourceDescriptionGenerator.java	1 Jul 2002 16:41:55 -0000	1.6
  @@ -130,8 +130,8 @@
    
       private static final String URI_ATTR_NAME          = "about";
   
  -    private static final String SUBJECT_ATTR_NAME      = "subject";
  -    private static final String ACTION_ATTR_NAME       = "action";
  +    private static final String PRINCIPAL_ATTR_NAME    = "principal";
  +    private static final String PRIVILEGE_ATTR_NAME    = "privilege";
       private static final String INHERITABLE_ATTR_NAME  = "inheritable";
       private static final String NEGATIVE_ATTR_NAME     = "negative";
   
  @@ -282,8 +282,13 @@
   
               this.contentHandler.endPrefixMapping("prop");*/
   
  -            /*if (source instanceof RestrictableSource)
  -                pushSourcePermissions((RestrictableSource)source);*/
  +            try {
  +                if (source instanceof RestrictableSource)
  +                    pushSourcePermissions((RestrictableSource)source);
  +            } catch (SourceException se) {
  +                getLogger().warn("Could not retrieve source permissions", se);
  +            }
  +
               if (source instanceof LockableSource)
                   pushSourceLocks((LockableSource)source);
               if ((source instanceof TraversableSource) && (deep>0))
  @@ -366,33 +371,30 @@
           }
       }
   
  -    /*private void pushSourcePermissions(RestrictableSource source) throws SAXException,
SourceException {
  -        Enumeration permissionsList = source.getSourcePermissions();
  -        SourcePermission permission;
  +    private void pushSourcePermissions(RestrictableSource source) throws SAXException,
SourceException {
  +        SourcePermission[] permissions = source.getSourcePermissions();
   
  -        if (permissionsList.hasMoreElements()) {
  +        if ((permissions!=null) && (permissions.length>0)) {
   
               this.contentHandler.startElement(SOURCE_NS, PERMISSIONS_NODE_NAME,
                                                PERMISSIONS_NODE_NAME, new AttributesImpl());
               this.contentHandler.startElement(RDF_NS, SEQUENCE_NODE_NAME,
                                                RDF_PREFIX+':'+SEQUENCE_NODE_NAME, new AttributesImpl());
   
  -            while (permissionsList.hasMoreElements()) {
  -    
  -                permission = (SourcePermission) permissionsList.nextElement();
  +            for(int i=0; i<permissions.length; i++) {
       
                   this.contentHandler.startElement(RDF_NS, SEQUENCEITEM_NODE_NAME,
                                                    RDF_PREFIX+':'+SEQUENCEITEM_NODE_NAME,
new AttributesImpl());
   
                   AttributesImpl attributes = new AttributesImpl();
  -                attributes.addAttribute("", SUBJECT_ATTR_NAME, SUBJECT_ATTR_NAME, "CDATA",
  -                                        permission.getSubject());
  -                attributes.addAttribute("", ACTION_ATTR_NAME, ACTION_ATTR_NAME, "CDATA",
  -                                        permission.getAction());
  +                attributes.addAttribute("", PRINCIPAL_ATTR_NAME, PRINCIPAL_ATTR_NAME, "CDATA",
  +                                        permissions[i].getPrincipal());
  +                attributes.addAttribute("", PRIVILEGE_ATTR_NAME, PRIVILEGE_ATTR_NAME, "CDATA",
  +                                        permissions[i].getPrivilege());
                   attributes.addAttribute("", INHERITABLE_ATTR_NAME, INHERITABLE_ATTR_NAME,
"CDATA",
  -                                        String.valueOf(permission.isInheritable()));
  +                                        String.valueOf(permissions[i].isInheritable()));
                   attributes.addAttribute("", NEGATIVE_ATTR_NAME, NEGATIVE_ATTR_NAME, "CDATA",
  -                                        String.valueOf(permission.isNegative()));
  +                                        String.valueOf(permissions[i].isNegative()));
   
                   this.contentHandler.startElement(SOURCE_NS, PERMISSION_NODE_NAME,
                                                    PERMISSION_NODE_NAME, attributes);
  @@ -408,7 +410,7 @@
               this.contentHandler.endElement(SOURCE_NS, PERMISSIONS_NODE_NAME, 
                                              PERMISSIONS_NODE_NAME);
           }
  -    }*/
  +    }
   
       public void pushSourceLocks(LockableSource source) throws SAXException, SourceException
{
           Enumeration locks = source.getSourceLocks();
  @@ -430,7 +432,7 @@
   
                   AttributesImpl attributes = new AttributesImpl();
                   attributes = new AttributesImpl();
  -                attributes.addAttribute("", SUBJECT_ATTR_NAME, SUBJECT_ATTR_NAME, "CDATA",
  +                attributes.addAttribute("", PRINCIPAL_ATTR_NAME, PRINCIPAL_ATTR_NAME, "CDATA",
                                           lock.getSubject());
                   attributes.addAttribute("", TYPE_ATTR_NAME, TYPE_ATTR_NAME, "CDATA",
                                           lock.getType());
  
  
  
  1.2       +33 -12    xml-cocoon2/src/scratchpad/webapp/samples/slide/rdf2html.xsl
  
  Index: rdf2html.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/samples/slide/rdf2html.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- rdf2html.xsl	1 Jul 2002 15:09:21 -0000	1.1
  +++ rdf2html.xsl	1 Jul 2002 16:41:55 -0000	1.2
  @@ -30,11 +30,11 @@
       </td>
      </tr>
      <tr>
  -    <td colspan="3" bgcolor="#eeeeee"><a href="/cocoon/samples/slide/browse/">Home</a></td>
  +    <td colspan="3" bgcolor="#eeeeee"><a href="/cocoon/mount/slide/browse/">Home</a></td>
       <td colspan="2" bgcolor="#eeeeee">
        <xsl:if test="dav:getcontentlength!='' and dav:getcontentlength!='0'">
         <xsl:if test="dav:resourcetype!='&lt;collection/>'">
  -       <a href="/cocoon/samples/slide/view/{@rdf:about}">Download</a>
  +       <a href="/cocoon/mount/slide/view/{@rdf:about}">Download</a>
         </xsl:if>
        </xsl:if>
       </td>
  @@ -132,8 +132,8 @@
          <td align="left" colspan="5"><tt><b>ACL Info</b></tt></td>
         </tr>
         <tr bgcolor="#cccccc">
  -       <td align="left"><tt><b>Subject</b></tt></td>
  -       <td align="left"><tt><b>Action</b></tt></td>
  +       <td align="left"><tt><b>Principal</b></tt></td>
  +       <td align="left"><tt><b>Privilege</b></tt></td>
          <td align="left"><tt><b>Inheritable</b></tt></td>
          <td align="left"><tt><b>Deny</b></tt></td>
          <td align="right"></td>
  @@ -145,10 +145,31 @@
          <form action="" method="post">
           <input type="hidden" name="uri" value="{@rdf:about}"/>
           <td align="left">
  -         <input name="permissonsubject" type="text" size="25" maxlength="40"/>
  +         <input name="permissonprincipal" type="text" size="25" maxlength="40"/>
           </td>
           <td align="left">
  -         <input name="permissonaction" type="text" size="25" maxlength="40"/>
  +         <select name="permissonprivilege">
  +          <option>all</option>
  +          <option>read</option>
  +          <option>write</option>
  +          <option>read-acl</option>
  +          <option>write-acl</option>
  +          <option>read-source</option>
  +          <option>create-source</option>
  +          <option>remove-source</option>
  +          <option>lock-source</option>
  +          <option>read-locks</option>
  +          <option>read-property</option>
  +          <option>create-property</option>
  +          <option>modify-property</option>
  +          <option>remove-property</option>
  +          <option>read-content</option>
  +          <option>create-content</option>
  +          <option>modify-content</option>
  +          <option>remove-content</option>
  +          <option>grant-permission</option>
  +          <option>revoke-permission</option>
  +         </select>
           </td>
           <td align="left">
            <select name="permissoninheritable">
  @@ -286,15 +307,15 @@
   
    <xsl:template match="source:permission">
     <tr bgcolor="#eeeeee">
  -   <td align="left"><tt><xsl:value-of select="@subjecturi"/></tt></td>
  -   <td align="left"><tt><xsl:value-of select="@actionuri"/></tt></td>
  +   <td align="left"><tt><xsl:value-of select="@principal"/></tt></td>
  +   <td align="left"><tt><xsl:value-of select="@privilege"/></tt></td>
      <td align="left"><tt><xsl:value-of select="@inheritable"/></tt></td>
      <td align="left"><tt><xsl:value-of select="@negative"/></tt></td>
      <td align="right">
       <form action="" method="post">
        <input type="hidden" name="uri" value="{../../../../@uri}"/>
  -     <input type="hidden" name="permissionsubject" value="{@subject}"/>
  -     <input type="hidden" name="permissionsaction" value="{@action}"/>
  +     <input type="hidden" name="permissionprincipal" value="{@subject}"/>
  +     <input type="hidden" name="permissionprivilege" value="{@action}"/>
   
        <input type="submit" name="cocoon-action-deletepermission" value="Delete"/>
       </form>
  @@ -323,7 +344,7 @@
    <xsl:template match="rdf:li" mode="enumerate">
     <tr bgcolor="#eeeeee">
      <td align="left">&#160;&#160;
  -    <a href="/cocoon/samples/slide/browse/{substring-after(@rdf:resource,'://')}"
  +    <a href="/cocoon/mount/slide/browse/{substring-after(@rdf:resource,'://')}"
         ><tt><xsl:value-of select="@rdf:resource"/></tt></a>
      </td>
      <xsl:variable name="location"><xsl:value-of select="@rdf:resource"/></xsl:variable>
  @@ -343,7 +364,7 @@
   <!-- <xsl:template match="rdf:Description" mode="enumerate">
     <tr bgcolor="#eeeeee">
      <td align="left">&#160;&#160;
  -    <a href="/cocoon/samples/slide/browse/{source:uri}"><tt><xsl:value-of
select="source:uri"/></tt></a>
  +    <a href="/cocoon/mount/slide/browse/{source:uri}"><tt><xsl:value-of
select="source:uri"/></tt></a>
      </td>
      <td align="left"><tt></tt></td>
      <td align="left"><tt><xsl:value-of select="dav:getcontentlength"/></tt></td>
  
  
  
  1.2       +5 -5      xml-cocoon2/src/scratchpad/webapp/samples/slide/slide.xconf
  
  Index: slide.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/samples/slide/slide.xconf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- slide.xconf	1 Jul 2002 15:09:21 -0000	1.1
  +++ slide.xconf	1 Jul 2002 16:41:55 -0000	1.2
  @@ -63,7 +63,7 @@
   
      <!-- Paths configuration -->
      <userspath>/users</userspath>
  -   <guestpath>guest</guestpath>
  +   <guestpath>/users/anonymous</guestpath>
      <filespath>/files</filespath>
      <parameter name="dav">true</parameter>
      <parameter name="standalone">true</parameter>
  @@ -96,7 +96,7 @@
       <!-- /users -->
       <objectnode classname="org.apache.slide.structure.SubjectNode" uri="/users">
        <permission action="/actions" subject="~"/>
  -     <permission action="/actions" subject="/users/guest" inheritable="true" negative="true"/>
  +     <permission action="/actions" subject="/users/anonymous" inheritable="true" negative="true"/>
        <permission action="/actions/read" subject="/users" inheritable="false"/>
   
        <!-- Permission group example -->
  @@ -124,7 +124,7 @@
        </objectnode>
   
        <!-- /users/guest represents an authenticated or unauthenticated guest user -->
  -     <objectnode classname="slideroles.basic.GuestRoleImpl" uri="/users/guest">
  +     <objectnode classname="slideroles.basic.GuestRoleImpl" uri="/users/anonymous">
         <revision>
          <property name="password"/>
         </revision>
  @@ -138,9 +138,9 @@
       </objectnode>
    
       <objectnode classname="org.apache.slide.structure.SubjectNode" uri="/files">
  -     <permission action="/actions" subject="/users/guest"/> 
  +     <permission action="/actions" subject="/users/anonymous"/> 
        <permission action="/actions/manage" subject="/users/john"/>
  -     <permission action="/actions/write" subject="+/users/groupA"/>
  +     <permission action="/actions/write" subject="/users/groupA"/>
        <permission action="/actions/read" subject="nobody"/>
       </objectnode>
      </objectnode>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message