1 19 20 package com.sslexplorer.applications.types; 21 22 import java.util.Map ; 23 24 import javax.servlet.http.HttpServletRequest ; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 31 import com.maverick.multiplex.Request; 32 import com.sslexplorer.agent.AgentTunnel; 33 import com.sslexplorer.agent.DefaultAgentManager; 34 import com.sslexplorer.applications.ApplicationLauncherType; 35 import com.sslexplorer.applications.ApplicationService; 36 import com.sslexplorer.applications.ApplicationShortcut; 37 import com.sslexplorer.extensions.ExtensionDescriptor; 38 import com.sslexplorer.extensions.ExtensionException; 39 import com.sslexplorer.extensions.types.AbstractJavaType; 40 import com.sslexplorer.policyframework.LaunchSession; 41 import com.sslexplorer.security.SessionInfo; 42 43 50 public class JavaType extends AbstractJavaType implements ApplicationLauncherType { 51 52 53 static Log log = LogFactory.getLog(JavaType.class); 54 55 58 public final static String TYPE = "java"; 59 60 63 public JavaType() { 64 super(TYPE, true); 65 } 66 67 70 public boolean isHidden() { 71 return false; 72 } 73 74 77 public boolean isAgentRequired(ApplicationShortcut shortcut, ExtensionDescriptor descriptor) { 78 return true; 79 } 80 81 84 public ActionForward launch(Map <String , String > parameters, ExtensionDescriptor descriptor, ApplicationShortcut shortcut, ActionMapping mapping, LaunchSession launchSession, String returnTo, HttpServletRequest request) throws ExtensionException { 85 if (log.isInfoEnabled()) 86 log.info("Launching client application " + shortcut.getResourceName()); 87 88 SessionInfo session = launchSession.getSession(); 89 if (DefaultAgentManager.getInstance().hasActiveAgent(session)) { 90 try { 91 Request agentRequest = ((ApplicationService) DefaultAgentManager.getInstance().getService(ApplicationService.class)).launchApplication(launchSession); 92 AgentTunnel agent = DefaultAgentManager.getInstance().getAgentBySession(launchSession.getSession()); 93 if (!agent.sendRequest(agentRequest, true, 60000)) { 94 throw new ExtensionException(ExtensionException.AGENT_REFUSED_LAUNCH); 95 } 96 } catch (ExtensionException ee) { 97 throw ee; 98 } catch (Exception e) { 99 throw new ExtensionException(ExtensionException.INTERNAL_ERROR, e); 100 } 101 } 102 else { 103 throw new ExtensionException(ExtensionException.NO_AGENT); 104 } 105 return null; 106 } 107 108 111 public String getTypeBundle() { 112 return "applications"; 113 } 114 115 118 public boolean isServerSide() { 119 return false; 120 } 121 } | Popular Tags |