0
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
|
|
2 // All rights reserved.
|
|
3 //
|
|
4 //-------------------------------------------------------------------------
|
|
5 // This file is part of the TightVNC software. Please visit our Web site:
|
|
6 //
|
|
7 // http://www.tightvnc.com/
|
|
8 //
|
|
9 // This program is free software; you can redistribute it and/or modify
|
|
10 // it under the terms of the GNU General Public License as published by
|
|
11 // the Free Software Foundation; either version 2 of the License, or
|
|
12 // (at your option) any later version.
|
|
13 //
|
|
14 // This program is distributed in the hope that it will be useful,
|
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 // GNU General Public License for more details.
|
|
18 //
|
|
19 // You should have received a copy of the GNU General Public License along
|
|
20 // with this program; if not, write to the Free Software Foundation, Inc.,
|
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
22 //-------------------------------------------------------------------------
|
|
23 //
|
|
24
|
|
25 package com.glavsoft.rfb.protocol.state;
|
|
26
|
|
27 import com.glavsoft.exceptions.TransportException;
|
|
28 import com.glavsoft.exceptions.UnsupportedSecurityTypeException;
|
|
29 import com.glavsoft.rfb.protocol.ProtocolContext;
|
|
30 import com.glavsoft.rfb.protocol.auth.AuthHandler;
|
|
31
|
|
32 import java.util.logging.Logger;
|
|
33
|
|
34 public class SecurityType33State extends SecurityType37State {
|
|
35
|
|
36 public SecurityType33State(ProtocolContext context) {
|
|
37 super(context);
|
|
38 }
|
|
39
|
|
40 @Override
|
|
41 protected void negotiateAboutSecurityType()
|
|
42 throws TransportException, UnsupportedSecurityTypeException {
|
|
43 Logger.getLogger(getClass().getName()).info("Get Security Type");
|
|
44 int type = reader.readInt32();
|
|
45 Logger.getLogger(getClass().getName()).info("Type received: " + type);
|
|
46 if (0 == type)
|
|
47 // throw exception with reason
|
|
48 throw new UnsupportedSecurityTypeException(reader.readString());
|
|
49 AuthHandler typeSelected = selectAuthHandler(new byte[] {(byte) (0xff & type)},
|
|
50 context.getSettings().authCapabilities);
|
|
51 if (typeSelected != null) {
|
|
52 setUseSecurityResult(typeSelected);
|
|
53 Logger.getLogger(getClass().getName()).info("Type accepted: " + typeSelected.getName());
|
|
54 } else
|
|
55 throw new UnsupportedSecurityTypeException(
|
|
56 "No security types supported. Server sent '" +
|
|
57 type + "' security type, but we do not support it.");
|
|
58 changeStateTo(new AuthenticationState(context, typeSelected));
|
|
59 }
|
|
60
|
|
61 }
|