source: trunk/vnc/vnc_javasrc/VNCProxyConnectSocketFactory.java @ 78

Last change on this file since 78 was 66, checked in by quentin, 17 years ago

Initial checkin of modified Java VNC viewer for use as remote console

File size: 2.3 KB
RevLine 
[66]1//
2//  Copyright (C) 2002 Constantin Kaplinsky, Inc.  All Rights Reserved.
3//  Copyright 2007 MIT Student Information Processing Board
4//
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.
9//
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.
14//
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,
18//  USA.
19//
20
21//
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.
25//
26
27import java.applet.*;
28import java.net.*;
29import java.io.*;
30
31class VNCProxyConnectSocketFactory implements SocketFactory {
32
33  public Socket createSocket(String host, int port, Applet applet)
34    throws IOException {
35
36    return createSocket(host, port,
37                        applet.getParameter("VMNAME"),
38                        applet.getParameter("AUTHTOKEN"));
39  }
40
41  public Socket createSocket(String host, int port, String[] args)
42    throws IOException {
43
44    return createSocket(host, port,
45                        readArg(args, "VMNAME"),
46                        readArg(args, "AUTHTOKEN"));
47  }
48
49  public Socket createSocket(String host, int port,
50                             String vmname, String authtoken)
51    throws IOException {
52
53    if (vmname == null || authtoken == null) {
54      System.out.println("Incomplete parameter list for VNCProxyConnectSocket");
55      return new Socket(host, port);
56    }
57
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);
62
63    return (Socket)s;
64  }
65
66  private String readArg(String[] args, String name) {
67
68    for (int i = 0; i < args.length; i += 2) {
69      if (args[i].equalsIgnoreCase(name)) {
70        try {
71          return args[i+1];
72        } catch (Exception e) {
73          return null;
74        }
75      }
76    }
77    return null;
78  }
79}
80
Note: See TracBrowser for help on using the repository browser.