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.

SSecurityPlain.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifdef HAVE_CONFIG_H
  23. #include <config.h>
  24. #endif
  25. #include <rfb/SConnection.h>
  26. #include <rfb/SSecurity.h>
  27. #include <rfb/SSecurityVeNCrypt.h>
  28. #include <rfb/util.h>
  29. #include <rfb/Configuration.h>
  30. namespace rfb {
  31. class PasswordValidator {
  32. public:
  33. bool validate(SConnection* sc, const char *username, const char *password)
  34. { return validUser(username) ? validateInternal(sc, username, password) : false; }
  35. static StringParameter plainUsers;
  36. virtual ~PasswordValidator() { }
  37. protected:
  38. virtual bool validateInternal(SConnection* sc, const char *username, const char *password)=0;
  39. static bool validUser(const char* username);
  40. };
  41. class SSecurityPlain : public SSecurity {
  42. public:
  43. SSecurityPlain(SConnection* sc);
  44. virtual bool processMsg();
  45. virtual int getType() const { return secTypePlain; };
  46. virtual const char* getUserName() const { return username.buf; }
  47. virtual ~SSecurityPlain() { }
  48. private:
  49. PasswordValidator* valid;
  50. unsigned int ulen, plen, state;
  51. CharArray username;
  52. static const unsigned int MaxSaneUsernameLength = 1024;
  53. static const unsigned int MaxSanePasswordLength = 1024;
  54. };
  55. }
  56. #endif