Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SSecurityPlain.h 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (C) 2005 Martin Koegler
  2. * Copyright (C) 2006 OCCAM Financial Technology
  3. * Copyright (C) 2010 TigerVNC Team
  4. *
  5. * This is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This software is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this software; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  18. * USA.
  19. */
  20. #ifndef __RFB_SSECURITYPLAIN_H__
  21. #define __RFB_SSECURITYPLAIN_H__
  22. #include <rfb/SConnection.h>
  23. #include <rfb/SSecurity.h>
  24. #include <rfb/SSecurityVeNCrypt.h>
  25. #include <rfb/util.h>
  26. #include <rfb/Configuration.h>
  27. namespace rfb {
  28. class PasswordValidator {
  29. public:
  30. bool validate(SConnection* sc, const char *username, const char *password)
  31. { return validUser(username) ? validateInternal(sc, username, password) : false; }
  32. static StringParameter plainUsers;
  33. virtual ~PasswordValidator() { }
  34. protected:
  35. virtual bool validateInternal(SConnection* sc, const char *username, const char *password)=0;
  36. static bool validUser(const char* username);
  37. };
  38. class SSecurityPlain : public SSecurity {
  39. public:
  40. SSecurityPlain(SConnection* sc);
  41. virtual bool processMsg();
  42. virtual int getType() const { return secTypePlain; };
  43. virtual const char* getUserName() const { return username.buf; }
  44. virtual ~SSecurityPlain() { }
  45. private:
  46. PasswordValidator* valid;
  47. unsigned int ulen, plen, state;
  48. CharArray username;
  49. static const unsigned int MaxSaneUsernameLength = 1024;
  50. static const unsigned int MaxSanePasswordLength = 1024;
  51. };
  52. }
  53. #endif