Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* 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 | // |
| 19 | // secTypes.h - constants for the various security types. |
| 20 | // |
| 21 | |
| 22 | #ifndef __RFB_SECTYPES_H__ |
| 23 | #define __RFB_SECTYPES_H__ |
| 24 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 25 | #include <rdr/types.h> |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 26 | #include <rfb/Configuration.h> |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame^] | 27 | #include <rfb/CSecurity.h> |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 28 | #include <rfb/SSecurity.h> |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame^] | 29 | #include <rfb/UserPasswdGetter.h> |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 30 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 31 | #include <list> |
| 32 | |
| 33 | namespace rfb { |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 34 | const rdr::U8 secTypeInvalid = 0; |
| 35 | const rdr::U8 secTypeNone = 1; |
| 36 | const rdr::U8 secTypeVncAuth = 2; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 37 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 38 | const rdr::U8 secTypeRA2 = 5; |
| 39 | const rdr::U8 secTypeRA2ne = 6; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 40 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 41 | const rdr::U8 secTypeSSPI = 7; |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 42 | const rdr::U8 secTypeSSPIne = 8; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 43 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 44 | const rdr::U8 secTypeTight = 16; |
| 45 | const rdr::U8 secTypeUltra = 17; |
| 46 | const rdr::U8 secTypeTLS = 18; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 47 | |
| 48 | // result types |
| 49 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 50 | const rdr::U32 secResultOK = 0; |
| 51 | const rdr::U32 secResultFailed = 1; |
| 52 | const rdr::U32 secResultTooMany = 2; // deprecated |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 53 | |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 54 | class Security { |
| 55 | public: |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame^] | 56 | /* |
| 57 | * Create Security instance. |
| 58 | */ |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 59 | Security(void); |
| 60 | |
| 61 | /* Enable/Disable certain security type */ |
| 62 | void EnableSecType(rdr::U8 secType); |
| 63 | void DisableSecType(rdr::U8 secType) { enabledSecTypes.remove(secType); } |
| 64 | |
| 65 | /* Check if certain type is supported */ |
| 66 | bool IsSupported(rdr::U8 secType); |
| 67 | |
| 68 | /* Get list of enabled security types */ |
| 69 | const std::list<rdr::U8>& GetEnabledSecTypes(void) |
| 70 | { return enabledSecTypes; } |
| 71 | |
| 72 | /* Create server side SSecurity class instance */ |
| 73 | SSecurity* GetSSecurity(rdr::U8 secType); |
| 74 | |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame^] | 75 | /* Create client side CSecurity class instance */ |
| 76 | CSecurity* GetCSecurity(rdr::U8 secType); |
| 77 | |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 78 | static StringParameter secTypes; |
Adam Tkac | c210e8a | 2010-04-23 14:09:16 +0000 | [diff] [blame^] | 79 | |
| 80 | /* |
| 81 | * Use variable directly instead of dumb get/set methods. It is used |
| 82 | * only in viewer-side code and MUST be set by viewer. |
| 83 | */ |
| 84 | UserPasswdGetter *upg; |
Adam Tkac | 1d15e2d | 2010-04-23 14:06:38 +0000 | [diff] [blame] | 85 | private: |
| 86 | std::list<rdr::U8> enabledSecTypes; |
| 87 | }; |
| 88 | |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 89 | const char* secTypeName(rdr::U8 num); |
| 90 | rdr::U8 secTypeNum(const char* name); |
Adam Tkac | 94d88c1 | 2010-04-23 13:59:52 +0000 | [diff] [blame] | 91 | std::list<rdr::U8> parseSecTypes(const char* types); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | #endif |