1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service; 27 28 import java.io.IOException ; 29 import java.util.ArrayList ; 30 import java.util.Collections ; 31 import java.util.Iterator ; 32 33 import javax.management.ObjectName ; 34 import javax.servlet.ServletException ; 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletResponse ; 37 38 import org.apache.struts.action.ActionForm; 39 import org.apache.struts.action.ActionForward; 40 import org.apache.struts.action.ActionMapping; 41 import org.objectweb.jonas.jmx.CatalinaObjectName; 42 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 43 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 44 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 45 import org.objectweb.jonas.webapp.jonasadmin.security.RealmItem; 46 import org.objectweb.jonas.webapp.jonasadmin.security.RealmItemByNameComparator; 47 48 51 52 public class EditServiceSecurityAction extends JonasBaseAction { 53 54 56 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 57 , HttpServletRequest p_Request, HttpServletResponse p_Response) 58 throws IOException , ServletException { 59 60 m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR 62 + "services" + WhereAreYou.NODE_SEPARATOR + "security", true); 63 try { 64 ArrayList al = new ArrayList (); 65 if (m_WhereAreYou.isCatalinaServer() == true) { 67 try { 68 ObjectName on; 69 on = CatalinaObjectName.catalinaRealm(m_WhereAreYou. 71 getCurrentCatalinaDomainName()); 72 String sUsedRealmName = getStringAttribute(on, "resourceName"); 73 String sRealmName; 75 String sRealmType; 76 String sPathContext = null; 77 Iterator it = JonasAdminJmx.getListMbean(CatalinaObjectName.catalinaRealms()). 78 iterator(); 79 while (it.hasNext() == true) { 80 on = (ObjectName ) it.next(); 81 sRealmName = getStringAttribute(on, "resourceName"); 82 sRealmType = JonasAdminJmx.findSecurityFactorySubType(sRealmName); 83 try { 84 sPathContext = on.getKeyProperty("path"); 85 } catch (NullPointerException e) { 86 } 88 if (sPathContext != null) { 89 al.add(new RealmItem(sRealmName, sRealmType, sPathContext 90 , sRealmName.equals(sUsedRealmName))); 91 } 92 } 93 Collections.sort(al, new RealmItemByNameComparator()); 95 } 96 catch (Exception e) { 97 } 100 } 101 p_Request.setAttribute("listSecurityRealms", al); 103 } 104 catch (Throwable t) { 105 addGlobalError(t); 106 saveErrors(p_Request, m_Errors); 107 return (p_Mapping.findForward("Global Error")); 108 } 109 return (p_Mapping.findForward("Service Security")); 111 } 112 } 113 | Popular Tags |