blob: 3502289f3b44ea500ab477382e9308524442249e [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());
40 os.writeBytes(username.toString().getBytes(), 0, username.length());
41 os.flush();
42 int serverPort = is.readU16();
43 //if (serverPort==0) { return true; };
44 String serverName = cc.getServerName();
45 vlog.debug("Redirected to "+serverName+" port "+serverPort);
46 try {
47 CConn.getSocket().close();
48 cc.setServerPort(serverPort);
49 sock = new java.net.Socket(serverName, serverPort);
50 sock.setTcpNoDelay(true);
51 sock.setTrafficClass(0x10);
52 CConn.setSocket(sock);
53 vlog.debug("connected to host "+serverName+" port "+serverPort);
54 cc.setStreams(new JavaInStream(sock.getInputStream()),
55 new JavaOutStream(sock.getOutputStream()));
56 cc.initialiseProtocol();
57 } catch (java.io.IOException e) {
58 e.printStackTrace();
59 }
60 return false;
61 }
62
63 public int getType() { return Security.secTypeManaged; }
64
65 java.net.Socket sock;
66 UserPasswdGetter upg;
67
68 static LogWriter vlog = new LogWriter("Managed");
69 public String description() { return "No Encryption"; }
70
71}