EditSecurityCatalinaRealmAction.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: EditSecurityCatalinaRealmAction.java,v 1.4 2004/10/22 13:53:33 danesa Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.security;
00027 
00028 import java.io.IOException;
00029 import java.util.ArrayList;
00030 import java.util.Collections;
00031 import java.util.Iterator;
00032 
00033 import javax.management.ObjectName;
00034 import javax.servlet.ServletException;
00035 import javax.servlet.http.HttpServletRequest;
00036 import javax.servlet.http.HttpServletResponse;
00037 
00038 import org.apache.struts.action.ActionForm;
00039 import org.apache.struts.action.ActionForward;
00040 import org.apache.struts.action.ActionMapping;
00041 import org.objectweb.jonas.jmx.CatalinaObjectName;
00042 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
00043 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
00044 
00049 public class EditSecurityCatalinaRealmAction extends JonasBaseAction {
00050 
00051 // --------------------------------------------------------- Public Methods
00052 
00053     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00054         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00055         throws IOException, ServletException {
00056 
00057         try {
00058             ArrayList al = new ArrayList();
00059             // Catalina
00060             if (m_WhereAreYou.isCatalinaServer() == true) {
00061                 try {
00062                     ObjectName on;
00063                     // Find used realm name
00064                     on = CatalinaObjectName.catalinaRealm(m_WhereAreYou.getCurrentCatalinaServiceName());
00065                     String sUsedRealmName = getStringAttribute(on, "resourceName");
00066                     // Find all realms
00067                     String sRealmName;
00068                     String sRealmType;
00069                     Iterator it = JonasAdminJmx.getListMbean(CatalinaObjectName.catalinaRealms()).
00070                         iterator();
00071                     while (it.hasNext() == true) {
00072                         on = (ObjectName) it.next();
00073                         sRealmName = getStringAttribute(on, "resourceName");
00074                         al.add(new RealmItem(sRealmName, null, sRealmName.equals(sUsedRealmName)));
00075                     }
00076                     // Sort
00077                     Collections.sort(al, new RealmItemByNameComparator());
00078                 }
00079                 catch (Exception e) {
00080                     // no action
00081                     // Exception because catalina realm don't exists
00082                 }
00083             }
00084             // Set form in the request
00085             p_Request.setAttribute("listSecurityRealms", al);
00086         }
00087         catch (Throwable t) {
00088             addGlobalError(t);
00089             saveErrors(p_Request, m_Errors);
00090             return (p_Mapping.findForward("Global Error"));
00091         }
00092         // Forward to the jsp.
00093         return (p_Mapping.findForward("Security Catalina Realm"));
00094     }
00095 }

Generated on Tue Feb 15 15:05:30 2005 for JOnAS by  doxygen 1.3.9.1