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.

PasswordDialog.cxx 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright (C) 2004-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. #include <vncconfig/resource.h>
  19. #include <vncconfig/PasswordDialog.h>
  20. #include <rfb_win32/MsgBox.h>
  21. #include <rfb/obfuscate.h>
  22. using namespace rfb;
  23. using namespace win32;
  24. PasswordDialog::PasswordDialog(const RegKey& rk, bool registryInsecure_)
  25. : Dialog(GetModuleHandle(0)), regKey(rk), registryInsecure(registryInsecure_) {
  26. }
  27. bool PasswordDialog::showDialog(HWND owner) {
  28. return Dialog::showDialog(MAKEINTRESOURCE(IDD_AUTH_VNC_PASSWD), owner);
  29. }
  30. bool PasswordDialog::onOk() {
  31. std::string password1(getItemString(IDC_PASSWORD1));
  32. std::string password2(getItemString(IDC_PASSWORD2));
  33. if (password1 != password2) {
  34. MsgBox(0, "The supplied passwords do not match",
  35. MB_ICONEXCLAMATION | MB_OK);
  36. return false;
  37. }
  38. if (registryInsecure &&
  39. (MsgBox(0, "Please note that your password cannot be stored securely on this system. "
  40. "Are you sure you wish to continue?",
  41. MB_YESNO | MB_ICONWARNING) == IDNO))
  42. return false;
  43. std::vector<uint8_t> obfPwd = obfuscate(password1.c_str());
  44. regKey.setBinary("Password", obfPwd.data(), obfPwd.size());
  45. return true;
  46. }