tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/webapps/admin/users group.jsp groups.jspf role.jsp roles.jspf user.jsp users.jspf
Date Sun, 10 Feb 2002 08:06:21 GMT
craigmcc    02/02/10 00:06:21

  Modified:    catalina/src/share/org/apache/catalina Group.java User.java
               catalina/src/share/org/apache/catalina/mbeans
                        mbeans-descriptors.xml
               catalina/src/share/org/apache/catalina/users
                        AbstractGroup.java AbstractUser.java
                        MemoryGroup.java MemoryUser.java
               webapps/admin/WEB-INF struts-config.xml
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users
                        GroupForm.java ListGroupsAction.java
                        ListRolesAction.java ListUsersAction.java
                        SaveGroupAction.java SaveRoleAction.java
                        SaveUserAction.java SetUpGroupAction.java
                        SetUpRoleAction.java SetUpUserAction.java
                        UserForm.java
               webapps/admin/users group.jsp groups.jspf role.jsp
                        roles.jspf user.jsp users.jspf
  Added:       webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users
                        UserUtils.java
  Log:
  Complete full support for associating roles with users and groups, and
  associating groups with users.  Modulo any remaining bugs, the "User
  and Group Administration" section of the admin app should be fully
  functional.
  
  Revision  Changes    Path
  1.5       +10 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Group.java
  
  Index: Group.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Group.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Group.java	3 Feb 2002 00:56:57 -0000	1.4
  +++ Group.java	10 Feb 2002 08:06:19 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Group.java,v 1.4 2002/02/03 00:56:57 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/03 00:56:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Group.java,v 1.5 2002/02/10 08:06:19 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/10 08:06:19 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -74,7 +74,7 @@
    * inherits the {@link Role}s assigned to the group.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2002/02/03 00:56:57 $
  + * @version $Revision: 1.5 $ $Date: 2002/02/10 08:06:19 $
    * @since 4.1
    */
   
  @@ -157,6 +157,12 @@
        * @param role The old role
        */
       public void removeRole(Role role);
  +
  +
  +    /**
  +     * Remove all {@link Role}s from those assigned to this group.
  +     */
  +    public void removeRoles();
   
   
   }
  
  
  
  1.5       +16 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/User.java
  
  Index: User.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/User.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- User.java	3 Feb 2002 00:56:57 -0000	1.4
  +++ User.java	10 Feb 2002 08:06:19 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/User.java,v 1.4 2002/02/03 00:56:57 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/03 00:56:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/User.java,v 1.5 2002/02/10 08:06:19 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/10 08:06:19 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -75,7 +75,7 @@
    * of specific {@link Role}s.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2002/02/03 00:56:57 $
  + * @version $Revision: 1.5 $ $Date: 2002/02/10 08:06:19 $
    * @since 4.1
    */
   
  @@ -197,11 +197,23 @@
   
   
       /**
  +     * Remove all {@link Group}s from those this user belongs to.
  +     */
  +    public void removeGroups();
  +
  +
  +    /**
        * Remove a {@link Role} from those assigned to this user.
        *
        * @param role The old role
        */
       public void removeRole(Role role);
  +
  +
  +    /**
  +     * Remove all {@link Role}s from those assigned to this user.
  +     */
  +    public void removeRoles();
   
   
   }
  
  
  
  1.28      +19 -1     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/mbeans-descriptors.xml
  
  Index: mbeans-descriptors.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/mbeans-descriptors.xml,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- mbeans-descriptors.xml	10 Feb 2002 03:20:17 -0000	1.27
  +++ mbeans-descriptors.xml	10 Feb 2002 08:06:20 -0000	1.28
  @@ -6,7 +6,7 @@
   <!--
        Descriptions of JMX MBeans for Catalina
   
  -     $Id: mbeans-descriptors.xml,v 1.27 2002/02/10 03:20:17 craigmcc Exp $
  +     $Id: mbeans-descriptors.xml,v 1.28 2002/02/10 08:06:20 craigmcc Exp $
    -->
   
   <mbeans-descriptors>
  @@ -161,6 +161,12 @@
                    type="java.lang.String"/>
       </operation>
   
  +    <operation   name="removeRoles"
  +          description="Remove all authorized roles for this group"
  +               impact="ACTION"
  +           returnType="void">
  +    </operation>
  +
     </mbean>
   
   
  @@ -1436,6 +1442,12 @@
                    type="java.lang.String"/>
       </operation>
   
  +    <operation   name="removeGroups"
  +          description="Remove all group memberships for this user"
  +               impact="ACTION"
  +           returnType="void">
  +    </operation>
  +
       <operation   name="removeRole"
             description="Remove an old authorized role for this user"
                  impact="ACTION"
  @@ -1443,6 +1455,12 @@
         <parameter name="role"
             description="Role to be removed"
                    type="java.lang.String"/>
  +    </operation>
  +
  +    <operation   name="removeRoles"
  +          description="Remove all authorized roles for this user"
  +               impact="ACTION"
  +           returnType="void">
       </operation>
   
     </mbean>
  
  
  
  1.4       +10 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractGroup.java
  
  Index: AbstractGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractGroup.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractGroup.java	3 Feb 2002 00:56:58 -0000	1.3
  +++ AbstractGroup.java	10 Feb 2002 08:06:20 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractGroup.java,v 1.3 2002/02/03 00:56:58 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/03 00:56:58 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractGroup.java,v 1.4 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -75,7 +75,7 @@
    * <p>Convenience base class for {@link Group} implementations.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2002/02/03 00:56:58 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -189,6 +189,12 @@
        * @param role The old role
        */
       public abstract void removeRole(Role role);
  +
  +
  +    /**
  +     * Remove all {@link Role}s from those assigned to this group.
  +     */
  +    public abstract void removeRoles();
   
   
       // ------------------------------------------------------ Principal Methods
  
  
  
  1.4       +16 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractUser.java
  
  Index: AbstractUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractUser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractUser.java	3 Feb 2002 00:56:58 -0000	1.3
  +++ AbstractUser.java	10 Feb 2002 08:06:20 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractUser.java,v 1.3 2002/02/03 00:56:58 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/03 00:56:58 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/AbstractUser.java,v 1.4 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -74,7 +74,7 @@
    * <p>Convenience base class for {@link User} implementations.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2002/02/03 00:56:58 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -235,11 +235,23 @@
   
   
       /**
  +     * Remove all {@link Group}s from those this user belongs to.
  +     */
  +    public abstract void removeGroups();
  +
  +
  +    /**
        * Remove a {@link Role} from those assigned to this user.
        *
        * @param role The old role
        */
       public abstract void removeRole(Role role);
  +
  +
  +    /**
  +     * Remove all {@link Role}s from those assigned to this user.
  +     */
  +    public abstract void removeRoles();
   
   
       // ------------------------------------------------------ Principal Methods
  
  
  
  1.5       +16 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryGroup.java
  
  Index: MemoryGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryGroup.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MemoryGroup.java	10 Feb 2002 03:20:17 -0000	1.4
  +++ MemoryGroup.java	10 Feb 2002 08:06:20 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryGroup.java,v 1.4 2002/02/10 03:20:17 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/10 03:20:17 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryGroup.java,v 1.5 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -77,7 +77,7 @@
    * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2002/02/10 03:20:17 $
  + * @version $Revision: 1.5 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -206,6 +206,18 @@
   
           synchronized (roles) {
               roles.remove(role);
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Remove all {@link Role}s from those assigned to this group.
  +     */
  +    public void removeRoles() {
  +
  +        synchronized (roles) {
  +            roles.clear();
           }
   
       }
  
  
  
  1.5       +28 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUser.java
  
  Index: MemoryUser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUser.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MemoryUser.java	10 Feb 2002 03:20:17 -0000	1.4
  +++ MemoryUser.java	10 Feb 2002 08:06:20 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUser.java,v 1.4 2002/02/10 03:20:17 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/10 03:20:17 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUser.java,v 1.5 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -77,7 +77,7 @@
    * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2002/02/10 03:20:17 $
  + * @version $Revision: 1.5 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -246,6 +246,18 @@
   
   
       /**
  +     * Remove all {@link Group}s from those this user belongs to.
  +     */
  +    public void removeGroups() {
  +
  +        synchronized (groups) {
  +            groups.clear();
  +        }
  +
  +    }
  +
  +
  +    /**
        * Remove a {@link Role} from those assigned to this user.
        *
        * @param role The old role
  @@ -254,6 +266,18 @@
   
           synchronized (roles) {
               roles.remove(role);
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Remove all {@link Role}s from those assigned to this user.
  +     */
  +    public void removeRoles() {
  +
  +        synchronized (roles) {
  +            roles.clear();
           }
   
       }
  
  
  
  1.27      +3 -3      jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- struts-config.xml	10 Feb 2002 05:48:57 -0000	1.26
  +++ struts-config.xml	10 Feb 2002 08:06:20 -0000	1.27
  @@ -483,19 +483,19 @@
       <action    path="/users/saveGroup"
                 input="/users/group.jsp"
                  name="groupForm"
  -              scope="session"
  +              scope="request"
                  type="org.apache.webapp.admin.users.SaveGroupAction"/>
   
       <action    path="/users/saveRole"
                 input="/users/role.jsp"
                  name="roleForm"
  -              scope="session"
  +              scope="request"
                  type="org.apache.webapp.admin.users.SaveRoleAction"/>
   
       <action    path="/users/saveUser"
                 input="/users/user.jsp"
                  name="userForm"
  -              scope="session"
  +              scope="request"
                  type="org.apache.webapp.admin.users.SaveUserAction"/>
   
       <action    path="/users/setUpGroup"
  
  
  
  1.2       +21 -3     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/GroupForm.java
  
  Index: GroupForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/GroupForm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GroupForm.java	10 Feb 2002 03:18:37 -0000	1.1
  +++ GroupForm.java	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/GroupForm.java,v 1.1 2002/02/10 03:18:37 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/10 03:18:37 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/GroupForm.java,v 1.2 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    * Form bean for the individual group page.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/02/10 03:18:37 $
  + * @version $Revision: 1.2 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -114,6 +114,23 @@
       }
   
   
  +    /**
  +     * The MBean Names of the roles associated with this group.
  +     */
  +    private String roles[] = new String[0];
  +
  +    public String[] getRoles() {
  +        return (this.roles);
  +    }
  +
  +    public void setRoles(String roles[]) {
  +        if (roles == null) {
  +            roles = new String[0];
  +        }
  +        this.roles = roles;
  +    }
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -128,6 +145,7 @@
           super.reset(mapping, request);
           description = null;
           groupname = null;
  +        roles = new String[0];
   
       }
   
  
  
  
  1.3       +10 -21    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListGroupsAction.java
  
  Index: ListGroupsAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListGroupsAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListGroupsAction.java	10 Feb 2002 05:48:57 -0000	1.2
  +++ ListGroupsAction.java	10 Feb 2002 08:06:20 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListGroupsAction.java,v 1.2 2002/02/10 05:48:57 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/10 05:48:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListGroupsAction.java,v 1.3 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -65,11 +65,9 @@
   
   import java.io.IOException;
   import java.net.URLDecoder;
  -import java.util.Arrays;
   import java.util.Locale;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  -import javax.management.modelmbean.ModelMBean;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  @@ -94,7 +92,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/02/10 05:48:57 $
  + * @version $Revision: 1.3 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -152,32 +150,23 @@
           Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
   
   
  -        // Acquire the set of group object names to be listed
  +        // Create a form bean containing the requested MBean Names
           String databaseName =
               URLDecoder.decode(request.getParameter("databaseName"));
  -        String results[] = null;
  +        GroupsForm groupsForm = null;
           try {
  -            ObjectName dname = new ObjectName(databaseName);
  -            results =
  -                (String[]) mserver.getAttribute(dname, "groups");
  -            if (results == null) {
  -                results = new String[0];
  -            }
  -            Arrays.sort(results);
  -        } catch (Throwable t) {
  +            groupsForm = UserUtils.getGroupsForm(mserver, databaseName);
  +        } catch (Exception e) {
               getServlet().log(resources.getMessage
                                (locale,
  -                              "users.error.attribute.get", "groups"), t);
  +                              "users.error.attribute.get", "groups"), e);
               response.sendError
                   (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    resources.getMessage
                    (locale, "users.error.attribute.get", "groups"));
           }
   
  -        // Stash the results in a form bean
  -        GroupsForm groupsForm = new GroupsForm();
  -        groupsForm.setDatabaseName(databaseName);
  -        groupsForm.setGroups(results);
  +        // Stash the results in request scope
           request.setAttribute("groupsForm", groupsForm);
           saveToken(request);
           String forward =
  
  
  
  1.3       +10 -21    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListRolesAction.java
  
  Index: ListRolesAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListRolesAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListRolesAction.java	10 Feb 2002 05:48:57 -0000	1.2
  +++ ListRolesAction.java	10 Feb 2002 08:06:20 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListRolesAction.java,v 1.2 2002/02/10 05:48:57 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/10 05:48:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListRolesAction.java,v 1.3 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -65,11 +65,9 @@
   
   import java.io.IOException;
   import java.net.URLDecoder;
  -import java.util.Arrays;
   import java.util.Locale;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  -import javax.management.modelmbean.ModelMBean;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  @@ -94,7 +92,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/02/10 05:48:57 $
  + * @version $Revision: 1.3 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -152,32 +150,23 @@
           Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
   
   
  -        // Acquire the set of role object names to be listed
  +        // Create a form bean containing the requested MBean Names
           String databaseName =
               URLDecoder.decode(request.getParameter("databaseName"));
  -        String results[] = null;
  +        RolesForm rolesForm = null;
           try {
  -            ObjectName dname = new ObjectName(databaseName);
  -            results =
  -                (String[]) mserver.getAttribute(dname, "roles");
  -            if (results == null) {
  -                results = new String[0];
  -            }
  -            Arrays.sort(results);
  -        } catch (Throwable t) {
  +            rolesForm = UserUtils.getRolesForm(mserver, databaseName);
  +        } catch (Exception e) {
               getServlet().log(resources.getMessage
                                (locale,
  -                              "users.error.attribute.get", "roles"), t);
  +                              "users.error.attribute.get", "roles"), e);
               response.sendError
                   (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    resources.getMessage
                    (locale, "users.error.attribute.get", "roles"));
           }
   
  -        // Stash the results in a form bean
  -        RolesForm rolesForm = new RolesForm();
  -        rolesForm.setDatabaseName(databaseName);
  -        rolesForm.setRoles(results);
  +        // Stash the results in request scope
           request.setAttribute("rolesForm", rolesForm);
           saveToken(request);
           String forward =
  
  
  
  1.3       +10 -21    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListUsersAction.java
  
  Index: ListUsersAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListUsersAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListUsersAction.java	10 Feb 2002 05:48:57 -0000	1.2
  +++ ListUsersAction.java	10 Feb 2002 08:06:20 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListUsersAction.java,v 1.2 2002/02/10 05:48:57 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/10 05:48:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/ListUsersAction.java,v 1.3 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -65,11 +65,9 @@
   
   import java.io.IOException;
   import java.net.URLDecoder;
  -import java.util.Arrays;
   import java.util.Locale;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  -import javax.management.modelmbean.ModelMBean;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  @@ -94,7 +92,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/02/10 05:48:57 $
  + * @version $Revision: 1.3 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -152,32 +150,23 @@
           Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
   
   
  -        // Acquire the set of user object names to be listed
  +        // Create a form bean containing the requested MBean Names
           String databaseName =
               URLDecoder.decode(request.getParameter("databaseName"));
  -        String results[] = null;
  +        UsersForm usersForm = null;
           try {
  -            ObjectName dname = new ObjectName(databaseName);
  -            results =
  -                (String[]) mserver.getAttribute(dname, "users");
  -            if (results == null) {
  -                results = new String[0];
  -            }
  -            Arrays.sort(results);
  -        } catch (Throwable t) {
  +            usersForm = UserUtils.getUsersForm(mserver, databaseName);
  +        } catch (Exception e) {
               getServlet().log(resources.getMessage
                                (locale,
  -                              "users.error.attribute.get", "users"), t);
  +                              "users.error.attribute.get", "users"), e);
               response.sendError
                   (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    resources.getMessage
                    (locale, "users.error.attribute.get", "users"));
           }
   
  -        // Stash the results in a form bean
  -        UsersForm usersForm = new UsersForm();
  -        usersForm.setDatabaseName(databaseName);
  -        usersForm.setUsers(results);
  +        // Stash the results in request scope
           request.setAttribute("usersForm", usersForm);
           saveToken(request);
           String forward =
  
  
  
  1.3       +46 -12    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveGroupAction.java
  
  Index: SaveGroupAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveGroupAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SaveGroupAction.java	10 Feb 2002 05:48:57 -0000	1.2
  +++ SaveGroupAction.java	10 Feb 2002 08:06:20 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveGroupAction.java,v 1.2 2002/02/10 05:48:57 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/10 05:48:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveGroupAction.java,v 1.3 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * updated Group back to the underlying database.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/02/10 05:48:57 $
  + * @version $Revision: 1.3 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -191,14 +191,14 @@
                   oname = new ObjectName(databaseName);
   
                   // Create the new object and associated MBean
  -                mserver.invoke(oname, "createGroup",
  -                               params, signature);
  +                objectName = (String) mserver.invoke(oname, "createGroup",
  +                                                     params, signature);
   
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
   
                   getServlet().log
                       (resources.getMessage(locale, "users.error.invoke",
  -                                          "createGroup"), t);
  +                                          "createGroup"), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage(locale, "users.error.invoke",
  @@ -225,11 +225,11 @@
                       (oname,
                        new Attribute(attribute, groupForm.getDescription()));
   
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
   
                   getServlet().log
                       (resources.getMessage(locale, "users.error.set.attribute",
  -                                          attribute), t);
  +                                          attribute), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage(locale, "users.error.set.attribute",
  @@ -240,6 +240,40 @@
   
           }
   
  +
  +        // Reset the roles associated with this group
  +        try {
  +
  +            ObjectName oname = new ObjectName(objectName);
  +            mserver.invoke(oname, "removeRoles",
  +                           new Object[0], new String[0]);
  +            String roles[] = groupForm.getRoles();
  +            if (roles == null) {
  +                roles = new String[0];
  +            }
  +            String addsig[] = new String[1];
  +            addsig[0] = "java.lang.String";
  +            Object addpar[] = new Object[1];
  +            for (int i = 0; i < roles.length; i++) {
  +                addpar[0] =
  +                    (new ObjectName(roles[i])).getKeyProperty("rolename");
  +                mserver.invoke(oname, "addRole",
  +                               addpar, addsig);
  +            }
  +
  +        } catch (Exception e) {
  +
  +            getServlet().log
  +                (resources.getMessage(locale, "users.error.invoke",
  +                                      "addRole"), e);
  +            response.sendError
  +                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                 resources.getMessage(locale, "users.error.invoke",
  +                                      "addRole"));
  +            return (null);
  +
  +        }
  +
           // Save the updated database information
           try {
   
  @@ -247,11 +281,11 @@
               mserver.invoke(dname, "save",
                              new Object[0], new String[0]);
   
  -        } catch (Throwable t) {
  +        } catch (Exception e) {
   
               getServlet().log
                   (resources.getMessage(locale, "users.error.invoke",
  -                                      "save"), t);
  +                                      "save"), e);
               response.sendError
                   (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    resources.getMessage(locale, "users.error.invoke",
  
  
  
  1.3       +9 -9      jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveRoleAction.java
  
  Index: SaveRoleAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveRoleAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SaveRoleAction.java	10 Feb 2002 05:48:57 -0000	1.2
  +++ SaveRoleAction.java	10 Feb 2002 08:06:20 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveRoleAction.java,v 1.2 2002/02/10 05:48:57 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/10 05:48:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveRoleAction.java,v 1.3 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * updated Role back to the underlying database.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/02/10 05:48:57 $
  + * @version $Revision: 1.3 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -194,11 +194,11 @@
                   mserver.invoke(oname, "createRole",
                                  params, signature);
   
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
   
                   getServlet().log
                       (resources.getMessage(locale, "users.error.invoke",
  -                                          "createRole"), t);
  +                                          "createRole"), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage(locale, "users.error.invoke",
  @@ -225,11 +225,11 @@
                       (oname,
                        new Attribute(attribute, roleForm.getDescription()));
   
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
   
                   getServlet().log
                       (resources.getMessage(locale, "users.error.set.attribute",
  -                                          attribute), t);
  +                                          attribute), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage(locale, "users.error.set.attribute",
  @@ -247,7 +247,7 @@
               mserver.invoke(dname, "save",
                              new Object[0], new String[0]);
   
  -        } catch (Throwable t) {
  +        } catch (Exception e) {
   
               getServlet().log
                   (resources.getMessage(locale, "users.error.invoke",
  
  
  
  1.3       +78 -12    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveUserAction.java
  
  Index: SaveUserAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveUserAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SaveUserAction.java	10 Feb 2002 05:48:57 -0000	1.2
  +++ SaveUserAction.java	10 Feb 2002 08:06:20 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveUserAction.java,v 1.2 2002/02/10 05:48:57 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/10 05:48:57 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SaveUserAction.java,v 1.3 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * updated User back to the underlying database.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2002/02/10 05:48:57 $
  + * @version $Revision: 1.3 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -193,14 +193,14 @@
                   oname = new ObjectName(databaseName);
   
                   // Create the new object and associated MBean
  -                mserver.invoke(oname, "createUser",
  -                               params, signature);
  +                objectName = (String) mserver.invoke(oname, "createUser",
  +                                                     params, signature);
   
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
   
                   getServlet().log
                       (resources.getMessage(locale, "users.error.invoke",
  -                                          "createUser"), t);
  +                                          "createUser"), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage(locale, "users.error.invoke",
  @@ -231,11 +231,11 @@
                       (oname,
                        new Attribute(attribute, userForm.getPassword()));
   
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
   
                   getServlet().log
                       (resources.getMessage(locale, "users.error.set.attribute",
  -                                          attribute), t);
  +                                          attribute), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage(locale, "users.error.set.attribute",
  @@ -246,6 +246,72 @@
   
           }
   
  +        // Reset the groups this user is a member of
  +        try {
  +
  +            ObjectName oname = new ObjectName(objectName);
  +            mserver.invoke(oname, "removeGroups",
  +                           new Object[0], new String[0]);
  +            String groups[] = userForm.getGroups();
  +            if (groups == null) {
  +                groups = new String[0];
  +            }
  +            String addsig[] = new String[1];
  +            addsig[0] = "java.lang.String";
  +            Object addpar[] = new Object[1];
  +            for (int i = 0; i < groups.length; i++) {
  +                addpar[0] =
  +                    (new ObjectName(groups[i])).getKeyProperty("groupname");
  +                mserver.invoke(oname, "addGroup",
  +                               addpar, addsig);
  +            }
  +
  +        } catch (Exception e) {
  +
  +            getServlet().log
  +                (resources.getMessage(locale, "users.error.invoke",
  +                                      "addGroup"), e);
  +            response.sendError
  +                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                 resources.getMessage(locale, "users.error.invoke",
  +                                      "addGroup"));
  +            return (null);
  +
  +        }
  +
  +        // Reset the roles associated with this user
  +        try {
  +
  +            ObjectName oname = new ObjectName(objectName);
  +            mserver.invoke(oname, "removeRoles",
  +                           new Object[0], new String[0]);
  +            String roles[] = userForm.getRoles();
  +            if (roles == null) {
  +                roles = new String[0];
  +            }
  +            String addsig[] = new String[1];
  +            addsig[0] = "java.lang.String";
  +            Object addpar[] = new Object[1];
  +            for (int i = 0; i < roles.length; i++) {
  +                addpar[0] =
  +                    (new ObjectName(roles[i])).getKeyProperty("rolename");
  +                mserver.invoke(oname, "addRole",
  +                               addpar, addsig);
  +            }
  +
  +        } catch (Exception e) {
  +
  +            getServlet().log
  +                (resources.getMessage(locale, "users.error.invoke",
  +                                      "addRole"), e);
  +            response.sendError
  +                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                 resources.getMessage(locale, "users.error.invoke",
  +                                      "addRole"));
  +            return (null);
  +
  +        }
  +
           // Save the updated database information
           try {
   
  @@ -253,11 +319,11 @@
               mserver.invoke(dname, "save",
                              new Object[0], new String[0]);
   
  -        } catch (Throwable t) {
  +        } catch (Exception e) {
   
               getServlet().log
                   (resources.getMessage(locale, "users.error.invoke",
  -                                      "save"), t);
  +                                      "save"), e);
               response.sendError
                   (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    resources.getMessage(locale, "users.error.invoke",
  
  
  
  1.2       +30 -8     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpGroupAction.java
  
  Index: SetUpGroupAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpGroupAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetUpGroupAction.java	10 Feb 2002 03:18:37 -0000	1.1
  +++ SetUpGroupAction.java	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpGroupAction.java,v 1.1 2002/02/10 03:18:37 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/10 03:18:37 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpGroupAction.java,v 1.2 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,7 @@
   
   
   import java.io.IOException;
  +import java.net.URLDecoder;
   import java.util.Iterator;
   import java.util.Locale;
   import javax.management.Attribute;
  @@ -97,7 +98,7 @@
    * being added, or a non-null value for an existing group.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/02/10 03:18:37 $
  + * @version $Revision: 1.2 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -153,6 +154,25 @@
           HttpSession session = request.getSession();
           Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
   
  +        // Set up a bean containing all possible roles
  +        String databaseName =
  +            URLDecoder.decode(request.getParameter("databaseName"));
  +        try {
  +            request.setAttribute("rolesForm",
  +                                 UserUtils.getRolesForm(mserver,
  +                                                        databaseName));
  +        } catch (Exception e) {
  +            getServlet().log
  +                (resources.getMessage(locale,
  +                                      "users.error.attribute.get",
  +                                      "roles"), e);
  +            response.sendError
  +                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                 resources.getMessage
  +                 (locale, "users.error.attribute.get", "roles"));
  +            return (null);
  +        }
  +
           // Set up the form bean based on the creating or editing state
           String objectName = request.getParameter("objectName");
           GroupForm groupForm = new GroupForm();
  @@ -173,11 +193,13 @@
                   attribute = "description";
                   groupForm.setDescription
                       ((String) mserver.getAttribute(oname, attribute));
  -                // FIXME - roles list
  -            } catch (Throwable t) {
  +                attribute = "roles";
  +                groupForm.setRoles
  +                    ((String[]) mserver.getAttribute(oname, attribute));
  +            } catch (Exception e) {
                   getServlet().log
                       (resources.getMessage(locale,
  -                        "users.error.attribute.get", attribute), t);
  +                        "users.error.attribute.get", attribute), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage
  @@ -185,11 +207,11 @@
                   return (null);
               }
           }
  -        groupForm.setDatabaseName(request.getParameter("databaseName"));
  +        groupForm.setDatabaseName(databaseName);
   
           // Stash the form bean and forward to the display page
           saveToken(request);
  -        session.setAttribute("groupForm", groupForm);
  +        request.setAttribute("groupForm", groupForm);
           return (mapping.findForward("Group"));
   
       }
  
  
  
  1.2       +10 -7     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpRoleAction.java
  
  Index: SetUpRoleAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpRoleAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetUpRoleAction.java	10 Feb 2002 03:18:38 -0000	1.1
  +++ SetUpRoleAction.java	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpRoleAction.java,v 1.1 2002/02/10 03:18:38 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/10 03:18:38 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpRoleAction.java,v 1.2 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,7 @@
   
   
   import java.io.IOException;
  +import java.net.URLDecoder;
   import java.util.Iterator;
   import java.util.Locale;
   import javax.management.Attribute;
  @@ -97,7 +98,7 @@
    * being added, or a non-null value for an existing role.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/02/10 03:18:38 $
  + * @version $Revision: 1.2 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -152,6 +153,8 @@
           }
           HttpSession session = request.getSession();
           Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
  +        String databaseName =
  +            URLDecoder.decode(request.getParameter("databaseName"));
   
           // Set up the form bean based on the creating or editing state
           String objectName = request.getParameter("objectName");
  @@ -173,10 +176,10 @@
                   attribute = "description";
                   roleForm.setDescription
                       ((String) mserver.getAttribute(oname, attribute));
  -            } catch (Throwable t) {
  +            } catch (Exception e) {
                   getServlet().log
                       (resources.getMessage(locale,
  -                        "users.error.attribute.get", attribute), t);
  +                        "users.error.attribute.get", attribute), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage
  @@ -184,11 +187,11 @@
                   return (null);
               }
           }
  -        roleForm.setDatabaseName(request.getParameter("databaseName"));
  +        roleForm.setDatabaseName(databaseName);
   
           // Stash the form bean and forward to the display page
           saveToken(request);
  -        session.setAttribute("roleForm", roleForm);
  +        request.setAttribute("roleForm", roleForm);
           return (mapping.findForward("Role"));
   
       }
  
  
  
  1.2       +48 -9     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpUserAction.java
  
  Index: SetUpUserAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpUserAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetUpUserAction.java	10 Feb 2002 03:18:38 -0000	1.1
  +++ SetUpUserAction.java	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpUserAction.java,v 1.1 2002/02/10 03:18:38 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/10 03:18:38 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/SetUpUserAction.java,v 1.2 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,7 @@
   
   
   import java.io.IOException;
  +import java.net.URLDecoder;
   import java.util.Iterator;
   import java.util.Locale;
   import javax.management.Attribute;
  @@ -97,7 +98,7 @@
    * being added, or a non-null value for an existing user.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/02/10 03:18:38 $
  + * @version $Revision: 1.2 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -153,6 +154,40 @@
           HttpSession session = request.getSession();
           Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
   
  +        // Set up beans containing all possible groups and roles
  +        String databaseName =
  +            URLDecoder.decode(request.getParameter("databaseName"));
  +        try {
  +            request.setAttribute("groupsForm",
  +                                 UserUtils.getGroupsForm(mserver,
  +                                                         databaseName));
  +        } catch (Exception e) {
  +            getServlet().log
  +                (resources.getMessage(locale,
  +                                      "users.error.attribute.get",
  +                                      "groups"), e);
  +            response.sendError
  +                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                 resources.getMessage
  +                 (locale, "users.error.attribute.get", "groups"));
  +            return (null);
  +        }
  +        try {
  +            request.setAttribute("rolesForm",
  +                                 UserUtils.getRolesForm(mserver,
  +                                                        databaseName));
  +        } catch (Exception e) {
  +            getServlet().log
  +                (resources.getMessage(locale,
  +                                      "users.error.attribute.get",
  +                                      "roles"), e);
  +            response.sendError
  +                (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                 resources.getMessage
  +                 (locale, "users.error.attribute.get", "roles"));
  +            return (null);
  +        }
  +
           // Set up the form bean based on the creating or editing state
           String objectName = request.getParameter("objectName");
           UserForm userForm = new UserForm();
  @@ -176,12 +211,16 @@
                   attribute = "fullName";
                   userForm.setFullName
                       ((String) mserver.getAttribute(oname, attribute));
  -                // FIXME - groups list
  -                // FIXME - roles list
  -            } catch (Throwable t) {
  +                attribute = "groups";
  +                userForm.setGroups
  +                    ((String[]) mserver.getAttribute(oname, attribute));
  +                attribute = "roles";
  +                userForm.setRoles
  +                    ((String[]) mserver.getAttribute(oname, attribute));
  +            } catch (Exception e) {
                   getServlet().log
                       (resources.getMessage(locale,
  -                        "users.error.attribute.get", attribute), t);
  +                        "users.error.attribute.get", attribute), e);
                   response.sendError
                       (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        resources.getMessage
  @@ -189,11 +228,11 @@
                   return (null);
               }
           }
  -        userForm.setDatabaseName(request.getParameter("databaseName"));
  +        userForm.setDatabaseName(databaseName);
   
           // Stash the form bean and forward to the display page
           saveToken(request);
  -        session.setAttribute("userForm", userForm);
  +        request.setAttribute("userForm", userForm);
           return (mapping.findForward("User"));
   
       }
  
  
  
  1.2       +19 -15    jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/UserForm.java
  
  Index: UserForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/UserForm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UserForm.java	10 Feb 2002 03:18:38 -0000	1.1
  +++ UserForm.java	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/UserForm.java,v 1.1 2002/02/10 03:18:38 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/10 03:18:38 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/UserForm.java,v 1.2 2002/02/10 08:06:20 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/10 08:06:20 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    * Form bean for the individual user page.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/02/10 03:18:38 $
  + * @version $Revision: 1.2 $ $Date: 2002/02/10 08:06:20 $
    * @since 4.1
    */
   
  @@ -101,15 +101,18 @@
   
   
       /**
  -     * A comma-delimited list of the groups this user is a member of.
  +     * The MBean Names of the groups associated with this user.
        */
  -    private String groups = null;
  +    private String groups[] = new String[0];
   
  -    public String getGroups() {
  +    public String[] getGroups() {
           return (this.groups);
       }
   
  -    public void setGroups(String groups) {
  +    public void setGroups(String groups[]) {
  +        if (groups == null) {
  +            groups = new String[0];
  +        }
           this.groups = groups;
       }
   
  @@ -129,17 +132,18 @@
   
   
       /**
  -     * A comma-delimited list of the security roles associated
  -     * with this user.  <strong>FIXME</strong> - implement as a
  -     * List instead, with predefined values?
  +     * The MBean Names of the roles associated with this user.
        */
  -    private String roles = null;
  +    private String roles[] = new String[0];
   
  -    public String getRoles() {
  +    public String[] getRoles() {
           return (this.roles);
       }
   
  -    public void setRoles(String roles) {
  +    public void setRoles(String roles[]) {
  +        if (roles == null) {
  +            roles = new String[0];
  +        }
           this.roles = roles;
       }
   
  @@ -170,9 +174,9 @@
   
           super.reset(mapping, request);
           fullName = null;
  -        groups = null;
  +        groups = new String[0];
           password = null;
  -        roles = null;
  +        roles = new String[0];
           username = null;
   
       }
  
  
  
  1.1                  jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/UserUtils.java
  
  Index: UserUtils.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/users/UserUtils.java,v 1.1 2002/02/10 08:06:20 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/10 08:06:20 $
   *
   * ====================================================================
   *
   * 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 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/>.
   *
   */
  
  
  package org.apache.webapp.admin.users;
  
  
  import java.util.Arrays;
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  
  
  /**
   * <p>Shared utility methods for the user database administration module.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/02/10 08:06:20 $
   * @since 4.1
   */
  
  public class UserUtils {
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Construct and return a GroupsForm identifying all currently defined
       * groups in the specified user database.
       *
       * @param mserver MBeanServer to be consulted
       * @param databaseName MBean Name of the user database to be consulted
       *
       * @exception Exception if an error occurs
       */
      public static GroupsForm getGroupsForm(MBeanServer mserver,
                                             String databaseName)
          throws Exception {
  
          ObjectName dname = new ObjectName(databaseName);
          String results[] =
              (String[]) mserver.getAttribute(dname, "groups");
          if (results == null) {
              results = new String[0];
          }
          Arrays.sort(results);
  
          GroupsForm groupsForm = new GroupsForm();
          groupsForm.setDatabaseName(databaseName);
          groupsForm.setGroups(results);
          return (groupsForm);
  
      }
  
  
      /**
       * Construct and return a RolesForm identifying all currently defined
       * roles in the specified user database.
       *
       * @param mserver MBeanServer to be consulted
       * @param databaseName MBean Name of the user database to be consulted
       *
       * @exception Exception if an error occurs
       */
      public static RolesForm getRolesForm(MBeanServer mserver,
                                             String databaseName)
          throws Exception {
  
          ObjectName dname = new ObjectName(databaseName);
          String results[] =
              (String[]) mserver.getAttribute(dname, "roles");
          if (results == null) {
              results = new String[0];
          }
          Arrays.sort(results);
  
          RolesForm rolesForm = new RolesForm();
          rolesForm.setDatabaseName(databaseName);
          rolesForm.setRoles(results);
          return (rolesForm);
  
      }
  
  
      /**
       * Construct and return a UsersForm identifying all currently defined
       * users in the specified user database.
       *
       * @param mserver MBeanServer to be consulted
       * @param databaseName MBean Name of the user database to be consulted
       *
       * @exception Exception if an error occurs
       */
      public static UsersForm getUsersForm(MBeanServer mserver,
                                             String databaseName)
          throws Exception {
  
          ObjectName dname = new ObjectName(databaseName);
          String results[] =
              (String[]) mserver.getAttribute(dname, "users");
          if (results == null) {
              results = new String[0];
          }
          Arrays.sort(results);
  
          UsersForm usersForm = new UsersForm();
          usersForm.setDatabaseName(databaseName);
          usersForm.setUsers(results);
          return (usersForm);
  
      }
  
  
  }
  
  
  
  1.2       +5 -1      jakarta-tomcat-4.0/webapps/admin/users/group.jsp
  
  Index: group.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/users/group.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- group.jsp	10 Feb 2002 03:15:04 -0000	1.1
  +++ group.jsp	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,6 +1,6 @@
   <!-- Standard Struts Entries -->
   
  -<%@ page language="java" %>
  +<%@ page language="java" import="java.net.URLEncoder" %>
   <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
   <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
   <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  @@ -106,6 +106,10 @@
       </tr>
   
     </table>
  +
  +  <bean:define id="checkboxes" scope="page" value="true"/>
  +  <br>
  +  <%@ include file="roles.jspf" %>
   
     <%@ include file="../buttons.jsp" %>
   
  
  
  
  1.2       +11 -4     jakarta-tomcat-4.0/webapps/admin/users/groups.jspf
  
  Index: groups.jspf
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/users/groups.jspf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- groups.jspf	10 Feb 2002 05:48:58 -0000	1.1
  +++ groups.jspf	10 Feb 2002 08:06:20 -0000	1.2
  @@ -11,7 +11,7 @@
             &nbsp;
           </td>
         </logic:present>
  -      <td><div align="left" class="table-header-text">
  +      <td width="20%"><div align="left" class="table-header-text">
           <bean:message key="users.list.groupname"/>
         </div></td>
         <td><div align="left" class="table-header-text">
  @@ -23,13 +23,20 @@
         <tr class="line-row">
           <logic:present name="checkboxes">
             <td><div align="center" class="table-normal-text">
  -            <input type="checkbox" name="groups"
  -                  value="<%= group %>">
  +            <logic:present name="userForm">
  +              <html:multibox property="groups" value="<%= group %>"/>
  +            </logic:present>
  +            <logic:notPresent name="userForm">
  +              <input type="checkbox" name="groups"
  +                    value="<%= group %>">
  +            </logic:notPresent>
             </td>
           </logic:present>
           <td><div align="left" class="table-normal-text">&nbsp;
             <html:link page='<%= "/users/setUpGroup.do?objectName=" + 
  -                               URLEncoder.encode(group) %>'>
  +                               URLEncoder.encode(group) +
  +                               "&databaseName=" +
  +                               URLEncoder.encode(request.getParameter("databaseName")) %>'>
               <controls:attribute name="group" attribute="groupname"/>
             </html:link>
           </div></td>
  
  
  
  1.2       +1 -1      jakarta-tomcat-4.0/webapps/admin/users/role.jsp
  
  Index: role.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/users/role.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- role.jsp	10 Feb 2002 03:15:04 -0000	1.1
  +++ role.jsp	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,6 +1,6 @@
   <!-- Standard Struts Entries -->
   
  -<%@ page language="java" %>
  +<%@ page language="java" import="java.net.URLEncoder" %>
   <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
   <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
   <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  
  
  
  1.3       +16 -4     jakarta-tomcat-4.0/webapps/admin/users/roles.jspf
  
  Index: roles.jspf
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/users/roles.jspf,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- roles.jspf	10 Feb 2002 05:48:58 -0000	1.2
  +++ roles.jspf	10 Feb 2002 08:06:20 -0000	1.3
  @@ -11,7 +11,7 @@
             &nbsp;
           </td>
         </logic:present>
  -      <td><div align="left" class="table-header-text">
  +      <td width="20%"><div align="left" class="table-header-text">
           <bean:message key="users.list.rolename"/>
         </div></td>
         <td><div align="left" class="table-header-text">
  @@ -23,13 +23,25 @@
         <tr class="line-row">
           <logic:present name="checkboxes">
             <td><div align="center" class="table-normal-text">
  -            <input type="checkbox" name="roles"
  -                  value="<%= role %>">
  +            <logic:present name="groupForm">
  +              <html:multibox property="roles" value="<%= role %>"/>
  +            </logic:present>
  +            <logic:present name="userForm">
  +              <html:multibox property="roles" value="<%= role %>"/>
  +            </logic:present>
  +            <logic:notPresent name="groupForm">
  +              <logic:notPresent name="userForm">
  +                <input type="checkbox" name="roles"
  +                      value="<%= role %>">
  +              </logic:notPresent>
  +            </logic:notPresent>
             </td>
           </logic:present>
           <td><div align="left" class="table-normal-text">&nbsp;
             <html:link page='<%= "/users/setUpRole.do?objectName=" + 
  -                               URLEncoder.encode(role) %>'>
  +                               URLEncoder.encode(role) +
  +                               "&databaseName=" +
  +                               URLEncoder.encode(request.getParameter("databaseName")) %>'>
               <controls:attribute name="role" attribute="rolename"/>
             </html:link>
           </div></td>
  
  
  
  1.2       +7 -1      jakarta-tomcat-4.0/webapps/admin/users/user.jsp
  
  Index: user.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/users/user.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- user.jsp	10 Feb 2002 03:15:04 -0000	1.1
  +++ user.jsp	10 Feb 2002 08:06:20 -0000	1.2
  @@ -1,6 +1,6 @@
   <!-- Standard Struts Entries -->
   
  -<%@ page language="java" %>
  +<%@ page language="java" import="java.net.URLEncoder" %>
   <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
   <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
   <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  @@ -116,6 +116,12 @@
       </tr>
   
     </table>
  +
  +  <bean:define id="checkboxes" scope="page" value="true"/>
  +  <br>
  +  <%@ include file="groups.jspf" %>
  +  <br>
  +  <%@ include file="roles.jspf" %>
   
     <%@ include file="../buttons.jsp" %>
   
  
  
  
  1.2       +4 -2      jakarta-tomcat-4.0/webapps/admin/users/users.jspf
  
  Index: users.jspf
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/users/users.jspf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- users.jspf	10 Feb 2002 05:48:58 -0000	1.1
  +++ users.jspf	10 Feb 2002 08:06:20 -0000	1.2
  @@ -11,7 +11,7 @@
             &nbsp;
           </td>
         </logic:present>
  -      <td><div align="left" class="table-header-text">
  +      <td width="20%"><div align="left" class="table-header-text">
           <bean:message key="users.list.username"/>
         </div></td>
         <td><div align="left" class="table-header-text">
  @@ -29,7 +29,9 @@
           </logic:present>
           <td><div align="left" class="table-normal-text">&nbsp;
             <html:link page='<%= "/users/setUpUser.do?objectName=" + 
  -                               URLEncoder.encode(user) %>'>
  +                               URLEncoder.encode(user) +
  +                               "&databaseName=" +
  +                               URLEncoder.encode(request.getParameter("databaseName")) %>'>
               <controls:attribute name="user" attribute="username"/>
             </html:link>
           </div></td>
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message