EditServiceSecurityAction.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: EditServiceSecurityAction.java,v 1.7 2004/10/22 13:53:33 danesa Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.service;
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 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00045 import org.objectweb.jonas.webapp.jonasadmin.security.RealmItem;
00046 import org.objectweb.jonas.webapp.jonasadmin.security.RealmItemByNameComparator;
00047 
00052 public class EditServiceSecurityAction extends JonasBaseAction {
00053 
00054 // --------------------------------------------------------- Public Methods
00055 
00056     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00057         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00058         throws IOException, ServletException {
00059 
00060         // Force the node selected in tree
00061         m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
00062             + "services" + WhereAreYou.NODE_SEPARATOR + "security", true);
00063         try {
00064             ArrayList al = new ArrayList();
00065             // Catalina
00066             if (m_WhereAreYou.isCatalinaServer() == true) {
00067                 try {
00068                     ObjectName on;
00069                     // Find used realm name
00070                     on = CatalinaObjectName.catalinaRealm(m_WhereAreYou.
00071                         getCurrentCatalinaDomainName());
00072                     String sUsedRealmName = getStringAttribute(on, "resourceName");
00073                     // Find all realms
00074                     String sRealmName;
00075                     String sRealmType;
00076                     String sPathContext = null;
00077                     Iterator it = JonasAdminJmx.getListMbean(CatalinaObjectName.catalinaRealms()).
00078                         iterator();
00079                     while (it.hasNext() == true) {
00080                         on = (ObjectName) it.next();
00081                         sRealmName = getStringAttribute(on, "resourceName");
00082                         sRealmType = JonasAdminJmx.findSecurityFactorySubType(sRealmName);
00083                         try {
00084                                 sPathContext = on.getKeyProperty("path");
00085                         } catch (NullPointerException e) {
00086                                 // Not possible as "path" is not null
00087                         }
00088                         if (sPathContext != null) {
00089                                 al.add(new RealmItem(sRealmName, sRealmType, sPathContext
00090                             , sRealmName.equals(sUsedRealmName)));
00091                         }
00092                     }
00093                     // Sort
00094                     Collections.sort(al, new RealmItemByNameComparator());
00095                 }
00096                 catch (Exception e) {
00097                     // no action
00098                     // Exception because catalina realm don't exists
00099                 }
00100             }
00101             // Set form in the request
00102             p_Request.setAttribute("listSecurityRealms", al);
00103         }
00104         catch (Throwable t) {
00105             addGlobalError(t);
00106             saveErrors(p_Request, m_Errors);
00107             return (p_Mapping.findForward("Global Error"));
00108         }
00109         // Forward to the jsp.
00110         return (p_Mapping.findForward("Service Security"));
00111     }
00112 }

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