craigmcc    02/01/19 19:00:58

  Modified:    catalina build.xml
               catalina/src/share/org/apache/catalina/core
                        NamingContextListener.java StandardServer.java
               catalina/src/share/org/apache/catalina/realm
                        LocalStrings.properties
               tester/web/WEB-INF web.xml
  Added:       catalina/src/share/org/apache/catalina Group.java User.java
                        UserDatabase.java
               catalina/src/share/org/apache/catalina/users
                        AbstractGroup.java AbstractUser.java Constants.java
                        LocalStrings.properties MemoryGroup.java
                        MemoryUser.java MemoryUserDatabase.java
                        MemoryUserDatabaseFactory.java
  Log:
  Initial check-ins to support a database of users and groups that can
  be edited through the administration application.  Groups are an
  enhancement over the existing capabilities, and allow users to inherit
  the roles of all groups that they are members of.
  
  * org.apache.catalina.{Group,User,UserDatabase} - Component definitions
    for groups, users, and the user database itself.
  
  * org.apache.catalina.users.Abstract{Group,User} - Convenience
    base classes for groups and users.
  
  * org.apache.catalina.users.Memory{Group,User} - Concrete implementations
    used with a memory database fed by an enhanced version of the existing
    "conf/tomcat-users.xml" file.
  
  * org.apache.catalina.users.MemoryUserDatabase - Concrete implementation
    of o.a.c.UserDatabase that can load *and store* groups and users in the
    "conf/tomcat-users.xml" file.  See below for revised syntax.
  
  * org.apache.catalina.users.MemoryUserDatabaseFactory - JNDI resource
    factory so that an instance of MemoryUserDatabase can be configured
    in the global JNDI resources, and then used by an appropriate Realm
    implementation (see next check-in) as well as being editable.
  
  The revised syntax for the tomcat-users.xml file introduces a "group"
  element, and adds a "groups" attribute to the "user" element.  Groups
  must be defined first.  An example:
  
    <?xml version='1.0'?>
    <tomcat-users>
      <group groupname='admins' description='System Administrators'
             roles='admin'/>
      <user username='tomcat' password='tomcat'
            groups='admins' roles='tomcat,manager'/>
      <user username='role1' password='tomcat' roles='role1'/>
      <user username='both' password='tomcat'
            groups='admins'  roles='tomcat,role1'/>
    </tomcat-users>
  
  In this scenario, users 'tomcat' and 'both' inherit the 'admin' role by
  virtue of the fact that they belong to the "admins" group.
  
  For backwards compatibility, the file reader accepts either "name" or
  "username" on the <user> element, but it always writes "username".
  
  Revision  Changes    Path
  1.97      +1 -1      jakarta-tomcat-4.0/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/build.xml,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- build.xml 17 Jan 2002 20:00:01 -0000      1.96
  +++ build.xml 20 Jan 2002 03:00:56 -0000      1.97
  @@ -880,7 +880,7 @@
       </jar>
   
       <!-- Naming - Factory JAR File -->
  -    <jar jarfile="${catalina.deploy}/shared/lib/naming-factory.jar">
  +    <jar jarfile="${catalina.deploy}/common/lib/naming-factory.jar">
         <fileset dir="${catalina.build}/server/classes">
           <include name="org/apache/naming/factory/**" />
           <exclude name="org/apache/naming/factory/Constants.class" />
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Group.java
  
  Index: Group.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Group.java,v 1.1 
