You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2002/04/11 16:16:17 UTC
cvs commit: jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve SaveRemoteAddrValveAction.java SaveRemoteHostValveAction.java SaveSingleSignOnValveAction.java RemoteHostValveForm.java
manveen 02/04/11 07:16:17
Modified: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve
RemoteHostValveForm.java
Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve
SaveRemoteAddrValveAction.java
SaveRemoteHostValveAction.java
SaveSingleSignOnValveAction.java
Log:
Implemented "save" operations for RemoteHostValve, RemoteAddrValve and SingleSIgnOnValve.
Revision Changes Path
1.2 +14 -159 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/RemoteHostValveForm.java
Index: RemoteHostValveForm.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/RemoteHostValveForm.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RemoteHostValveForm.java 10 Apr 2002 00:38:32 -0000 1.1
+++ RemoteHostValveForm.java 11 Apr 2002 14:16:16 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/RemoteHostValveForm.java,v 1.1 2002/04/10 00:38:32 manveen Exp $
- * $Revision: 1.1 $
- * $Date: 2002/04/10 00:38:32 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/RemoteHostValveForm.java,v 1.2 2002/04/11 14:16:16 manveen Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/04/11 14:16:16 $
*
* ====================================================================
*
@@ -76,22 +76,12 @@
* Form bean for the remote host valve page.
*
* @author Manveen Kaur
- * @version $Revision: 1.1 $ $Date: 2002/04/10 00:38:32 $
+ * @version $Revision: 1.2 $ $Date: 2002/04/11 14:16:16 $
*/
-public final class RemoteHostValveForm extends ActionForm {
+public final class RemoteHostValveForm extends ValveForm {
// ----------------------------------------------------- Instance Variables
-
- /**
- * The administrative action represented by this form.
- */
- private String adminAction = "Edit";
-
- /**
- * The object name of the valve this bean refers to.
- */
- private String objectName = null;
/**
* The text for the allow hosts IP addresses.
@@ -105,88 +95,8 @@
*/
private String deny = "";
- /**
- * The text for the valve name, used to retrieve
- * the corresponding valve mBean.
- */
- private String valveName = null;
-
- /**
- * The text for the valve type.
- */
- private String valveType = null;
-
- /**
- * The text for the node label.
- */
- private String nodeLabel = null;
-
- /**
- * The object name of the parent of this valve.
- */
- private String parentObjectName = null;
-
- /**
- * Set of valid values for valves.
- */
- private List valveTypeVals = null;
-
// ------------------------------------------------------------- Properties
- /**
- * Return the administrative action represented by this form.
- */
- public String getAdminAction() {
-
- return this.adminAction;
-
- }
-
- /**
- * Set the administrative action represented by this form.
- */
- public void setAdminAction(String adminAction) {
-
- this.adminAction = adminAction;
-
- }
-
- /**
- * Return the Object Name.
- */
- public String getObjectName() {
-
- return this.objectName;
-
- }
-
- /**
- * Set the Object Name.
- */
- public void setObjectName(String objectName) {
-
- this.objectName = objectName;
-
- }
-
- /**
- * Return the valve type.
- */
- public String getValveType() {
-
- return this.valveType;
-
- }
-
- /**
- * Set the valve type.
- */
- public void setValveType(String valveType) {
-
- this.valveType = valveType;
-
- }
-
/**
* Return the allow hosts IP adddresses.
*/
@@ -223,62 +133,6 @@
}
- /**
- * Return the label of the node that was clicked.
- */
- public String getNodeLabel() {
-
- return this.nodeLabel;
-
- }
-
- /**
- * Set the node label.
- */
- public void setNodeLabel(String nodeLabel) {
-
- this.nodeLabel = nodeLabel;
-
- }
-
- /**
- * Return the parent object name of the valve this bean refers to.
- */
- public String getParentObjectName() {
-
- return this.parentObjectName;
-
- }
-
-
- /**
- * Set the parent object name of the valve this bean refers to.
- */
- public void setParentObjectName(String parentObjectName) {
-
- this.parentObjectName = parentObjectName;
-
- }
-
-
- /**
- * Return the valveTypeVals.
- */
- public List getValveTypeVals() {
-
- return this.valveTypeVals;
-
- }
-
- /**
- * Set the valveTypeVals.
- */
- public void setValveTypeVals(List valveTypeVals) {
-
- this.valveTypeVals = valveTypeVals;
-
- }
-
// --------------------------------------------------------- Public Methods
/**
@@ -288,8 +142,8 @@
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
-
- this.objectName = null;
+
+ super.reset(mapping, request);
this.allow = null;
this.deny = null;
@@ -301,15 +155,15 @@
public String toString() {
StringBuffer sb = new StringBuffer("RemoteHostValveForm[adminAction=");
- sb.append(adminAction);
+ sb.append(getAdminAction());
sb.append("',valveType=");
- sb.append(valveType);
+ sb.append(getValveType());
sb.append(",allow=");
sb.append(allow);
sb.append(",deny=");
sb.append(deny);
sb.append("',objectName='");
- sb.append(objectName);
+ sb.append(getObjectName());
sb.append("]");
return (sb.toString());
@@ -335,9 +189,10 @@
// front end validation when save is clicked.
if (submit != null) {
- // validate allow/deny patterns?
- }
-
+ // TBD
+ // validate allow/deny IPs
+ }
return errors;
}
+
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/SaveRemoteAddrValveAction.java
Index: SaveRemoteAddrValveAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/SaveRemoteAddrValveAction.java,v 1.1 2002/04/11 14:16:16 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/04/11 14:16:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-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", "Struts", 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.valve;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Locale;
import java.io.IOException;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.QueryExp;
import javax.management.Query;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.JMException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.webapp.admin.ApplicationServlet;
import org.apache.webapp.admin.TomcatTreeBuilder;
import org.apache.webapp.admin.TreeControl;
import org.apache.webapp.admin.TreeControlNode;
import org.apache.webapp.admin.logger.DeleteLoggerAction;
/**
* The <code>Action</code> that completes <em>Add Valve</em> and
* <em>Edit Valve</em> transactions for Remote Addr valve.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/04/11 14:16:16 $
*/
public final class SaveRemoteAddrValveAction extends Action {
// ----------------------------------------------------- Instance Variables
/**
* The MBeanServer we will be interacting with.
*/
private MBeanServer mBServer = null;
/**
* The MessageResources we will be retrieving messages from.
*/
private MessageResources resources = null;
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Acquire the resources that we need
HttpSession session = request.getSession();
Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
if (resources == null) {
resources = getServlet().getResources();
}
// Acquire a reference to the MBeanServer containing our MBeans
try {
mBServer = ((ApplicationServlet) getServlet()).getServer();
} catch (Throwable t) {
throw new ServletException
("Cannot acquire MBeanServer reference", t);
}
// Identify the requested action
RemoteAddrValveForm vform = (RemoteAddrValveForm) form;
String adminAction = vform.getAdminAction();
String vObjectName = vform.getObjectName();
String parent = vform.getObjectName();
String valveType = vform.getValveType();
// Perform a "Create Valve" transaction (if requested)
if ("Create".equals(adminAction)) {
return ValveUtil.
createValve(parent, valveType, response, request, mapping,
(ApplicationServlet) getServlet());
}
// Perform attribute updates as requested
String attribute = null;
try {
ObjectName voname = new ObjectName(vObjectName);
attribute = "allow";
mBServer.setAttribute(voname,
new Attribute("allow", vform.getAllow()));
attribute = "deny";
mBServer.setAttribute(voname,
new Attribute("deny", vform.getDeny()));
} catch (Exception e) {
getServlet().log
(resources.getMessage(locale, "users.error.attribute.set",
attribute), e);
response.sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
resources.getMessage(locale, "users.error.attribute.set",
attribute));
return (null);
}
// Forward to the success reporting page
session.removeAttribute(mapping.getAttribute());
return (mapping.findForward("Save Successful"));
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/SaveRemoteHostValveAction.java
Index: SaveRemoteHostValveAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/SaveRemoteHostValveAction.java,v 1.1 2002/04/11 14:16:16 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/04/11 14:16:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-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", "Struts", 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.valve;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Locale;
import java.io.IOException;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.QueryExp;
import javax.management.Query;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.JMException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.webapp.admin.ApplicationServlet;
import org.apache.webapp.admin.TomcatTreeBuilder;
import org.apache.webapp.admin.TreeControl;
import org.apache.webapp.admin.TreeControlNode;
import org.apache.webapp.admin.logger.DeleteLoggerAction;
/**
* The <code>Action</code> that completes <em>Add Valve</em> and
* <em>Edit Valve</em> transactions for Remote Host valve.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/04/11 14:16:16 $
*/
public final class SaveRemoteHostValveAction extends Action {
// ----------------------------------------------------- Instance Variables
/**
* The MBeanServer we will be interacting with.
*/
private MBeanServer mBServer = null;
/**
* The MessageResources we will be retrieving messages from.
*/
private MessageResources resources = null;
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Acquire the resources that we need
HttpSession session = request.getSession();
Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
if (resources == null) {
resources = getServlet().getResources();
}
// Acquire a reference to the MBeanServer containing our MBeans
try {
mBServer = ((ApplicationServlet) getServlet()).getServer();
} catch (Throwable t) {
throw new ServletException
("Cannot acquire MBeanServer reference", t);
}
// Identify the requested action
RemoteHostValveForm vform = (RemoteHostValveForm) form;
String adminAction = vform.getAdminAction();
String vObjectName = vform.getObjectName();
String parent = vform.getObjectName();
String valveType = vform.getValveType();
// Perform a "Create Valve" transaction (if requested)
if ("Create".equals(adminAction)) {
return ValveUtil.
createValve(parent, valveType, response, request, mapping,
(ApplicationServlet) getServlet());
}
// Perform attribute updates as requested
String attribute = null;
try {
ObjectName voname = new ObjectName(vObjectName);
attribute = "allow";
mBServer.setAttribute(voname,
new Attribute("allow", vform.getAllow()));
attribute = "deny";
mBServer.setAttribute(voname,
new Attribute("deny", vform.getDeny()));
} catch (Exception e) {
getServlet().log
(resources.getMessage(locale, "users.error.attribute.set",
attribute), e);
response.sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
resources.getMessage(locale, "users.error.attribute.set",
attribute));
return (null);
}
// Forward to the success reporting page
session.removeAttribute(mapping.getAttribute());
return (mapping.findForward("Save Successful"));
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/SaveSingleSignOnValveAction.java
Index: SaveSingleSignOnValveAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/valve/SaveSingleSignOnValveAction.java,v 1.1 2002/04/11 14:16:16 manveen Exp $
* $Revision: 1.1 $
* $Date: 2002/04/11 14:16:16 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-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", "Struts", 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.valve;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Locale;
import java.io.IOException;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.QueryExp;
import javax.management.Query;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.JMException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import org.apache.webapp.admin.ApplicationServlet;
import org.apache.webapp.admin.TomcatTreeBuilder;
import org.apache.webapp.admin.TreeControl;
import org.apache.webapp.admin.TreeControlNode;
import org.apache.webapp.admin.logger.DeleteLoggerAction;
/**
* The <code>Action</code> that completes <em>Add Valve</em> and
* <em>Edit Valve</em> transactions for Single Sign On valve.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2002/04/11 14:16:16 $
*/
public final class SaveSingleSignOnValveAction extends Action {
// ----------------------------------------------------- Instance Variables
/**
* The MBeanServer we will be interacting with.
*/
private MBeanServer mBServer = null;
/**
* The MessageResources we will be retrieving messages from.
*/
private MessageResources resources = null;
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Acquire the resources that we need
HttpSession session = request.getSession();
Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
if (resources == null) {
resources = getServlet().getResources();
}
// Acquire a reference to the MBeanServer containing our MBeans
try {
mBServer = ((ApplicationServlet) getServlet()).getServer();
} catch (Throwable t) {
throw new ServletException
("Cannot acquire MBeanServer reference", t);
}
// Identify the requested action
SingleSignOnValveForm vform = (SingleSignOnValveForm) form;
String adminAction = vform.getAdminAction();
String vObjectName = vform.getObjectName();
String parent = vform.getObjectName();
String valveType = vform.getValveType();
// Perform a "Create Valve" transaction (if requested)
if ("Create".equals(adminAction)) {
return ValveUtil.
createValve(parent, valveType, response, request, mapping,
(ApplicationServlet) getServlet());
}
// Perform attribute updates as requested
String attribute = null;
try {
ObjectName voname = new ObjectName(vObjectName);
attribute = "debug";
int debug = 0;
try {
debug = Integer.parseInt(vform.getDebugLvl());
} catch (Throwable t) {
debug = 0;
}
mBServer.setAttribute(voname,
new Attribute("debug", new Integer(debug)));
} catch (Exception e) {
getServlet().log
(resources.getMessage(locale, "users.error.attribute.set",
attribute), e);
response.sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
resources.getMessage(locale, "users.error.attribute.set",
attribute));
return (null);
}
// Forward to the success reporting page
session.removeAttribute(mapping.getAttribute());
return (mapping.findForward("Save Successful"));
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>