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 | // CSecurity - class on the client side for handling security handshaking. A |
| 20 | // derived class for a particular security type overrides the processMsg() |
| 21 | // method. |
| 22 | |
| 23 | // processMsg() is called first when the security type has been decided on, and |
| 24 | // will keep being called whenever there is data to read from the server. It |
| 25 | // should return false when it needs more data, or true when the security |
| 26 | // handshaking is over and we are now waiting for the SecurityResult message |
| 27 | // from the server. In the event of failure a suitable exception should be |
| 28 | // thrown. |
| 29 | // |
| 30 | // Note that the first time processMsg() is called, there is no guarantee that |
| 31 | // there is any data to read from the CConnection's InStream, but subsequent |
| 32 | // calls guarantee there is at least one byte which can be read without |
| 33 | // blocking. |
| 34 | // |
| 35 | // description is a string describing the level of encryption applied to the |
| 36 | // session, or null if no encryption will be used. |
| 37 | |
| 38 | #ifndef __RFB_CSECURITY_H__ |
| 39 | #define __RFB_CSECURITY_H__ |
| 40 | |
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 41 | #include <rfb/UserPasswdGetter.h> |
| 42 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 43 | namespace rfb { |
| 44 | class CConnection; |
| 45 | class CSecurity { |
| 46 | public: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 47 | CSecurity(CConnection* cc) { this->cc = cc; } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 48 | virtual ~CSecurity() {} |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 49 | virtual bool processMsg() = 0; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 50 | virtual int getType() const = 0; |
| 51 | virtual const char* description() const = 0; |
Pierre Ossman | daf3d88 | 2017-09-01 11:14:35 +0200 | [diff] [blame] | 52 | virtual bool isSecure() const { return false; } |
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | * Use variable directly instead of dumb get/set methods. |
| 56 | * It MUST be set by viewer. |
| 57 | */ |
| 58 | static UserPasswdGetter *upg; |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 59 | |
| 60 | protected: |
| 61 | CConnection* cc; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 62 | }; |
| 63 | } |
| 64 | #endif |