Esempio n. 1
0
        public void CheckMasterPasswordTest()
        {
            SecureString wrongPassword = new SecureString();

            wrongPassword.AppendChar('c');
            SecureString passwd = new SecureString();

            foreach (char c in masterPassword.ToCharArray())
            {
                passwd.AppendChar(c);
            }

            Authentification.NewMasterPassword(passwd, triggerCompleteEvent: true);
            PasswordObject oldAppPassword = new PasswordObject();

            oldAppPassword.Password = Authentification.AppPassword.Password.Copy();
            oldAppPassword.Salt     = new byte[Authentification.AppPassword.Salt.Length];
            Authentification.AppPassword.Salt.CopyTo(oldAppPassword.Salt, 0);

            Assert.IsFalse(Authentification.CheckMasterPassword(wrongPassword));

            Assert.IsTrue(Authentification.CheckMasterPassword(passwd));
            PasswordObject newAppPassword = new PasswordObject();

            newAppPassword.Password = Authentification.AppPassword.Password.Copy();
            newAppPassword.Salt     = new byte[Authentification.AppPassword.Salt.Length];
            Authentification.AppPassword.Salt.CopyTo(newAppPassword.Salt, 0);
            Assert.IsTrue(CheckAppPassword(oldAppPassword, newAppPassword));

            Assert.IsTrue(Authentification.CheckMasterPassword(passwd, shortCheck: true));
            Assert.IsTrue(CheckAppPassword(newAppPassword, Authentification.AppPassword));
        }
        public void OnSubmitPassword(object box)
        {
            var result = BasePasswordCheck((box as PasswordBox).SecurePassword);

            if (!string.IsNullOrEmpty(result))
            {
                PasswordError      = result;
                CheckPasswordError = Visibility.Visible;
            }
            else if (!Authentification.CheckMasterPassword((box as PasswordBox).SecurePassword))
            {
                CheckPasswordError = Visibility.Visible;
            }
        }
Esempio n. 3
0
        public bool OnSubmitPassword()
        {
            ClearValidationErros();
            string result = BasePasswordCheck(CheckPassword.Password, "Current");

            if (!string.IsNullOrEmpty(result))
            {
                CheckPasswordError      = result;
                CheckPasswordErrorFrame = Visibility.Visible;
                return(false);
            }
            result = BasePasswordCheck(NewPassword.Password, "New");
            if (!string.IsNullOrEmpty(result))
            {
                NewPasswordError      = result;
                NewPasswordErrorFrame = Visibility.Visible;
                return(false);
            }
            if (CheckPassword.Equals(NewPassword))
            {
                NewPasswordError      = "Cannot use current password as a new one!";
                NewPasswordErrorFrame = Visibility.Visible;
                return(false);
            }
            if (!ValidateNewPasswordReEnter())
            {
                return(false);
            }
            if (!Authentification.CheckMasterPassword(CheckPassword.Password, shortCheck: true))
            {
                CheckPasswordError      = "Current password is incorrect!";
                CheckPasswordErrorFrame = Visibility.Visible;
                return(false);
            }
            Authentification.NewMasterPassword(NewPassword.Password, triggerCompleteEvent: true);
            OnPasswordUpdateComplete();
            return(true);
        }