2002/01/20 03:00:56 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:56 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina;
  
  
  import java.util.Iterator;
  
  
  /**
   * <p>Abstract representation of a group of {@link User}s in a
   * {@link UserDatabase}.  Each user that is a member of this group
   * inherits the security roles assigned to the group.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:56 $
   * @since 4.1
   */
  
  public interface Group {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the description of this group.
       */
      public String getDescription();
  
  
      /**
       * Set the description of this group.
       *
       * @param description The new description
       */
      public void setDescription(String description);
  
  
      /**
       * Return the group name of this group, which must be unique
       * within the scope of a {@link UserDatabase}.
       */
      public String getGroupname();
  
  
      /**
       * Set the group name of this group, which must be unique
       * within the scope of a {@link UserDatabase}.
       *
       * @param groupname The new group name
       */
      public void setGroupname(String groupname);
  
  
      /**
       * Return the set of security roles assigned specifically to this group,
       * as Strings.
       */
      public Iterator getRoles();
  
  
      /**
       * Return the set of {@link User}s that are members of this group.
       */
      public Iterator getUsers();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a new security role to those assigned specifically to this group.
       *
       * @param role The new role
       */
      public void addRole(String role);
  
  
      /**
       * Is this group specifically assigned the specified role?
       *
       * @param role The role to check
       */
      public boolean isInRole(String role);
  
  
      /**
       * Remove a security role from those assigned to this group.
       *
       * @param role The old role
       */
      public void removeRole(String role);
  
  
  
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/User.java
  
  Index: User.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/User.java,v 1.1 
2002/01/20 03:00:56 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:56 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina;
  
  
  import java.util.Iterator;
  
  
  /**
   * <p>Abstract representation of a user in a {@link UserDatabase}.  Each user
   * is optionally associated with a set of {@link Group}s through which he or
   * she inherits additional security roles, and is optionally assigned a set
   * of specific security roles.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:56 $
   * @since 4.1
   */
  
  public interface User {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the full name of this user.
       */
      public String getFullName();
  
  
      /**
       * Set the full name of this user.
       *
       * @param fullName The new full name
       */
      public void setFullName(String fullName);
  
  
      /**
       * Return the set of {@link Group}s to which this user belongs.
       */
      public Iterator getGroups();
  
  
      /**
       * Return the logon password of this user, optionally prefixed with the
       * identifier of an encoding scheme surrounded by curly braces, such as
       * <code>{md5}xxxxx</code>.
       */
      public String getPassword();
  
  
      /**
       * Set the logon password of this user, optionally prefixed with the
       * identifier of an encoding scheme surrounded by curly braces, such as
       * <code>{md5}xxxxx</code>.
       *
       * @param password The new logon password
       */
      public void setPassword(String password);
  
  
      /**
       * Return the set of security roles assigned specifically to this user,
       * as Strings.
       */
      public Iterator getRoles();
  
  
      /**
       * Return the logon username of this user, which must be unique
       * within the scope of a {@link UserDatabase}.
       */
      public String getUsername();
  
  
      /**
       * Set the logon username of this user, which must be unique within
       * the scope of a {@link UserDatabase}.
       *
       * @param username The new logon username
       */
      public void setUsername(String username);
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a new {@link Group} to those this user belongs to.
       *
       * @param group The new group
       */
      public void addGroup(Group group);
  
  
      /**
       * Add a new security role to those assigned specifically to this user.
       *
       * @param role The new role
       */
      public void addRole(String role);
  
  
      /**
       * Is this user in the specified group?
       *
       * @param group The group to check
       */
      public boolean isInGroup(Group group);
  
  
      /**
       * Is this user specifically assigned the specified role?  This method
       * does <strong>NOT</strong> check for roles inherited based on group
       * membership.
       *
       * @param role The role to check
       */
      public boolean isInRole(String role);
  
  
      /**
       * Remove a {@link Group} from those this user belongs to.
       *
       * @param group The old group
       */
      public void removeGroup(Group group);
  
  
      /**
       * Remove a security role from those assigned to this user.
       *
       * @param role The old role
       */
      public void removeRole(String role);
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/UserDatabase.java
  
  Index: UserDatabase.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/UserDatabase.java,v
 1.1 2002/01/20 03:00:56 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:56 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina;
  
  
  import java.util.Iterator;
  
  
  /**
   * <p>Abstract representation of a database of {@link User}s and
   * {@link Group}s that can be maintained by an application, and
   * referenced by a {@link Realm} for authentication and access control.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:56 $
   * @since 4.1
   */
  
  public interface UserDatabase {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the set of {@link Group}s defined in this user database.
       */
      public Iterator getGroups();
  
  
      /**
       * Return the set of {@link User}s defined in this user database.
       */
      public Iterator getUsers();
  
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Finalize access to this user database.
       *
       * @exception Exception if any exception is thrown during closing
       */
      public void close() throws Exception;
  
  
      /**
       * Create and return a new {@link Group} defined in this user database.
       *
       * @param groupname The group name of the new group (must be unique)
       * @param description The description of this group
       */
      public Group createGroup(String groupname, String description);
  
  
      /**
       * Create and return a new {@link User} defined in this user database.
       *
       * @param username The logon username of the new user (must be unique)
       * @param password The logon password of the new user
       * @param fullName The full name of the new user
       */
      public User createUser(String username, String password,
                             String fullName);
  
  
      /**
       * Return the {@link Group} with the specified group name, if any;
       * otherwise return <code>null</code>.
       *
       * @param groupname Name of the group to return
       */
      public Group findGroup(String groupname);
  
  
      /**
       * Return the {@link User} with the specified user name, if any;
       * otherwise return <code>null</code>.
       *
       * @param username Name of the user to return
       */
      public User findUser(String username);
  
  
      /**
       * Initialize access to this user database.
       *
       * @exception Exception if any exception is thrown during opening
       */
      public void open() throws Exception;
  
  
      /**
       * Remove the specified {@link Group} from this user database.
       *
       * @param group The group to be removed
       */
      public void removeGroup(Group group);
  
  
      /**
       * Remove the specified {@link User} from this user database.
       *
       * @param user The user to be removed
       */
      public void removeUser(User user);
  
  
      /**
       * Save any updated information to the persistent storage location for
       * this user database.
       *
       * @exception Exception if any exception is thrown during saving
       */
      public void save() throws Exception;
  
  
  }
  
  
  
  1.6       +8 -4      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java
  
  Index: NamingContextListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NamingContextListener.java        29 Nov 2001 03:12:52 -0000      1.5
  +++ NamingContextListener.java        20 Jan 2002 03:00:56 -0000      1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
 1.5 2001/11/29 03:12:52 remm Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/11/29 03:12:52 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
 1.6 2002/01/20 03:00:56 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/01/20 03:00:56 $
    *
    * ====================================================================
    *
  @@ -116,7 +116,7 @@
    * with each context and server.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.5 $ $Date: 2001/11/29 03:12:52 $
  + * @version $Revision: 1.6 $ $Date: 2002/01/20 03:00:56 $
    */
   
   public class NamingContextListener
  @@ -312,6 +312,10 @@
               if (container instanceof Server) {
                   org.apache.naming.factory.ResourceLinkFactory.setGlobalContext
                       (namingContext);
  +                if (container instanceof StandardServer) {
  +                    ((StandardServer) container).setGlobalNamingContext
  +                        (namingContext);
  +                }
               }
   
               initialized = true;
  
  
  
  1.17      +33 -4     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- StandardServer.java       11 Nov 2001 18:39:52 -0000      1.16
  +++ StandardServer.java       20 Jan 2002 03:00:56 -0000      1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
 1.16 2001/11/11 18:39:52 remm Exp $
  - * $Revision: 1.16 $
  - * $Date: 2001/11/11 18:39:52 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
 1.17 2002/01/20 03:00:56 craigmcc Exp $
  + * $Revision: 1.17 $
  + * $Date: 2002/01/20 03:00:56 $
    *
    * ====================================================================
    *
  @@ -72,6 +72,7 @@
   import java.net.Socket;
   import java.security.AccessControlException;
   import java.util.Random;
  +import javax.naming.Context;
   import org.apache.catalina.Lifecycle;
   import org.apache.catalina.LifecycleEvent;
   import org.apache.catalina.LifecycleException;
  @@ -90,7 +91,7 @@
    * (but not required) when deploying and starting Catalina.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.16 $ $Date: 2001/11/11 18:39:52 $
  + * @version $Revision: 1.17 $ $Date: 2002/01/20 03:00:56 $
    */
   
   public final class StandardServer
  @@ -121,6 +122,12 @@
   
   
       /**
  +     * Global naming resources context.
  +     */
  +    private Context globalNamingContext = null;
  +
  +
  +    /**
        * Global naming resources.
        */
       private NamingResources globalNamingResources = null;
  @@ -210,6 +217,28 @@
       public void setDebug(int debug) {
   
           this.debug = debug;
  +
  +    }
  +
  +
  +    /**
  +     * Return the global naming resources context.
  +     */
  +    public Context getGlobalNamingContext() {
  +
  +        return (this.globalNamingContext);
  +
  +    }
  +
  +
  +    /**
  +     * Set the global naming resources context.
  +     *
  +     * @param globalNamingContext The new global naming resource context
  +     */
  +    public void setGlobalNamingContext(Context globalNamingContext) {
  +
  +        this.globalNamingContext = globalNamingContext;
   
       }
   
  
  
  
  1.6       +7 -1      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/LocalStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalStrings.properties   2 Nov 2001 20:34:48 -0000       1.5
  +++ LocalStrings.properties   20 Jan 2002 03:00:57 -0000      1.6
  @@ -1,4 +1,4 @@
  -# $Id: LocalStrings.properties,v 1.5 2001/11/02 20:34:48 craigmcc Exp $
  +# $Id: LocalStrings.properties,v 1.6 2002/01/20 03:00:57 craigmcc Exp $
   
   # language 
   
  @@ -30,3 +30,9 @@
   realmBase.hasRoleFailure=Username {0} does NOT have role {1}
   realmBase.hasRoleSuccess=Username {0} has role {1}
   realmBase.notStarted=This Realm has not yet been started
  +userDatabaseRealm.authenticateFailure=Username {0} NOT successfully authenticated
  +userDatabaseRealm.authenticateSuccess=Username {0} successfully authenticated
  +userDatabaseRealm.lookup=Exception looking up UserDatabase under key {0}
  +userDatabaseRealm.noDatabase=No UserDatabase component found under key {0}
  +userDatabaseRealm.noEngine=No Engine component found in container hierarchy
  +userDatabaseRealm.noGlobal=No global JNDI resources context found
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractGroup.java
  
  Index: AbstractGroup.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractGroup.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import org.apache.catalina.Group;
  
  
  /**
   * <p>Convenience base class for {@link Group} implementations.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public abstract class AbstractGroup implements Group {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The description of this group.
       */
      protected String description = null;
  
  
      /**
       * The group name of this group.
       */
      protected String groupname = null;
  
  
      /**
       * The set of security roles associated with this group.
       */
      protected ArrayList roles = new ArrayList();
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the description of this group.
       */
      public String getDescription() {
  
          return (this.description);
  
      }
  
  
      /**
       * Set the description of this group.
       *
       * @param description The new description
       */
      public void setDescription(String description) {
  
          this.description = description;
  
      }
  
  
      /**
       * Return the group name of this group, which must be unique
       * within the scope of a {@link UserDatabase}.
       */
      public String getGroupname() {
  
          return (this.groupname);
  
      }
  
  
      /**
       * Set the group name of this group, which must be unique
       * within the scope of a {@link UserDatabase}.
       *
       * @param groupname The new group name
       */
      public void setGroupname(String groupname) {
  
          this.groupname = groupname;
  
      }
  
  
      /**
       * Return the set of security roles assigned specifically to this group,
       * as Strings.
       */
      public Iterator getRoles() {
  
          synchronized (roles) {
              return (roles.iterator());
          }
  
      }
  
  
      /**
       * Return the set of {@link User}s that are members of this group.
       */
      public abstract Iterator getUsers();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a new security role to those assigned specifically to this group.
       *
       * @param role The new role
       */
      public void addRole(String role) {
  
          synchronized (roles) {
              if (!roles.contains(role)) {
                  roles.add(role);
              }
          }
  
      }
  
  
      /**
       * Is this group specifically assigned the specified role?
       *
       * @param role The role to check
       */
      public boolean isInRole(String role) {
  
          synchronized (roles) {
              return (roles.contains(role));
          }
  
      }
  
  
      /**
       * Remove a security role from those assigned to this group.
       *
       * @param role The old role
       */
      public void removeRole(String role) {
  
          synchronized (roles) {
              roles.remove(role);
          }
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractUser.java
  
  Index: AbstractUser.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractUser.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import org.apache.catalina.Group;
  import org.apache.catalina.User;
  
  
  /**
   * <p>Convenience base class for {@link User} implementations.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public abstract class AbstractUser implements User {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The full name of this user.
       */
      protected String fullName = null;
  
  
      /**
       * The logon password of this user.
       */
      protected String password = null;
  
  
      /**
       * The set of security roles associated with this user.
       */
      protected ArrayList roles = new ArrayList();
  
  
      /**
       * The logon username of this user.
       */
      protected String username = null;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the full name of this user.
       */
      public String getFullName() {
  
          return (this.fullName);
  
      }
  
  
      /**
       * Set the full name of this user.
       *
       * @param fullName The new full name
       */
      public void setFullName(String fullName) {
  
          this.fullName = fullName;
  
      }
  
  
      /**
       * Return the set of {@link Group}s to which this user belongs.
       */
      public abstract Iterator getGroups();
  
  
      /**
       * Return the logon password of this user, optionally prefixed with the
       * identifier of an encoding scheme surrounded by curly braces, such as
       * <code>{md5}xxxxx</code>.
       */
      public String getPassword() {
  
          return (this.password);
  
      }
  
  
      /**
       * Set the logon password of this user, optionally prefixed with the
       * identifier of an encoding scheme surrounded by curly braces, such as
       * <code>{md5}xxxxx</code>.
       *
       * @param password The new logon password
       */
      public void setPassword(String password) {
  
          this.password = password;
  
      }
  
  
      /**
       * Return the set of security roles assigned specifically to this user,
       * as Strings.
       */
      public Iterator getRoles() {
  
          synchronized (roles) {
              return (roles.iterator());
          }
  
      }
  
  
      /**
       * Return the logon username of this user, which must be unique
       * within the scope of a {@link UserDatabase}.
       */
      public String getUsername() {
  
          return (this.username);
  
      }
  
  
      /**
       * Set the logon username of this user, which must be unique within
       * the scope of a {@link UserDatabase}.
       *
       * @param username The new logon username
       */
      public void setUsername(String username) {
  
          this.username = username;
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a new {@link Group} to those this user belongs to.
       *
       * @param group The new group
       */
      public abstract void addGroup(Group group);
  
  
      /**
       * Add a new security role to those assigned specifically to this user.
       *
       * @param role The new role
       */
      public void addRole(String role) {
  
          synchronized (roles) {
              if (!roles.contains(role)) {
                  roles.add(role);
              }
          }
  
      }
  
  
      /**
       * Is this user in the specified group?
       *
       * @param group The group to check
       */
      public abstract boolean isInGroup(Group group);
  
  
      /**
       * Is this user specifically assigned the specified role?  This method
       * does <strong>NOT</strong> check for roles inherited based on group
       * membership.
       *
       * @param role The role to check
       */
      public boolean isInRole(String role) {
  
          synchronized (roles) {
              return (roles.contains(role));
          }
  
      }
  
  
      /**
       * Remove a {@link Group} from those this user belongs to.
       *
       * @param group The old group
       */
      public abstract void removeGroup(Group group);
  
  
      /**
       * Remove a security role from those assigned to this user.
       *
       * @param role The old role
       */
      public void removeRole(String role) {
  
          synchronized (roles) {
              roles.remove(role);
          }
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/Constants.java
  
  Index: Constants.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/Constants.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  /**
   * Manifest constants for this Java package.
   *
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public final class Constants {
  
      public static final String Package = "org.apache.catalina.users";
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  memoryUserDatabase.invalidGroup=Invalid group name {0}
  memoryUserDatabase.renameOld=Cannot rename original file to {0}
  memoryUserDatabase.renameNew=Cannot rename new file to {0}
  memoryUserDatabase.writeException=IOException writing to {0}
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryGroup.java
  
  Index: MemoryGroup.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryGroup.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import org.apache.catalina.Group;
  import org.apache.catalina.User;
  import org.apache.catalina.UserDatabase;
  
  
  /**
   * <p>Concrete implementation of {@link Group} for the
   * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public class MemoryGroup extends AbstractGroup {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Package-private constructor used by the factory method in
       * {@link MemoryUserDatabase}.
       *
       * @param database The {@link MemoryUserDatabase} that owns this group
       * @param groupname Group name of this group
       * @param description Description of this group
       */
      MemoryGroup(MemoryUserDatabase database,
                  String groupname, String description) {
  
          super();
          this.database = database;
          setGroupname(groupname);
          setDescription(description);
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The {@link MemoryUserDatabase} that owns this group.
       */
      protected MemoryUserDatabase database = null;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Return the set of {@link User}s that are members of this group.
       */
      public Iterator getUsers() {
  
          String groupname = getGroupname();
          ArrayList results = new ArrayList();
          Iterator users = database.getUsers();
          while (users.hasNext()) {
              MemoryUser user = (MemoryUser) users.next();
              if (user.isInGroup(this)) {
                  results.add(user);
              }
          }
          return (results.iterator());
  
      }
  
  
      /**
       * <p>Return a String representation of this group in XML format.</p>
       */
      public String toString() {
  
          StringBuffer sb = new StringBuffer("<group groupname='");
          sb.append(groupname);
          sb.append("'");
          if (description != null) {
              sb.append(" description='");
              sb.append(description);
              sb.append("'");
          }
          synchronized (roles) {
              if (roles.size() > 0) {
                  sb.append(" roles='");
                  int n = 0;
                  Iterator values = roles.iterator();
                  while (values.hasNext()) {
                      if (n > 0) {
                          sb.append(',');
                      }
                      n++;
                      sb.append((String) values.next());
                  }
                  sb.append("'");
              }
          }
          sb.append("/>");
          return (sb.toString());
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUser.java
  
  Index: MemoryUser.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUser.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import org.apache.catalina.Group;
  import org.apache.catalina.User;
  import org.apache.catalina.UserDatabase;
  
  
  /**
   * <p>Concrete implementation of {@link User} for the
   * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public class MemoryUser extends AbstractUser {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Package-private constructor used by the factory method in
       * {@link MemoryUserDatabase}.
       *
       * @param database The {@link MemoryUserDatabase} that owns this user
       * @param username Logon username of the new user
       * @param password Logon password of the new user
       * @param fullName Full name of the new user
       */
      MemoryUser(MemoryUserDatabase database, String username,
                 String password, String fullName) {
  
          super();
          this.database = database;
          setUsername(username);
          setPassword(password);
          setFullName(fullName);
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The {@link MemoryUserDatabase} that owns this user.
       */
      protected MemoryUserDatabase database = null;
  
  
      /**
       * The set of {@link Group}s that this user is a member of.
       */
      protected ArrayList groups = new ArrayList();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Return the set of {@link Group}s to which this user belongs.
       */
      public Iterator getGroups() {
  
          synchronized (groups) {
              return (groups.iterator());
          }
  
      }
  
  
      /**
       * Add a new {@link Group} to those this user belongs to.
       *
       * @param group The new group
       */
      public void addGroup(Group group) {
  
          synchronized (groups) {
              if (!groups.contains(group)) {
                  groups.add(group);
              }
          }
  
      }
  
  
      /**
       * Is this user in the specified group?
       *
       * @param group The group to check
       */
      public boolean isInGroup(Group group) {
  
          synchronized (groups) {
              return (groups.contains(group));
          }
  
      }
  
  
      /**
       * Remove a {@link Group} from those this user belongs to.
       *
       * @param group The old group
       */
      public void removeGroup(Group group) {
  
          synchronized (groups) {
              groups.remove(group);
          }
  
      }
  
  
      /**
       * <p>Return a String representation of this user in XML format.</p>
       *
       * <p><strong>IMPLEMENTATION NOTE</strong> - For backwards compatibility,
       * the reader that processes this entry will accept either
       * <code>username</code> or </code>name</code> for the username
       * property.</p>
       */
      public String toString() {
  
          StringBuffer sb = new StringBuffer("<user username='");
          sb.append(username);
          sb.append("' password='");
          sb.append(password);
          sb.append("'");
          if (fullName != null) {
              sb.append(" fullname='");
              sb.append(fullName);
              sb.append("'");
          }
          synchronized (groups) {
              if (groups.size() > 0) {
                  sb.append(" groups='");
                  int n = 0;
                  Iterator values = groups.iterator();
                  while (values.hasNext()) {
                      if (n > 0) {
                          sb.append(',');
                      }
                      n++;
                      sb.append(((Group) values.next()).getGroupname());
                  }
                  sb.append("'");
              }
          }
          synchronized (roles) {
              if (roles.size() > 0) {
                  sb.append(" roles='");
                  int n = 0;
                  Iterator values = roles.iterator();
                  while (values.hasNext()) {
                      if (n > 0) {
                          sb.append(',');
                      }
                      n++;
                      sb.append((String) values.next());
                  }
                  sb.append("'");
              }
          }
          sb.append("/>");
          return (sb.toString());
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUserDatabase.java
  
  Index: MemoryUserDatabase.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUserDatabase.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.util.HashMap;
  import java.util.Iterator;
  import org.apache.catalina.Group;
  import org.apache.catalina.User;
  import org.apache.catalina.UserDatabase;
  import org.apache.catalina.util.StringManager;
  import org.apache.commons.digester.Digester;
  import org.apache.commons.digester.ObjectCreationFactory;
  import org.xml.sax.Attributes;
  
  
  /**
   * <p>Concrete implementation of {@link UserDatabase} that loads all
   * defined users and groups into an in-memory data structure, and uses
   * a specified XML file for its persistent storage.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public class MemoryUserDatabase implements UserDatabase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The character encoding to be used when reading and writing our
       * persistent storage file, or <code>null</code> for the platform
       * default encoding.
       */
      protected String encoding = null;
  
  
      /**
       * The set of {@link Group}s defined in this database, keyed by
       * group name.
       */
      protected HashMap groups = new HashMap();
  
  
      /**
       * The relative (to <code>catalina.base</code>) or absolute pathname to
       * the XML file in which we will save our persistent information.
       */
      protected String pathname = "conf/tomcat-users.xml";
  
  
      /**
       * The relative or absolute pathname to the file in which our old
       * information is stored while renaming is in progress.
       */
      protected String pathnameOld = pathname + ".old";
  
  
      /**
       * The relative or absolute pathname ot the file in which we write
       * our new information prior to renaming.
       */
      protected String pathnameNew = pathname + ".new";
  
  
      /**
       * The string manager for this package.
       */
      private static StringManager sm =
          StringManager.getManager(Constants.Package);
  
  
      /**
       * The set of {@link User}s defined in this database, keyed by
       * user name.
       */
      protected HashMap users = new HashMap();
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the character encoding for our persistent storage file.
       */
      public String getEncoding() {
  
          return (this.encoding);
  
      }
  
  
      /**
       * Set the character encoding for our persistent storage file.
       *
       * @param encoding The new encoding
       */
      public void setEncoding(String encoding) {
  
          this.encoding = encoding;
  
      }
  
  
      /**
       * Return the set of {@link Group}s defined in this user database.
       */
      public Iterator getGroups() {
  
          synchronized (groups) {
              return (groups.values().iterator());
          }
  
      }
  
  
      /**
       * Return the relative or absolute pathname to the persistent storage file.
       */
      public String getPathname() {
  
          return (this.pathname);
  
      }
  
  
      /**
       * Set the relative or absolute pathname to the persistent storage file.
       *
       * @param pathname The new pathname
       */
      public void setPathname(String pathname) {
  
          this.pathname = pathname;
          this.pathnameOld = pathname + ".old";
          this.pathnameNew = pathname + ".new";
  
      }
  
  
      /**
       * Return the set of {@link User}s defined in this user database.
       */
      public Iterator getUsers() {
  
          synchronized (users) {
              return (users.values().iterator());
          }
  
      }
  
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Finalize access to this user database.
       *
       * @exception Exception if any exception is thrown during closing
       */
      public void close() throws Exception {
  
          save();
  
          synchronized (groups) {
              synchronized (users) {
                  users.clear();
                  groups.clear();
              }
          }
  
      }
  
  
      /**
       * Create and return a new {@link Group} defined in this user database.
       *
       * @param groupname The group name of the new group (must be unique)
       * @param description The description of this group
       */
      public Group createGroup(String groupname, String description) {
  
          MemoryGroup group = new MemoryGroup(this, groupname, description);
          synchronized (groups) {
              groups.put(group.getGroupname(), group);
          }
          return (group);
  
      }
  
  
      /**
       * Create and return a new {@link User} defined in this user database.
       *
       * @param username The logon username of the new user (must be unique)
       * @param password The logon password of the new user
       * @param fullName The full name of the new user
       */
      public User createUser(String username, String password,
                             String fullName) {
  
          MemoryUser user = new MemoryUser(this, username, password, fullName);
          synchronized (users) {
              users.put(user.getUsername(), user);
          }
          return (user);
  
      }
  
  
      /**
       * Return the {@link Group} with the specified group name, if any;
       * otherwise return <code>null</code>.
       *
       * @param groupname Name of the group to return
       */
      public Group findGroup(String groupname) {
  
          synchronized (groups) {
              return ((Group) groups.get(groupname));
          }
  
      }
  
  
      /**
       * Return the {@link User} with the specified user name, if any;
       * otherwise return <code>null</code>.
       *
       * @param username Name of the user to return
       */
      public User findUser(String username) {
  
          synchronized (users) {
              return ((User) users.get(username));
          }
  
      }
  
  
      /**
       * Initialize access to this user database.
       *
       * @exception Exception if any exception is thrown during opening
       */
      public void open() throws Exception {
  
          synchronized (groups) {
              synchronized (users) {
  
                  // Erase any previous groups and users
                  users.clear();
                  groups.clear();
  
                  // Construct a reader for the XML input file (if it exists)
                  File file = new File(pathname);
                  if (!file.isAbsolute()) {
                      file = new File(System.getProperty("catalina.base"),
                                      pathname);
                  }
                  if (!file.exists()) {
                      return;
                  }
                  FileInputStream fis = new FileInputStream(file);
  
                  // Construct a digester to read the XML input file
                  Digester digester = new Digester();
                  digester.addFactoryCreate
                      ("tomcat-users/group",
                       new MemoryGroupCreationFactory(this));
                  digester.addFactoryCreate
                      ("tomcat-users/user",
                       new MemoryUserCreationFactory(this));
  
                  // Parse the XML input file to load this database
                  try {
                      digester.parse(fis);
                      fis.close();
                  } catch (Exception e) {
                      try {
                          fis.close();
                      } catch (Throwable t) {
                          ;
                      }
                      throw e;
                  }
  
              }
          }
  
      }
  
  
      /**
       * Remove the specified {@link Group} from this user database.
       *
       * @param group The group to be removed
       */
      public void removeGroup(Group group) {
  
          synchronized (groups) {
              Iterator users = getUsers();
              while (users.hasNext()) {
                  User user = (User) users.next();
                  user.removeGroup(group);
              }
              groups.remove(group.getGroupname());
          }
  
      }
  
  
      /**
       * Remove the specified {@link User} from this user database.
       *
       * @param user The user to be removed
       */
      public void removeUser(User user) {
  
          synchronized (users) {
              users.remove(user.getUsername());
          }
  
      }
  
  
      /**
       * Save any updated information to the persistent storage location for
       * this user database.
       *
       * @exception Exception if any exception is thrown during saving
       */
      public void save() throws Exception {
  
          // Write out contents to a temporary file
          File fileNew = new File(pathnameNew);
          if (!fileNew.isAbsolute()) {
              fileNew =
                  new File(System.getProperty("catalina.base"), pathnameNew);
          }
          PrintWriter writer = null;
          try {
  
              // Configure our PrintWriter
              FileOutputStream fos = new FileOutputStream(fileNew);
              OutputStreamWriter osw = null;
              if (encoding == null) {
                  osw = new OutputStreamWriter(fos);
              } else {
                  osw = new OutputStreamWriter(fos, encoding);
              }
              writer = new PrintWriter(osw);
  
              // Print the file prolog
              writer.print("<?xml version='1.0' encoding='");
              writer.print(osw.getEncoding());
              writer.println("'?>");
              writer.println("<tomcat-users>");
  
              // Print entries for each defined group and user
              Iterator values = getGroups();
              while (values.hasNext()) {
                  writer.print("  ");
                  writer.println(values.next());
              }
              values = getUsers();
              while (values.hasNext()) {
                  writer.print("  ");
                  writer.println(values.next());
              }
  
              // Print the file epilog
              writer.println("</tomcat-users>");
  
              // Check for errors that occurred while printing
              if (writer.checkError()) {
                  writer.close();
                  fileNew.delete();
                  throw new IOException
                      (sm.getString("memoryUserDatabase.writeException",
                                    fileNew.getAbsolutePath()));
              }
              writer.close();
          } catch (IOException e) {
              if (writer != null) {
                  writer.close();
              }
              fileNew.delete();
              throw e;
          }
  
          // Perform the required renames to permanently save this file
          File fileOld = new File(pathnameNew);
          if (!fileOld.isAbsolute()) {
              fileOld =
                  new File(System.getProperty("catalina.base"), pathnameOld);
          }
          fileOld.delete();
          File fileOrig = new File(pathname);
          if (!fileOrig.isAbsolute()) {
              fileOrig =
                  new File(System.getProperty("catalina.base"), pathname);
          }
          if (fileOrig.exists()) {
              fileOld.delete();
              if (!fileOrig.renameTo(fileOld)) {
                  throw new IOException
                      (sm.getString("memoryUserDatabase.renameOld",
                                    fileOld.getAbsolutePath()));
              }
          }
          if (!fileNew.renameTo(fileOrig)) {
              if (fileOld.exists()) {
                  fileOld.renameTo(fileOrig);
              }
              throw new IOException
                  (sm.getString("memoryUserDatabase.renameNew",
                                fileOrig.getAbsolutePath()));
          }
          fileOld.delete();
  
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
      /**
       * Return the <code>StringManager</code> for use in looking up messages.
       */
      StringManager getStringManager() {
  
          return (sm);
  
      }
  
  
  }
  
  
  
  /**
   * Digester object creation factory for group instances.
   */
  class MemoryGroupCreationFactory implements ObjectCreationFactory {
  
      public MemoryGroupCreationFactory(MemoryUserDatabase database) {
          this.database = database;
      }
  
      public Object createObject(Attributes attributes) {
          String groupname = attributes.getValue("groupname");
          if (groupname == null) {
              groupname = attributes.getValue("name");
          }
          String description = attributes.getValue("description");
          String roles = attributes.getValue("roles");
          Group group = database.createGroup(groupname, description);
          if (roles != null) {
              while (roles.length() > 0) {
                  String role = null;
                  int comma = roles.indexOf(',');
                  if (comma >= 0) {
                      role = roles.substring(0, comma).trim();
                      roles = roles.substring(comma + 1);
                  } else {
                      role = roles.trim();
                      roles = "";
                  }
                  group.addRole(role);
              }
          }
          return (group);
      }
  
      private MemoryUserDatabase database = null;
  
      private Digester digester = null;
  
      public Digester getDigester() {
          return (this.digester);
      }
  
      public void setDigester(Digester digester) {
          this.digester = digester;
      }
  
  }
  
  
  /**
   * Digester object creation factory for user instances.
   */
  class MemoryUserCreationFactory implements ObjectCreationFactory {
  
      public MemoryUserCreationFactory(MemoryUserDatabase database) {
          this.database = database;
      }
  
      public Object createObject(Attributes attributes) {
          String username = attributes.getValue("username");
          if (username == null) {
              username = attributes.getValue("name");
          }
          String password = attributes.getValue("password");
          String fullName = attributes.getValue("fullname");
          String groups = attributes.getValue("groups");
          String roles = attributes.getValue("roles");
          User user = database.createUser(username, password, fullName);
          if (groups != null) {
              while (groups.length() > 0) {
                  String groupname = null;
                  int comma = groups.indexOf(',');
                  if (comma >= 0) {
                      groupname = groups.substring(0, comma).trim();
                      groups = groups.substring(comma + 1);
                  } else {
                      groupname = groups.trim();
                      groups = "";
                  }
                  Group group = database.findGroup(groupname);
                  if (group == null) {
                      throw new IllegalArgumentException
                          (database.getStringManager().getString
                           ("memoryUserDatabase.invalidGroup", groupname));
                  }
                  user.addGroup(group);
              }
          }
          if (roles != null) {
              while (roles.length() > 0) {
                  String role = null;
                  int comma = roles.indexOf(',');
                  if (comma >= 0) {
                      role = roles.substring(0, comma).trim();
                      roles = roles.substring(comma + 1);
                  } else {
                      role = roles.trim();
                      roles = "";
                  }
                  user.addRole(role);
              }
          }
          return (user);
      }
  
      private MemoryUserDatabase database = null;
  
      private Digester digester = null;
  
      public Digester getDigester() {
          return (this.digester);
      }
  
      public void setDigester(Digester digester) {
          this.digester = digester;
      }
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUserDatabaseFactory.java
  
  Index: MemoryUserDatabaseFactory.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUserDatabaseFactory.java,v
 1.1 2002/01/20 03:00:57 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/20 03:00:57 $
   *
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 [EMAIL PROTECTED]
   *
   * 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.catalina.users;
  
  
  import java.util.Hashtable;
  import java.security.AccessControlException;
  import javax.naming.Name;
  import javax.naming.Context;
  import javax.naming.NamingException;
  import javax.naming.Reference;
  import javax.naming.RefAddr;
  import javax.naming.spi.ObjectFactory;
  
  
  /**
   * <p>JNDI object creation factory for <code>MemoryUserDatabase</code>
   * instances.  This makes it convenient to configure a user database
   * in the global JNDI resources associated with this Catalina instance,
   * and then link to that resource for web applications that administer
   * the contents of the user database.</p>
   *
   * <p>The <code>MemoryUserDatabase</code> instance is configured based
   * on the following parameter values:</p>
   * <ul>
   * <li><strong>encoding</strong> - The character encoding to use when
   *     saving the user information to the specified XML file.
   *     [Server platform default encoding]</li>
   * <li><strong>pathname</strong> - Absolute or relative (to the directory
   *     path specified by the <code>catalina.base</code> system property)
   *     pathname to the XML file from which our user information is loaded,
   *     and to which it is stored.  [conf/tomcat-users.xml]</li>
   * </ul>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/20 03:00:57 $
   * @since 4.1
   */
  
  public class MemoryUserDatabaseFactory implements ObjectFactory {
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * <p>Create and return a new <code>MemoryUserDatabase</code> instance
       * that has been configured according to the properties of the
       * specified <code>Reference</code>.  If you instance can be created,
       * return <code>null</code> instead.</p>
       *
       * @param obj The possibly null object containing location or
       *  reference information that can be used in creating an object
       * @param name The name of this object relative to <code>nameCtx</code>
       * @param nameCtx The context relative to which the <code>name</code>
       *  parameter is specified, or <code>null</code> if <code>name</code>
       *  is relative to the default initial context
       * @param environment The possibly null environment that is used in
       *  creating this object
       */
      public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                      Hashtable environment)
          throws Exception {
  
          // We only know how to deal with <code>javax.naming.Reference</code>s
          // that specify a class name of "org.apache.catalina.UserDatabase"
          if ((obj == null) || !(obj instanceof Reference)) {
              return (null);
          }
          Reference ref = (Reference) obj;
          if (!"org.apache.catalina.UserDatabase".equals(ref.getClassName())) {
              return (null);
          }
  
          // Create and configure a MemoryUserDatabase instance based on the
          // RefAddr values associated with this Reference
          MemoryUserDatabase database = new MemoryUserDatabase();
          RefAddr ra = null;
  
          ra = ref.get("encoding");
          if (ra != null) {
              database.setEncoding(ra.getContent().toString());
          }
  
          ra = ref.get("pathname");
          if (ra != null) {
              database.setPathname(ra.getContent().toString());
          }
  
          // Return the configured database instance
          database.open();
          database.save();
          return (database);
  
      }
  
  
  }
  
  
  
  1.57      +7 -0      jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- web.xml   19 Jan 2002 01:58:24 -0000      1.56
  +++ web.xml   20 Jan 2002 03:00:57 -0000      1.57
  @@ -1888,6 +1888,13 @@
       </servlet-mapping>
   
   
  +    <!-- ========== Session Configuration ================================= -->
  +
  +    <session-config>
  +        <session-timeout>5</session-timeout>
  +    </session-config>
  +
  +
       <!-- ========== Error Page Mappings =================================== -->
   
       <error-page>
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to