blob: 8ae7902c3bc40a0a39568303612791b24be06587 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* 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>
Michal Srb8d1ee002014-11-10 09:15:41 +020047#include <rfb/SConnection.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000048#include <rfb/util.h>
49#include <list>
50
51namespace rfb {
52
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000053 class SSecurity {
54 public:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020055 SSecurity(SConnection* sc) { this->sc = sc; }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000056 virtual ~SSecurity() {}
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020057 virtual bool processMsg() = 0;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000058 virtual int getType() const = 0;
59
60 // getUserName() gets the name of the user attempting authentication. The
61 // storage is owned by the SSecurity object, so a copy must be taken if
62 // necessary. Null may be returned to indicate that there is no user name
63 // for this security type.
64 virtual const char* getUserName() const = 0;
Michal Srb8d1ee002014-11-10 09:15:41 +020065
66 virtual SConnection::AccessRights getAccessRights() const { return SConnection::AccessDefault; }
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020067
68 protected:
69 SConnection* sc;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000070 };
71
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000072}
73#endif