tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amy...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/webapps/admin/host host.jsp hosts.jsp
Date Mon, 03 Feb 2003 22:55:01 GMT
amyroh      2003/02/03 14:55:01

  Modified:    webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        Lists.java
               webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host
                        DeleteHostAction.java EditHostAction.java
               webapps/admin/host host.jsp hosts.jsp
  Log:
  Fix to disallow localhost deletion and realm addition to localhost.  The
  checking for localhost was done incorrectly on linux environment therefore
  letting localhost to be deleted.
  
  Revision  Changes    Path
  1.14      +33 -4     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java
  
  Index: Lists.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Lists.java	14 Sep 2002 23:37:39 -0000	1.13
  +++ Lists.java	3 Feb 2003 22:55:00 -0000	1.14
  @@ -696,4 +696,33 @@
       }
   
   
  +    /**
  +     * Return the  <code>Host</code> object name string
  +     * that the admin app belongs to.
  +     *
  +     * @param mbserver MBeanServer from which to retrieve the list
  +     * @param request Http request
  +     *
  +     * @exception Exception if thrown while retrieving the list
  +     */
  +    public static String getAdminAppHost
  +        (MBeanServer mbserver, String domain, HttpServletRequest request)
  +        throws Exception {
  +
  +        // Get the admin app's host name
  +        StringBuffer sb = new StringBuffer(domain);
  +        sb.append(":type=Context");
  +        sb.append(",path=");
  +        sb.append(request.getContextPath());
  +        sb.append(",*");
  +        ObjectName search = new ObjectName(sb.toString());
  +        Iterator names = mbserver.queryNames(search, null).iterator();
  +        String host = null;
  +        while (names.hasNext()) {
  +            host = ((ObjectName)names.next()).getKeyProperty("host");
  +        }
  +        return host;
  +
  +    }
  +
   }
  
  
  
  1.4       +22 -5     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/DeleteHostAction.java
  
  Index: DeleteHostAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/DeleteHostAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DeleteHostAction.java	15 Mar 2002 01:16:29 -0000	1.3
  +++ DeleteHostAction.java	3 Feb 2003 22:55:00 -0000	1.4
  @@ -90,6 +90,7 @@
   import org.apache.struts.util.MessageResources;
   
   import org.apache.webapp.admin.ApplicationServlet;
  +import org.apache.webapp.admin.Lists;
   import org.apache.webapp.admin.TomcatTreeBuilder;
   
   /**
  @@ -152,7 +153,23 @@
               throw new ServletException
               ("Cannot acquire MBeanServer reference", t);
           }
  -        
  +
  +        String adminHost = null;
  +        // Get the host name the admin app runs on
  +        // this host cannot be deleted from the admin tool
  +        try {
  +            adminHost = Lists.getAdminAppHost(
  +                                  mBServer, "Catalina" ,request);
  +        } catch (Exception e) {
  +            String message =
  +                resources.getMessage("error.hostName.bad",
  +                                        adminHost);
  +            getServlet().log(message);
  +            response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
  +            return (null);
  +        }
  +        request.setAttribute("adminAppHost", adminHost);
  +         
           String serviceName = request.getParameter("serviceName");
           // Set up a form bean containing the currently selected
           // objects to be deleted
  
  
  
  1.4       +20 -4     jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/EditHostAction.java
  
  Index: EditHostAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/host/EditHostAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EditHostAction.java	9 Sep 2002 19:57:23 -0000	1.3
  +++ EditHostAction.java	3 Feb 2003 22:55:00 -0000	1.4
  @@ -147,6 +147,22 @@
               ("Cannot acquire MBeanServer reference", t);
           }
           
  +        String adminHost = null;
  +        // Get the host name the admin app runs on
  +        // this host cannot be deleted from the admin tool
  +        try {
  +            adminHost = Lists.getAdminAppHost(
  +                                  mBServer, "Catalina" ,request);
  +        } catch (Exception e) {
  +            String message =
  +                resources.getMessage("error.hostName.bad",
  +                                        adminHost);
  +            getServlet().log(message);
  +            response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
  +            return (null);
  +        }
  +        request.setAttribute("adminAppHost", adminHost);
  +                
           // Set up the object names of the MBeans we are manipulating
           ObjectName hname = null;
           StringBuffer sb = null;
  
  
  
  1.22      +1 -1      jakarta-tomcat-4.0/webapps/admin/host/host.jsp
  
  Index: host.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/host/host.jsp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- host.jsp	15 Jan 2003 22:25:19 -0000	1.21
  +++ host.jsp	3 Feb 2003 22:55:00 -0000	1.22
  @@ -78,7 +78,7 @@
                                     URLEncoder.encode(thisObjectName) %>'>
                   <bean:message key="actions.defaultcontexts.deletes"/>
               </controls:action-->            
  -            <logic:notEqual name="hostName" value='<%= request.getServerName() %>'>
  +            <logic:notEqual name="hostName" value='<%= (String)request.getAttribute("adminAppHost")
%>'>
               <controls:action disabled="true">
                   -------------------------------------
               </controls:action>
  
  
  
  1.7       +9 -5      jakarta-tomcat-4.0/webapps/admin/host/hosts.jsp
  
  Index: hosts.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/host/hosts.jsp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- hosts.jsp	15 Jan 2003 22:25:19 -0000	1.6
  +++ hosts.jsp	3 Feb 2003 22:55:00 -0000	1.7
  @@ -57,14 +57,18 @@
           <logic:iterate name="hostsList" id="host">
             <tr class="line-row">
               <td><div align="left" class="table-normal-text">&nbsp;
  -              <logic:match name="host" value='<%= "host="+request.getServerName()+","
%>'>
  -                <font color='red'>*</font>
  -              </logic:match>
  -              <logic:notMatch name="host" value='<%= "host="+request.getServerName()+","
%>'>
  -              <label for="hosts"></label>
  +            
  +             <logic:match name="host"
  +                        value='<%= (String)request.getAttribute("adminAppHost") %>'>
  +             <font color='red'>*</font>
  +             </logic:match>
  +             <logic:notMatch name="host"
  +                        value='<%= (String)request.getAttribute("adminAppHost") %>'>
  +              <label for="hosts"></label>          
                 <html:multibox property="hosts"
                                   value="<%= host.toString() %>" styleId="hosts"/>
                 </logic:notMatch>
  +                         
               </div></td>
               <td><div align="left" class="table-normal-text">&nbsp;
                 <html:link page='<%= "/EditHost.do?select=" +
  
  
  

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


Mime
View raw message