blob: 2461682d7402581d3dab7d786870245f7946ee8b [file] [log] [blame]
DRCc5dc0382011-05-13 21:42:14 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19package com.tigervnc.rfb;
20
21import java.io.IOException;
22
23import com.tigervnc.rdr.*;
24import com.tigervnc.vncviewer.*;
25
26public class CSecurityManaged extends CSecurity {
27
28 public CSecurityManaged() { }
29
30 public boolean processMsg(CConnection cc) {
31 InStream is = cc.getInStream();
32 OutStream os = cc.getOutStream();
33
34 StringBuffer username = new StringBuffer();
35
36 CConn.upg.getUserPasswd(username, null);
37
38 // Return the response to the server
39 os.writeU8(username.length());
Brian Hinz17fca552011-05-17 03:06:24 +000040 try {
41 byte[] utf8str = username.toString().getBytes("UTF8");
42 os.writeBytes(utf8str, 0, username.length());
43 } catch(java.io.UnsupportedEncodingException e) {
44 e.printStackTrace();
45 }
DRCc5dc0382011-05-13 21:42:14 +000046 os.flush();
47 int serverPort = is.readU16();
48 //if (serverPort==0) { return true; };
49 String serverName = cc.getServerName();
50 vlog.debug("Redirected to "+serverName+" port "+serverPort);
51 try {
52 CConn.getSocket().close();
53 cc.setServerPort(serverPort);
54 sock = new java.net.Socket(serverName, serverPort);
55 sock.setTcpNoDelay(true);
56 sock.setTrafficClass(0x10);
57 CConn.setSocket(sock);
58 vlog.debug("connected to host "+serverName+" port "+serverPort);
59 cc.setStreams(new JavaInStream(sock.getInputStream()),
60 new JavaOutStream(sock.getOutputStream()));
61 cc.initialiseProtocol();
62 } catch (java.io.IOException e) {
63 e.printStackTrace();
64 }
65 return false;
66 }
67
68 public int getType() { return Security.secTypeManaged; }
69
70 java.net.Socket sock;
71 UserPasswdGetter upg;
72
73 static LogWriter vlog = new LogWriter("Managed");
74 public String description() { return "No Encryption"; }
75
76}