1 19 20 package com.sslexplorer.extensions.actions; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.struts.action.ActionForm; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 31 import com.sslexplorer.core.CoreUtil; 32 import com.sslexplorer.core.actions.AuthenticatedAction; 33 import com.sslexplorer.extensions.ExtensionDescriptor; 34 import com.sslexplorer.policyframework.LaunchSession; 35 import com.sslexplorer.policyframework.LaunchSessionFactory; 36 import com.sslexplorer.security.Constants; 37 import com.sslexplorer.security.LogonControllerFactory; 38 import com.sslexplorer.security.SessionInfo; 39 40 48 49 public abstract class AbstractLaunchViaAppletAction extends AuthenticatedAction { 50 51 final static Log log = LogFactory.getLog(AbstractLaunchViaAppletAction.class); 52 53 61 protected ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, 62 HttpServletResponse response) throws Exception { 63 ExtensionDescriptor desc = getExtensionDescriptor(mapping, form, request, response); 64 if(desc == null) { 65 throw new Exception ("No application extension."); 66 } 67 SessionInfo session = LogonControllerFactory.getInstance().getSessionInfo(request); 68 String ref = request.getParameter("returnTo"); 69 if (ref == null) { 70 ref = CoreUtil.getReferer(request); 71 ref = ref == null ? "/showHome.do" : ref; 72 } 73 LaunchSession launchSession = LaunchSessionFactory.getInstance().createLaunchSession(session, null, null); 74 launchSession.setAttribute(Constants.LAUNCH_ATTR_AGENT_RETURN_TO, ref); 75 launchSession.setAttribute(Constants.LAUNCH_ATTR_AGENT_EXTENSION, desc); 76 request.setAttribute(Constants.REQ_ATTR_LAUNCH_SESSION, launchSession); 77 postSetup(mapping, form, request, response, launchSession); 78 return mapping.findForward("launchViaAgentApplet"); 79 } 80 81 90 protected abstract void postSetup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, LaunchSession launchSession); 91 92 104 protected abstract ExtensionDescriptor getExtensionDescriptor(ActionMapping mapping, ActionForm form, HttpServletRequest request, 105 HttpServletResponse response) throws Exception ; 106 107 } | Popular Tags |