[prev in list] [next in list] [prev in thread] [next in thread] 

List:       slide-dev
Subject:    cvs commit: jakarta-slide/src/stores/slidestore/file FileContentStoreNoVersioning.java
From:       remm () locus ! apache ! org
Date:       2000-10-08 22:49:30
[Download RAW message or body]

remm        00/10/08 15:49:30

  Modified:    src/conf/webapp web.xml
               src/share/org/apache/slide/security SecurityImpl.java
               src/share/org/apache/slide/util/resources
                        messages.properties
               src/share/org/apache/slide/webdav WebdavServlet.java
               src/share/org/apache/slide/webdav/method GetMethod.java
                        WebdavMethod.java
               src/stores/slidestore/file FileContentStoreNoVersioning.java
  Added:       src/share/org/apache/slide/manager ManagerServlet.java
  Log:
  - Adds a manager servlet, which can be used for various namespace operations.
    Documentation on it is coming soon.
  - The directory browse pages now enable manipulation of ACL, granting you
    have enough permissions.
  - Updated the status.
  
  Revision  Changes    Path
  1.3       +44 -3     jakarta-slide/src/conf/webapp/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/conf/webapp/web.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- web.xml	2000/09/23 07:41:32	1.2
  +++ web.xml	2000/10/08 22:49:27	1.3
  @@ -7,15 +7,27 @@
   <web-app>
   
     <servlet>
  -    <servlet-name>slide</servlet-name>
  +    <servlet-name>webdav</servlet-name>
       <servlet-class>org.apache.slide.webdav.WebdavServlet</servlet-class>
  +    <init-param>
  +      <param-name>debug</param-name>
  +      <param-value>0</param-value>
  +    </init-param>
       <load-on-startup>1</load-on-startup>
  +  </servlet>
  +
  +  <servlet>
  +    <servlet-name>manager</servlet-name>
  +    <servlet-class>org.apache.slide.manager.ManagerServlet</servlet-class>
       <init-param>
         <param-name>debug</param-name>
         <param-value>0</param-value>
       </init-param>
  +    <load-on-startup>1</load-on-startup>
     </servlet>
   
  +  <!-- Authetication for the WebDAV servlet -->
  +
     <!-- Uncomment this to get authentication -->
   
     <!--security-constraint>
  @@ -48,11 +60,40 @@
       <login-page>/login.html</login-page>
       <error-page>/error.html</error-page>
     </login-config-->
  +
  +  <!-- Authetication for the Manager servlet -->
  +
  +  <!-- Uncomment this to get authentication -->
  +
  +  <!--security-constraint>
  +    <auth-constraint>
  +      <role-name>root</role-name>
  +    </auth-constraint>
  +    <web-resource-collection>
  +      <web-resource-name>Manager</web-resource-name>
  +      <http-method>GET</http-method>
  +      <http-method>POST</http-method>
  +      <url-pattern>/manager/*</url-pattern>
  +    </web-resource-collection>
  +  </security-constraint>
  +
  +  <login-config>
  +    <auth-method>BASIC</auth-method>
  +    <realm-name>Catalina DAV Server</realm-name>
  +    <login-page>/login.html</login-page>
  +    <error-page>/error.html</error-page>
  +  </login-config-->
   
  -  <!-- The mapping for the slide servlet -->
  +  <!-- The mapping for the Slide WebDAV servlet -->
     <servlet-mapping>
  -    <servlet-name>slide</servlet-name>
  +    <servlet-name>webdav</servlet-name>
       <url-pattern>/</url-pattern>
  +  </servlet-mapping>
  +
  +  <!-- The mapping for the Slide Manager servlet -->
  +  <servlet-mapping>
  +    <servlet-name>manager</servlet-name>
  +    <url-pattern>/manager/*</url-pattern>
     </servlet-mapping>
   
     <!-- Set the default session timeout (in seconds) -->
  
  
  
  1.1                  \
jakarta-slide/src/share/org/apache/slide/manager/ManagerServlet.java  
  Index: ManagerServlet.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/manager/ManagerServlet.java,v \
                1.1 2000/10/08 22:49:28 remm Exp $
   * $Revision: 1.1 $
   * $Date: 2000/10/08 22:49:28 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.slide.manager;
  
  import java.io.*;
  import java.util.*;
  import java.security.Principal;
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.xml.parsers.SAXParser;
  import javax.xml.parsers.SAXParserFactory;
  import org.xml.sax.*;
  import org.xml.sax.helpers.*;
  import org.apache.slide.webdav.method.*;
  import org.apache.slide.webdav.common.*;
  import org.apache.slide.authenticate.*;
  import org.apache.slide.structure.*;
  import org.apache.slide.common.*;
  import org.apache.slide.security.*;
  import org.apache.slide.util.conf.*;
  import org.apache.slide.authenticate.SecurityToken;
  
  /**
   * Manager Servlet.
   * 
   * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
   */
  public class ManagerServlet extends HttpServlet {
      
      
      // -------------------------------------------------------------- Constants
      
      
      /**
       * HTTP Date format pattern (RFC 2068, 822, 1123).
       */
      public static final String DATE_FORMAT = "EEE, d MMM yyyy kk:mm:ss z";
      
      
      /**
       * Date formatter.
       */
      protected static final DateFormat formatter = 
          new SimpleDateFormat(DATE_FORMAT);
      
      
      // ----------------------------------------------------- Instance Variables
      
      
      /**
       * ACL editor page (if any).
       */
      protected String permissionEditor = null;
      
      
      /**
       * User editor page (if any).
       */
      protected String userEditor = null;
      
      
      // -------------------------------------------------------- Private Methods
      
      
      /**
       * Show HTTP header information.
       */
      private void showRequestInfo(HttpServletRequest req) {
  	
  	System.out.println();
  	System.out.println("SlideDAV Request Info");
  	System.out.println();
  	
  	// Show generic info
  	System.out.println("Encoding : " + req.getCharacterEncoding());
  	System.out.println("Length : " + req.getContentLength());
  	System.out.println("Type : " + req.getContentType());
  	
  	System.out.println();
  	System.out.println("Parameters");
  	
  	Enumeration parameters = req.getParameterNames();
  	
  	while (parameters.hasMoreElements()) {
  	    String paramName = (String) parameters.nextElement();
  	    String[] values = req.getParameterValues(paramName);
  	    System.out.print(paramName + " : ");
  	    for (int i = 0; i < values.length; i++) {
  		System.out.print(values[i] + ", ");
  	    }
  	    System.out.println();
  	}
  	
  	System.out.println();
  	
  	System.out.println("Protocol : " + req.getProtocol());
  	System.out.println("Address : " + req.getRemoteAddr());
  	System.out.println("Host : " + req.getRemoteHost());
  	System.out.println("Scheme : " + req.getScheme());
  	System.out.println("Server Name : " + req.getServerName());
  	System.out.println("Server Port : " + req.getServerPort());
  	
  	System.out.println();
  	System.out.println("Attributes");
  	
  	Enumeration attributes = req.getAttributeNames();
  	
  	while (attributes.hasMoreElements()) {
  	    String attributeName = (String) attributes.nextElement();
  	    System.out.print(attributeName + " : ");
  	    System.out.println(req.getAttribute(attributeName).toString());
  	}
  	
  	System.out.println();
  	
  	// Show HTTP info
  	System.out.println();
  	System.out.println("HTTP Header Info");
  	System.out.println();
  	
  	System.out.println("Authentication Type : " + req.getAuthType());
  	System.out.println("HTTP Method : " + req.getMethod());
  	System.out.println("Path Info : " + req.getPathInfo());
  	System.out.println("Path translated : " + req.getPathTranslated());
  	System.out.println("Query string : " + req.getQueryString());
  	System.out.println("Remote user : " + req.getRemoteUser());
  	System.out.println("Requested session id : " 
                             + req.getRequestedSessionId());
  	System.out.println("Request URI : " + req.getRequestURI());
  	System.out.println("Context path : " + req.getContextPath());
          System.out.println("Servlet path : " + req.getServletPath());
          System.out.println("User principal : " + req.getUserPrincipal());
          
  	
  	System.out.println();
  	System.out.println("Headers : ");
  	
  	Enumeration headers = req.getHeaderNames();
  	
  	while (headers.hasMoreElements()) {
  	    String headerName = (String) headers.nextElement();
  	    System.out.print(headerName + " : ");
  	    System.out.println(req.getHeader(headerName));
  	}
  	
  	// Show session info
  	HttpSession session = req.getSession(false);
          
  	System.out.println();
  	System.out.println("End Request Info");
  	System.out.println();
  	System.out.println();
  	
      }
      
      
      // -------------------------------------------------------- Servlet Methods
      
      
      /**
       * Process a GET request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      protected void doGet(HttpServletRequest request,
                           HttpServletResponse response)
  	throws IOException, ServletException {
          
          response.setStatus(HttpServletResponse.SC_OK);
          
          String command = request.getParameter("command");
          if (command == null) {
              // FIXME : Send a menu page ...
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          
          if (command.equals("addacl")) {
              addACL(request, response);
          } else if (command.equals("removeacl")) {
              removeACL(request, response);
          } else if (command.equals("adduser")) {
              //addUser(request, response);
          } else if (command.equals("removeuser")) {
              //removeUser(request, response);
          } else if (command.equals("addgroup")) {
              //addGroup(request, response);
          } else if (command.equals("removegroup")) {
              //removeGroup(request, response);
          } else {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          
      }
      
      
      /**
       * Process a POST request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      protected void doPost(HttpServletRequest request,
                            HttpServletResponse response)
  	throws IOException, ServletException {
          
          doGet(request, response);
          
      }
  
  
  
      /**
       * Manages some initialization stuff on the server.
       */
      public void init()
          throws ServletException {
          
          String domainConfigFile = "/Domain.xml";
          
          String value = null;
  	try {
  	    value = getServletConfig().getInitParameter("domain");
              if (value != null)
                  domainConfigFile = value;
          } catch (Throwable t) {
  	    ;
  	}
  	try {
              value = getServletConfig().getInitParameter("permissioneditor");
              if (value != null)
                  permissionEditor = value;
          } catch (Throwable t) {
              ;
          }
  	try {
              value = getServletConfig().getInitParameter("usereditor");
              if (value != null)
                  userEditor = value;
          } catch (Throwable t) {
              ;
          }
          
          if (!Domain.isInitialized()) {
              
              try {
                  
                  SAXParserFactory factory = SAXParserFactory.newInstance();
                  factory.setNamespaceAware(false);
                  factory.setValidating(false);
                  SAXParser parser = factory.newSAXParser();
                  
                  InputStream is = 
                      getServletContext().getResourceAsStream(domainConfigFile);
                  if (is == null)
                      throw new ServletException("Can't find init file");
                  Populate pop = new Populate();
                  Configuration slideConfiguration = 
                      new ConfigurationElement(pop.load(new InputSource(is), 
                                                        parser.getParser()));
                  
                  Domain.init(slideConfiguration);
                  
              } catch (Throwable t) {
                  t.printStackTrace();
                  throw new ServletException(t.getMessage());
              }
              
          }
          
      }
      
      
      /**
       * Destroy servlet.
       */
      public void destroy() {
      }
      
      
      // ------------------------------------------------------ Protected Methods
      
      
      /**
       * Removes a permission from an object.
       */
      protected void removeACL(HttpServletRequest request,
                               HttpServletResponse response)
  	throws IOException, ServletException {
          
          // Retrieving request's attributes
          
          String namespaceName = request.getPathInfo();
          if (namespaceName == null) {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          if (namespaceName.startsWith("/")) {
              namespaceName = namespaceName.substring(1);
          }
          
          String objectUri = request.getParameter("object");
          if (objectUri == null) {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          
          String subjectUri = request.getParameter("subject");
          if (subjectUri == null) {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          
          String actionUri = request.getParameter("action");
          if (actionUri == null) {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          
          try {
              
              NamespaceAccessToken nat = 
                  Domain.accessNamespace(new SecurityToken(this), namespaceName);
              Principal principal = request.getUserPrincipal();
              CredentialsToken token = null;
              if (principal != null) {
                  token = new CredentialsToken(principal);
              } else {
                  token = new CredentialsToken("");
              }
              ObjectNode object = 
                  nat.getStructureHelper().retrieve(token, objectUri);
              SubjectNode subject = (SubjectNode)
                  nat.getStructureHelper().retrieve(token, subjectUri);
              ActionNode action = (ActionNode)
                  nat.getStructureHelper().retrieve(token, actionUri);
              nat.getSecurityHelper().revokePermission(token, object, 
                                                         subject, action);
              
          } catch (AccessDeniedException e) {
              response.setStatus(HttpServletResponse.SC_FORBIDDEN);
              return;
          } catch (ObjectNotFoundException e) {
              response.setStatus(HttpServletResponse.SC_NOT_FOUND);
              return;
          } catch (SlideException e) {
              // FIXME : Can we be more specific ?
              response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
              return;
          }
          
          String contextPath = request.getContextPath();
          if (contextPath != null) {
              response.sendRedirect(contextPath);
          } else {
              response.sendRedirect("/");
          }
          
      }
      
      
      /**
       * Display an acl edit page if params are missing.
       */
      protected void addACL(HttpServletRequest request,
                            HttpServletResponse response)
  	throws IOException, ServletException {
          
          // Retrieving request's attributes
          
          boolean paramMissing = false;
          
          String namespaceName = request.getPathInfo();
          if (namespaceName == null) {
              response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
              return;
          }
          if (namespaceName.startsWith("/")) {
              namespaceName = namespaceName.substring(1);
          }
          
          String objectUri = request.getParameter("object");
          if (objectUri == null) {
              paramMissing = true;
          }
          
          String subjectUri = request.getParameter("subject");
          if (subjectUri == null) {
              paramMissing = true;
          }
          
          String actionUri = request.getParameter("action");
          if (actionUri == null) {
              paramMissing = true;
          }
          
          String inheritableValue = request.getParameter("inheritable");
          boolean inheritable = false;
          if (inheritableValue == null) {
              paramMissing = true;
          } else {
              if (inheritableValue.equals("true")) {
                  inheritable = true;
              } else if (inheritableValue.equals("false")) {
                  inheritable = false;
              } else {
                  response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                  return;
              }
          }
          
          String negativeValue = request.getParameter("negative");
          boolean negative = false;
          if (negativeValue == null) {
              paramMissing = true;
          } else {
              if (negativeValue.equals("true")) {
                  negative = true;
              } else if (negativeValue.equals("false")) {
                  negative = false;
              } else {
                  response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                  return;
              }
          }
          
          if (paramMissing) {
              
              // Display the edit page (or redirect to an edit page) ...
              if (permissionEditor != null) {
                  
                  // Redirect to the edit page
                  String editorUrl = permissionEditor + "?namespace=" 
                      + namespaceName;
                  if (objectUri != null) {
                      editorUrl += "&object=" + objectUri;
                  }
                  if (subjectUri != null) {
                      editorUrl += "&subject=" + subjectUri;
                  }
                  if (actionUri != null) {
                      editorUrl += "&action=" + actionUri;
                  }
                  response.sendRedirect(editorUrl);
                  return;
                  
              } else {
                  
                  // Display a simple edit page
                  displayPermissionEditor(request, response, namespaceName, 
                                          objectUri, subjectUri, actionUri);
                  return;
                  
              }
              
          } else {
              
              NodePermission permission = 
                  new NodePermission(objectUri, subjectUri, actionUri, 
                                     inheritable);
              
              try {
                  
                  NamespaceAccessToken nat = 
                      Domain.accessNamespace(new SecurityToken(this), 
                                             namespaceName);
                  Principal principal = request.getUserPrincipal();
                  CredentialsToken token = null;
                  if (principal != null) {
                      token = new CredentialsToken(principal);
                  } else {
                      token = new CredentialsToken("");
                  }
                  if (negative) {
                      nat.getSecurityHelper()
                          .denyPermission(token, permission);
                  } else {
                      nat.getSecurityHelper()
                          .grantPermission(token, permission);
                  }
                  
              } catch (AccessDeniedException e) {
                  response.setStatus(HttpServletResponse.SC_FORBIDDEN);
                  return;
              } catch (ObjectNotFoundException e) {
                  e.printStackTrace();
                  response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                  return;
              } catch (SlideException e) {
                  // FIXME : Can we be more specific ?
                  response.setStatus
                      (HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                  return;
              }
              
          }
          
          String contextPath = request.getContextPath();
          if (contextPath != null) {
              response.sendRedirect(contextPath);
          } else {
              response.sendRedirect("/");
          }
          
      }
      
      
      /**
       * Display an acl edit page if params are missing.
       */
      protected void displayPermissionEditor(HttpServletRequest request,
                                             HttpServletResponse response,
                                             String namespaceName,
                                             String objectUri, String subjectUri,
                                             String actionUri)
          throws IOException, ServletException {
          
          response.setContentType("text/html");
          
          PrintWriter writer = response.getWriter();
          
          writer.print("<html><head></head><body>");
          writer.print("<FORM NAME=\"ACL Editor\" ACTION=\"");
          String contextPath = request.getContextPath();
          if (contextPath != null) {
              writer.print(contextPath);
          }
          writer.print("/manager/" + namespaceName + "\" METHOD=GET>");
          writer.print("Object : <INPUT TYPE=\"text\" NAME=\"object\"");
          if (objectUri != null) {
              writer.print(objectUri);
          }
          writer.print("><br>");
          writer.print("Subject : <INPUT TYPE=\"text\" NAME=\"subject\"");
          if (subjectUri != null) {
              writer.print(subjectUri);
          }
          writer.print("><br>");
          writer.print("Action : <INPUT TYPE=\"text\" NAME=\"action\"");
          if (actionUri != null) {
              writer.print(actionUri);
          }
          writer.print("><br>");
          writer.print("Inheritable : <INPUT TYPE=\"text\" "
                       + "NAME=\"inheritable\" value=\"true\"><br>");
          writer.print("Negative : <INPUT TYPE=\"text\" NAME=\"negative\" " 
                       + "value=\"false\"><br>");
          writer.print("<input type=\"hidden\" name=\"command\" " 
                       + "value=\"addacl\">");
          writer.print("<input type=\"submit\" value=\"Add\">");
          writer.print("</form></body></html>");
          
          writer.close();
          
      }
      
      
  }
  
  
  
  1.9       +21 -13    \
jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java  
  Index: SecurityImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SecurityImpl.java	2000/10/03 06:16:44	1.8
  +++ SecurityImpl.java	2000/10/08 22:49:28	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v \
                1.8 2000/10/03 06:16:44 remm Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/10/03 06:16:44 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/security/SecurityImpl.java,v \
1.9 2000/10/08 22:49:28 remm Exp $  + * $Revision: 1.9 $
  + * $Date: 2000/10/08 22:49:28 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    * Security helper.
    * 
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.9 $
    */
   public final class SecurityImpl implements Security {
       
  @@ -173,9 +173,22 @@
           Uri objectUri = namespace.getUri(permission.getObjectUri());
           ObjectNode object = objectUri.getDescriptorsStore()
               .retrieveObject(objectUri);
  -        checkCredentials(token, object, namespaceConfig
  -                         .getGrantPermissionAction());
  -        objectUri.getDescriptorsStore().grantPermission(objectUri, permission);
  +        
  +        // Checking if the permission is already present
  +        Enumeration permissions = enumeratePermissions(token, object);
  +        boolean alreadyPresent = false;
  +        while (permissions.hasMoreElements() && !alreadyPresent) {
  +            if (permission.equals(permissions.nextElement())) {
  +                alreadyPresent = true;
  +            }
  +        }
  +        
  +        if (!alreadyPresent) {
  +            checkCredentials(token, object, namespaceConfig
  +                             .getGrantPermissionAction());
  +            objectUri.getDescriptorsStore().grantPermission(objectUri, 
  +                                                            permission);
  +        }
       }
       
       
  @@ -242,12 +255,7 @@
           // permission
           if (!permission.isNegative())
               permission.setNegative(true);
  -        Uri objectUri = namespace.getUri(permission.getObjectUri());
  -        ObjectNode object = objectUri.getDescriptorsStore()
  -            .retrieveObject(objectUri);
  -        checkCredentials(token, object, namespaceConfig
  -                         .getGrantPermissionAction());
  -        objectUri.getDescriptorsStore().grantPermission(objectUri, permission);
  +        grantPermission(token, permission);
       }
       
       
  
  
  
  1.4       +24 -2     \
jakarta-slide/src/share/org/apache/slide/util/resources/messages.properties  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/util/resources/messages.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- messages.properties	2000/09/25 07:24:48	1.3
  +++ messages.properties	2000/10/08 22:49:28	1.4
  @@ -1,9 +1,9 @@
   #
   # Slide messages
   #
  -# $Id: messages.properties,v 1.3 2000/09/25 07:24:48 remm Exp $
  +# $Id: messages.properties,v 1.4 2000/10/08 22:49:28 remm Exp $
   #
  -# @version $Revision: 1.3 $ $Date: 2000/09/25 07:24:48 $
  +# @version $Revision: 1.4 $ $Date: 2000/10/08 22:49:28 $
   #
   
   #
  @@ -110,6 +110,28 @@
   	Last Modified
   org.apache.slide.webdav.GetMethod.version=\
   	Jakarta Slide 1.0
  +org.apache.slide.webdav.GetMethod.aclinfo=\
  +	ACL Info
  +org.apache.slide.webdav.GetMethod.subject=\
  +	Subject
  +org.apache.slide.webdav.GetMethod.action=\
  +	Action
  +org.apache.slide.webdav.GetMethod.inheritable=\
  +	Inheritable
  +org.apache.slide.webdav.GetMethod.deny=\
  +	Deny
  +org.apache.slide.webdav.GetMethod.locksinfo=\
  +	Locks Info
  +org.apache.slide.webdav.GetMethod.type=\
  +	Type
  +org.apache.slide.webdav.GetMethod.expiration=\
  +	Expiration
  +org.apache.slide.webdav.GetMethod.exclusive=\
  +	Exclusive
  +org.apache.slide.webdav.GetMethod.add=\
  +	Add
  +org.apache.slide.webdav.GetMethod.remove=\
  +	Remove
   
   #
   # Messages produced by org.apache.slide.util.Configuration
  
  
  
  1.8       +12 -4     \
jakarta-slide/src/share/org/apache/slide/webdav/WebdavServlet.java  
  Index: WebdavServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/WebdavServlet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebdavServlet.java	2000/09/26 02:44:30	1.7
  +++ WebdavServlet.java	2000/10/08 22:49:29	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/WebdavServlet.java,v \
                1.7 2000/09/26 02:44:30 remm Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/09/26 02:44:30 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/WebdavServlet.java,v \
1.8 2000/10/08 22:49:29 remm Exp $  + * $Revision: 1.8 $
  + * $Date: 2000/10/08 22:49:29 $
    *
    * ====================================================================
    *
  @@ -301,6 +301,7 @@
           
           String namespaceName = "webdav";
           String domainConfigFile = "/Domain.xml";
  +        String managerServletPath = "/manager/";
           
           String value = null;
   	try {
  @@ -317,8 +318,15 @@
           } catch (Throwable t) {
   	    ;
   	}
  +	try {
  +	    value = getServletConfig().getInitParameter("manager");
  +            if (value != null)
  +                managerServletPath = value;
  +        } catch (Throwable t) {
  +	    ;
  +	}
           
  -        WebdavMethod.init();
  +        WebdavMethod.init(managerServletPath);
           
           if (!Domain.isInitialized()) {
               
  
  
  
  1.7       +55 -16    \
jakarta-slide/src/share/org/apache/slide/webdav/method/GetMethod.java  
  Index: GetMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/GetMethod.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GetMethod.java	2000/10/03 06:16:47	1.6
  +++ GetMethod.java	2000/10/08 22:49:29	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/GetMethod.java,v \
                1.6 2000/10/03 06:16:47 remm Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/10/03 06:16:47 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/GetMethod.java,v \
1.7 2000/10/08 22:49:29 remm Exp $  + * $Revision: 1.7 $
  + * $Date: 2000/10/08 22:49:29 $
    *
    * ====================================================================
    *
  @@ -579,7 +579,8 @@
               }
               writer.print(">\r\n");
               writer.print("<td align=\"left\" colspan=\"5\"><tt><b>");
  -            writer.print("ACL Info");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.aclinfo"));
               writer.print("</b></tt></td>\r\n");
               writer.print("</tr>\r\n");
               
  @@ -591,22 +592,38 @@
               }
               writer.print(">\r\n");
               
  -            writer.print("<td align=\"left\" colspan=\"2\"><tt><b>");
  -            writer.print("Subject");
  +            writer.print("<td align=\"left\"><tt><b>");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.subject"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"left\"><tt><b>");
  -            writer.print("Action");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.action"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"right\"><tt><b>");
  -            writer.print("Inheritable");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.inheritable"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"right\"><tt><b>");
  -            writer.print("Deny");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.deny"));
               writer.print("</b></tt></td>\r\n");
               
  +            writer.print("<td align=\"right\"><tt><b>");
  +            writer.print("<a href=\"");
  +            if (req.getContextPath() != null) {
  +                writer.print(req.getContextPath());
  +            }
  +            writer.print(managerServletPath + token.getName() 
  +                         + "?command=addacl\">");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.add"));
  +            writer.print("</a>");
  +            writer.print("</b></tt></td>\r\n");
  +            
               writer.print("</tr>\r\n");
               
               while (permissionsList.hasMoreElements()) {
  @@ -622,7 +639,7 @@
                   NodePermission currentPermission =
                       (NodePermission) permissionsList.nextElement();
                   
  -                writer.print("<td align=\"left\" colspan=\"2\"><tt>");
  +                writer.print("<td align=\"left\"><tt>");
                   writer.print(currentPermission.getSubjectUri());
                   writer.print("</tt></td>\r\n");
                   
  @@ -638,6 +655,22 @@
                   writer.print(currentPermission.isNegative());
                   writer.print("</tt></td>\r\n");
                   
  +                writer.print("<td align=\"right\"><tt><b>");
  +                writer.print("<a href=\"");
  +                if (req.getContextPath() != null) {
  +                    writer.print(req.getContextPath());
  +                }
  +                writer.print(managerServletPath + token.getName() 
  +                             + "?command=removeacl"
  +                             + "&object=" + currentPermission.getObjectUri()
  +                             + "&subject=" + currentPermission.getSubjectUri()
  +                             + "&action=" + currentPermission.getActionUri()
  +                             + "\">");
  +                writer.print(Messages.message
  +                             ("org.apache.slide.webdav.GetMethod.remove"));
  +                writer.print("</a>");
  +                writer.print("</b></tt></td>\r\n");
  +                
                   writer.print("</tr>\r\n");
                       
               }
  @@ -668,7 +701,8 @@
               }
               writer.print(">\r\n");
               writer.print("<td align=\"left\" colspan=\"5\"><tt><b>");
  -            writer.print("Locks Info");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.locksinfo"));
               writer.print("</b></tt></td>\r\n");
               writer.print("</tr>\r\n");
               
  @@ -681,23 +715,28 @@
               writer.print(">\r\n");
               
               writer.print("<td align=\"left\"><tt><b>");
  -            writer.print("Subject");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.subject"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"left\"><tt><b>");
  -            writer.print("Type");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.type"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"right\"><tt><b>");
  -            writer.print("Expiration");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.expiration"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"right\"><tt><b>");
  -            writer.print("Inheritable");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.inheritable"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("<td align=\"right\"><tt><b>");
  -            writer.print("Exclusive");
  +            writer.print(Messages.message
  +                         ("org.apache.slide.webdav.GetMethod.exclusive"));
               writer.print("</b></tt></td>\r\n");
               
               writer.print("</tr>\r\n");
  
  
  
  1.11      +18 -6     \
