1 19 20 package com.sslexplorer.agent.client.launcher; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 import java.lang.reflect.Method ; 26 import java.net.URL ; 27 import java.net.URLConnection ; 28 import java.net.URLEncoder ; 29 import java.text.MessageFormat ; 30 import java.util.Enumeration ; 31 import java.util.Hashtable ; 32 33 import com.sslexplorer.agent.client.util.AbstractApplicationLauncher; 34 import com.sslexplorer.agent.client.util.ApplicationLauncherEvents; 35 36 public class AgentLauncherApplicationLauncher extends AbstractApplicationLauncher { 37 38 39 50 public AgentLauncherApplicationLauncher(File cacheDir, String applicationStoreProtocol, String applicationStoreUser, String applicationStoreHost, int applicationStorePort, Hashtable parameters, ApplicationLauncherEvents events) { 51 super(cacheDir, applicationStoreProtocol, applicationStoreUser, applicationStoreHost, applicationStorePort, parameters, events); 52 } 53 54 61 protected InputStream getApplicationDescriptor() throws IOException { 62 StringBuffer parms = new StringBuffer (); 63 Enumeration en = parameters.keys(); 64 while(en.hasMoreElements()) { 65 if(parms.length() == 0) { 66 parms.append("?"); } 68 else { 69 parms.append("&"); } 71 String key = (String ) en.nextElement(); 72 parms.append(key); 73 parms.append("="); parms.append(URLEncoder.encode((String ) parameters.get(key))); 75 } 76 77 URL file = new URL (applicationStoreProtocol, applicationStoreHost, applicationStorePort, "/getExtensionDescriptor.do" + parms); 79 if (events != null) 80 events.debug(MessageFormat.format(Messages.getString("VPNLauncher.requestApplicationUsing"), new Object [] { file.toExternalForm() })); 82 URLConnection con = (URLConnection )file.openConnection(); 83 con.setUseCaches(false); 84 85 try { 86 Method m = con.getClass().getMethod("setConnectTimeout", new Class [] { int.class }); if (events != null) { 88 events.debug(Messages.getString("VPNLauncher.runtime5")); } 90 m.invoke(con, new Object [] { new Integer (20000) }); 91 m = con.getClass().getMethod("setReadTimeout", new Class [] { int.class }); m.invoke(con, new Object [] { new Integer (20000) }); 93 } catch (Throwable t) { 94 } 95 return con.getInputStream(); 96 } 97 } 98 | Popular Tags |