annotate src/main/java/com/glavsoft/rfb/protocol/state/SecurityType33State.java @ 0:daa24f8a557b

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