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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/Password.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. PlainPasswd password1(strDup(getItemString(IDC_PASSWORD1)));
  32. PlainPasswd password2(strDup(getItemString(IDC_PASSWORD2)));
  33. if (strcmp(password1.buf, password2.buf) != 0) {
  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. PlainPasswd password(strDup(password1.buf));
  44. ObfuscatedPasswd obfPwd(password);
  45. regKey.setBinary("Password", obfPwd.buf, obfPwd.length);
  46. return true;
  47. }