annotate src/myVncProxy/HTTPConnectSocketFactory.java @ 191:b2f0cd0cff6c default tip

Added tag Version-1.0 for changeset 79046b4e5990
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Nov 2011 15:52:44 +0900
parents 87b29d6039a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
87b29d6039a6 add package myVncProxy
e085711
parents: 0
diff changeset
1 package myVncProxy;
0
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
2 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
3 // Copyright (C) 2002 Constantin Kaplinsky, Inc. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
4 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
5 // This is free software; you can redistribute it and/or modify
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
6 // it under the terms of the GNU General Public License as published by
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
7 // the Free Software Foundation; either version 2 of the License, or
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
8 // (at your option) any later version.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
9 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
10 // This software is distributed in the hope that it will be useful,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
13 // GNU General Public License for more details.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
14 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
15 // You should have received a copy of the GNU General Public License
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
16 // along with this software; if not, write to the Free Software
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
18 // USA.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
19 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
20
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
21 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
22 // HTTPConnectSocketFactory.java together with HTTPConnectSocket.java
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
23 // implement an alternate way to connect to VNC servers via one or two
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24 // HTTP proxies supporting the HTTP CONNECT method.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27 import java.applet.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28 import java.net.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29 import java.io.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31 class HTTPConnectSocketFactory implements SocketFactory {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33 public Socket createSocket(String host, int port, Applet applet)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 throws IOException {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36 return createSocket(host, port,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37 applet.getParameter("PROXYHOST1"),
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38 applet.getParameter("PROXYPORT1"));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41 public Socket createSocket(String host, int port, String[] args)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42 throws IOException {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44 return createSocket(host, port,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45 readArg(args, "PROXYHOST1"),
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46 readArg(args, "PROXYPORT1"));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49 public Socket createSocket(String host, int port,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 String proxyHost, String proxyPortStr)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51 throws IOException {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 int proxyPort = 0;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54 if (proxyPortStr != null) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56 proxyPort = Integer.parseInt(proxyPortStr);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 } catch (NumberFormatException e) { }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 if (proxyHost == null || proxyPort == 0) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61 System.out.println("Incomplete parameter list for HTTPConnectSocket");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62 return new Socket(host, port);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 System.out.println("HTTP CONNECT via proxy " + proxyHost +
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66 " port " + proxyPort);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67 HTTPConnectSocket s =
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 new HTTPConnectSocket(host, port, proxyHost, proxyPort);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 return (Socket)s;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73 private String readArg(String[] args, String name) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75 for (int i = 0; i < args.length; i += 2) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 if (args[i].equalsIgnoreCase(name)) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
77 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
78 return args[i+1];
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
79 } catch (Exception e) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80 return null;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84 return null;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87