1 25 26 package org.objectweb.jonas.webapp.jonasadmin.security; 27 28 import java.io.IOException ; 29 30 import javax.management.ObjectName ; 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionForward; 37 import org.apache.struts.action.ActionMapping; 38 import org.objectweb.jonas.jmx.JonasObjectName; 39 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 40 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 41 42 45 public class EditDatasourceRealmAction extends JonasBaseAction { 46 47 49 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 50 , HttpServletRequest p_Request, HttpServletResponse p_Response) 51 throws IOException , ServletException { 52 53 String sResource = p_Request.getParameter("resource"); 54 String sAction = p_Request.getParameter("action"); 55 56 DatasourceRealmForm oForm = null; 58 if (sResource != null) { 59 oForm = new DatasourceRealmForm(); 61 m_Session.setAttribute("datasourceRealmForm", oForm); 62 oForm.setResource(sResource); 63 oForm.setAction("apply"); 64 } 65 else { 66 if ((sAction != null) && (sAction.equals("create") == true)) { 68 oForm = new DatasourceRealmForm(); 69 m_Session.setAttribute("datasourceRealmForm", oForm); 70 oForm.setAction("create"); 71 } 72 else { 74 oForm = (DatasourceRealmForm) m_Session.getAttribute("datasourceRealmForm"); 75 oForm.reset(p_Mapping, p_Request); 76 } 77 } 78 79 try { 81 if (oForm.getAction().equals("apply") == true) { 83 ObjectName oObjectName = JonasObjectName.securityDatasourceFactory(oForm. 84 getResource()); 85 oForm.setDsName(getStringAttribute(oObjectName, "DsName")); 86 oForm.setName(getStringAttribute(oObjectName, "Name")); 87 oForm.setRoleTable(getStringAttribute(oObjectName, "RoleTable")); 88 oForm.setRoleTableRolenameCol(getStringAttribute(oObjectName 89 , "RoleTableRolenameCol")); 90 oForm.setRoleTableUsernameCol(getStringAttribute(oObjectName 91 , "RoleTableUsernameCol")); 92 oForm.setUserTable(getStringAttribute(oObjectName, "UserTable")); 93 oForm.setUserTablePasswordCol(getStringAttribute(oObjectName 94 , "UserTablePasswordCol")); 95 oForm.setUserTableUsernameCol(getStringAttribute(oObjectName 96 , "UserTableUsernameCol")); 97 oForm.setAlgorithm(getStringAttribute(oObjectName, "Algorithm")); 98 99 m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) 101 + WhereAreYou.NODE_SEPARATOR + "security" + WhereAreYou.NODE_SEPARATOR 102 + "factory.datasource" + WhereAreYou.NODE_SEPARATOR + oForm.getName(), true); 103 } 104 } 105 catch (Throwable t) { 106 addGlobalError(t); 107 saveErrors(p_Request, m_Errors); 108 return (p_Mapping.findForward("Global Error")); 109 } 110 return (p_Mapping.findForward("Datasource Realm")); 112 } 113 114 116 } 117 | Popular Tags |