jakarta-slide/src/share/org/apache/slide/webdav/method/WebdavMethod.java  
  Index: WebdavMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/WebdavMethod.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WebdavMethod.java	2000/10/03 21:55:32	1.10
  +++ WebdavMethod.java	2000/10/08 22:49:29	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/WebdavMethod.java,v \
                1.10 2000/10/03 21:55:32 remm Exp $
  - * $Revision: 1.10 $
  - * $Date: 2000/10/03 21:55:32 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/webdav/method/WebdavMethod.java,v \
1.11 2000/10/08 22:49:29 remm Exp $  + * $Revision: 1.11 $
  + * $Date: 2000/10/08 22:49:29 $
    *
    * ====================================================================
    *
  @@ -219,8 +219,14 @@
        * The MD5 helper object for this class.
        */
       protected static final MD5Encoder md5Encoder = new MD5Encoder();
  -
  -
  +    
  +    
  +    /**
  +     * Manager servlet path.
  +     */
  +    protected static String managerServletPath = "/manager/";
  +    
  +    
       // ----------------------------------------------------------- Constructors
       
       
  @@ -274,8 +280,10 @@
       
       /**
        * Initializes static fields.
  +     * 
  +     * @param servletPath Path of the manager servlet
        */
  -    public static void init() {
  +    public static void init(String servletPath) {
           
           // Load the MD5 helper used to calculate signatures.
           try {
  @@ -283,6 +291,10 @@
           } catch (NoSuchAlgorithmException e) {
               e.printStackTrace();
               throw new IllegalStateException();
  +        }
  +        
  +        if (servletPath != null) {
  +            managerServletPath = servletPath;
           }
           
       }
  
  
  
  1.2       +8 -10     \
jakarta-slide/src/stores/slidestore/file/FileContentStoreNoVersioning.java  
  Index: FileContentStoreNoVersioning.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/slidestore/file/FileContentStoreNoVersioning.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileContentStoreNoVersioning.java	2000/10/04 09:20:37	1.1
  +++ FileContentStoreNoVersioning.java	2000/10/08 22:49:30	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/file/FileContentStoreNoVersioning.java,v \
                1.1 2000/10/04 09:20:37 remm Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/10/04 09:20:37 $
  + * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/file/FileContentStoreNoVersioning.java,v \
1.2 2000/10/08 22:49:30 remm Exp $  + * $Revision: 1.2 $
  + * $Date: 2000/10/08 22:49:30 $
    *
    * ====================================================================
    *
  @@ -76,7 +76,7 @@
    * Filesystem implementation of ContentStore.
    * 
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class FileContentStoreNoVersioning extends ServiceImpl 
       implements ContentStore {
  @@ -203,7 +203,7 @@
           (Uri uri, NodeRevisionNumber revisionNumber)
           throws ServiceAccessException, RevisionNotFoundException {
           NodeRevisionContent result = null;
  -        String revisionUri = uri.toString() + "_" + revisionNumber;
  +        String revisionUri = uri.toString();
           try {
               File file = new File(rootpath + revisionUri);
               FileInputStream is = new FileInputStream(file);
  @@ -236,8 +236,7 @@
           (Uri uri, NodeRevisionDescriptor revisionDescriptor, 
            NodeRevisionContent revisionContent)
           throws ServiceAccessException, RevisionAlreadyExistException {
  -        String revisionUri = uri.toString() + "_" 
  -            + revisionDescriptor.getRevisionNumber();
  +        String revisionUri = uri.toString();
           
           try {
               File file = new File(rootpath + revisionUri);
  @@ -301,8 +300,7 @@
           (Uri uri, NodeRevisionDescriptor revisionDescriptor, 
            NodeRevisionContent revisionContent)
           throws ServiceAccessException, RevisionNotFoundException {
  -        String revisionUri = uri.toString() + "_" 
  -            + revisionDescriptor.getRevisionNumber();
  +        String revisionUri = uri.toString();
           try {
               File file = new File(rootpath + revisionUri);
               
  @@ -364,7 +362,7 @@
       public void removeRevisionContent(Uri uri, 
                                         NodeRevisionNumber revisionNumber)
           throws ServiceAccessException {
  -        String revisionUri = uri.toString() + "_" + revisionNumber;
  +        String revisionUri = uri.toString();
           
           try {
               File file = new File(rootpath + revisionUri);
  
  
  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic