2 // Copyright (C) 2002 Constantin Kaplinsky, Inc. All Rights Reserved.
3 // Copyright 2007 MIT Student Information Processing Board
5 // This is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This software is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this software; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // VNCProxyConnectSocketFactory.java together with VNCProxyConnectSocket.java
23 // implement an alternate way to connect to VNC servers via one or two
24 // VNCProxy proxies supporting the VNCProxy CONNECT method.
31 class VNCProxyConnectSocketFactory implements SocketFactory {
33 public Socket createSocket(String host, int port, Applet applet)
36 return createSocket(host, port,
37 applet.getParameter("VMNAME"),
38 applet.getParameter("AUTHTOKEN"));
41 public Socket createSocket(String host, int port, String[] args)
44 return createSocket(host, port,
45 readArg(args, "VMNAME"),
46 readArg(args, "AUTHTOKEN"));
49 public Socket createSocket(String host, int port,
50 String vmname, String authtoken)
53 if (vmname == null || authtoken == null) {
54 System.out.println("Incomplete parameter list for VNCProxyConnectSocket");
55 return new Socket(host, port);
58 System.out.println("VNCProxy CONNECT via proxy " + host +
59 " port " + port + " to vm " + vmname);
60 VNCProxyConnectSocket s =
61 new VNCProxyConnectSocket(host, port, vmname, authtoken);
66 private String readArg(String[] args, String name) {
68 for (int i = 0; i < args.length; i += 2) {
69 if (args[i].equalsIgnoreCase(name)) {
72 } catch (Exception e) {