Esempio n. 1
0
        private bool DecryptAuthenticator()
        {
            if (newAuthenticator.IsDecrypted)
            {
                return(true);
            }

            if (newAuthenticator.EncryptionType.HasFlag(AuthAPI.Security.EncryptionProvider.EncryptionType.Password))
            {
                bool firstTry = true;

                while (true)
                {
                    AskPasswordWindow askPassWindow = new AskPasswordWindow(!firstTry);
                    askPassWindow.Title   = newAuthenticator.DisplayName;
                    askPassWindow.Owner   = this;
                    askPassWindow.Topmost = this.Topmost;

                    askPassWindow.ShowDialog();

                    firstTry = false;

                    if (askPassWindow.DialogResult == true)
                    {
                        bool decrypt = newAuthenticator.Decrypt(askPassWindow.PASS_Decrypt.Password);

                        if (decrypt == true)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                bool decrypt = newAuthenticator.Decrypt();

                if (decrypt == false)
                {
                    string type = newAuthenticator.EncryptionType.HasFlag(AuthAPI.Security.EncryptionProvider.EncryptionType.LocalUser) ? "user" : "machine";

                    MessageBox.Show("Could not decrypt " + type + " locked authenticator.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }