You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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