00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00055
00056 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00057 , HttpServletRequest p_Request, HttpServletResponse p_Response)
00058 throws IOException, ServletException {
00059
00060
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
00066 if (m_WhereAreYou.isCatalinaServer() == true) {
00067 try {
00068 ObjectName on;
00069
00070 on = CatalinaObjectName.catalinaRealm(m_WhereAreYou.
00071 getCurrentCatalinaDomainName());
00072 String sUsedRealmName = getStringAttribute(on, "resourceName");
00073
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
00087 }
00088 if (sPathContext != null) {
00089 al.add(new RealmItem(sRealmName, sRealmType, sPathContext
00090 , sRealmName.equals(sUsedRealmName)));
00091 }
00092 }
00093
00094 Collections.sort(al, new RealmItemByNameComparator());
00095 }
00096 catch (Exception e) {
00097
00098
00099 }
00100 }
00101
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
00110 return (p_Mapping.findForward("Service Security"));
00111 }
00112 }