protected void createTunnel(XMLElement e) throws IOException { String hostname = (String) e.getAttribute("hostname"); // $NON-NLS-1$ String name = (String) e.getAttribute("name"); // $NON-NLS-1$ int port = Integer.parseInt((String) e.getAttribute("port")); // $NON-NLS-1$ boolean usePreferredPort = ("true".equals(e.getAttribute("usePreferredPort"))); // $NON-NLS-1$ //$NON-NLS-2$ boolean singleConnection = !("false".equals(e.getAttribute("singleConnection"))); // $NON-NLS-1$ //$NON-NLS-2$ boolean localhostWorkaround = "true".equals(e.getAttribute("localhostWorkaround")); // $NON-NLS-1$ //$NON-NLS-2$ if (events != null) { TunnelConfiguration listeningSocketConfiguration = events.createTunnel( name, hostname, port, usePreferredPort, singleConnection, localhostWorkaround ? "127.0.0.2" : agent.getConfiguration().getLocalhostAddress()); tunnels.addElement(listeningSocketConfiguration); } else throw new IOException( Messages.getString("ApplicationLauncher.tunnelRequiredButNoEventHandler")); // $NON-NLS-1$ }
/** * Constructor. * * @param vpn agent * @param parameters parameters * @param events events callback */ public AgentApplicationLauncher( Agent vpn, String name, Hashtable parameters, String descriptor, ApplicationLauncherEvents events) { super( vpn.getConfiguration().getCacheDir(), "https", vpn.getUsername(), vpn.getAditoHost(), vpn.getAditoPort(), parameters, events); this.agent = vpn; this.name = name; this.descriptor = descriptor; }
/** * Get download file. * * @param name name * @param ticket ticket * @param filename filename * @return stream * @throws IOException on any error */ public InputStream getDownloadFile(String name, String ticket, String filename) throws IOException { if (events != null) events.debug("Downloading application file " + filename); try { ApplicationFileChannel channel = new ApplicationFileChannel(name, ticket, filename); agent.getConnection().openChannel(channel); return channel.getInputStream(); } catch (ChannelOpenException e) { throw new IOException(e.getMessage()); } }