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.auth;
|
|
26
|
|
27 import java.util.LinkedHashMap;
|
|
28 import java.util.Map;
|
|
29
|
|
30 import com.glavsoft.exceptions.UnsupportedSecurityTypeException;
|
|
31
|
|
32 /**
|
|
33 * Security types that implemented
|
|
34 */
|
|
35 public enum SecurityType {
|
|
36 NONE_AUTHENTICATION(1),
|
|
37 VNC_AUTHENTICATION(2),
|
|
38 // int RA2_AUTHENTICATION = 5;
|
|
39 // int RA2NE_AUTHENTICATION = 6;
|
|
40 TIGHT_AUTHENTICATION(16);
|
|
41 // int ULTRA_AUTHENTICATION = 17;
|
|
42 // int TLS_AUTHENTICATION = 18;
|
|
43 // int VENCRYPT_AUTHENTICATION = 19;
|
|
44
|
|
45 private int id;
|
|
46 private SecurityType(int id) {
|
|
47 this.id = id;
|
|
48 }
|
|
49
|
|
50 public int getId() {
|
|
51 return id;
|
|
52 }
|
|
53
|
|
54 @SuppressWarnings("serial")
|
|
55 public
|
|
56 static Map<Integer, AuthHandler> implementedSecurityTypes =
|
|
57 new LinkedHashMap<Integer, AuthHandler>() {{
|
|
58 put(TIGHT_AUTHENTICATION.getId(), new TightAuthentication());
|
|
59 put(VNC_AUTHENTICATION.getId(), new VncAuthentication());
|
|
60 put(NONE_AUTHENTICATION.getId(), new NoneAuthentication());
|
|
61 }};
|
|
62
|
|
63 public static AuthHandler getAuthHandlerById(int id) throws UnsupportedSecurityTypeException {
|
|
64 AuthHandler typeSelected = null;
|
|
65 typeSelected = implementedSecurityTypes.get(id);
|
|
66 if (null == typeSelected) {
|
|
67 throw new UnsupportedSecurityTypeException("Not supported: " + id);
|
|
68 }
|
|
69 return typeSelected;
|
|
70 }
|
|
71
|
|
72 }
|