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 | // SSecurity - class on the server 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 client. It |
| 25 | // should return false when it needs more data, or true when the connection has |
| 26 | // been successfully authenticated. In the event of authentication failure an |
| 27 | // AuthFailureException should be thrown - this will result in a "failed" |
| 28 | // security result being sent to the client with the str() from the exception |
| 29 | // being sent as the reason. Any other type of failure should be indicated by |
| 30 | // some other kind of exception which will cause the connection to be aborted. |
| 31 | // |
| 32 | // processMsg() must never block (or at least must never block until the client |
| 33 | // has been authenticated) - this is to prevent denial of service attacks. |
| 34 | // Note that the first time processMsg() is called, there is no guarantee that |
| 35 | // there is any data to read from the SConnection's InStream, but subsequent |
| 36 | // calls guarantee there is at least one byte which can be read without |
| 37 | // blocking. |
| 38 | // |
| 39 | // getType() should return the secType value corresponding to the SSecurity |
| 40 | // implementation. |
| 41 | // |
| 42 | |
| 43 | #ifndef __RFB_SSECURITY_H__ |
| 44 | #define __RFB_SSECURITY_H__ |
| 45 | |
| 46 | #include <rdr/types.h> |
| 47 | #include <rfb/util.h> |
| 48 | #include <list> |
| 49 | |
| 50 | namespace rfb { |
| 51 | |
| 52 | class SConnection; |
| 53 | |
| 54 | class SSecurity { |
| 55 | public: |
| 56 | virtual ~SSecurity() {} |
| 57 | virtual bool processMsg(SConnection* sc)=0; |
| 58 | virtual void destroy() { delete this; } |
| 59 | virtual int getType() const = 0; |
| 60 | |
| 61 | // getUserName() gets the name of the user attempting authentication. The |
| 62 | // storage is owned by the SSecurity object, so a copy must be taken if |
| 63 | // necessary. Null may be returned to indicate that there is no user name |
| 64 | // for this security type. |
| 65 | virtual const char* getUserName() const = 0; |
| 66 | }; |
| 67 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 68 | } |
| 69 | #endif |