Esempio n. 1
0
        private void DecryptAuthenticator()
        {
            if (Settings.SettingsDatabase.SelectedAuthenticator.EncryptionType.HasFlag(AuthAPI.Security.EncryptionProvider.EncryptionType.Password))
            {
                bool firstTry = true;

                while (true)
                {
                    AskPasswordWindow askPassWindow = new AskPasswordWindow(!firstTry);
                    askPassWindow.Title   = Settings.SettingsDatabase.SelectedAuthenticator.DisplayName;
                    askPassWindow.Owner   = App.MainAppWindow;
                    askPassWindow.Topmost = App.MainAppWindow.Topmost;

                    askPassWindow.ShowDialog();

                    firstTry = false;

                    if (askPassWindow.DialogResult == true)
                    {
                        bool decrypt = Settings.SettingsDatabase.SelectedAuthenticator.Decrypt(askPassWindow.PASS_Decrypt.Password);

                        if (decrypt == true)
                        {
                            this.RefreshAuthenticatorData();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                bool decrypt = Settings.SettingsDatabase.SelectedAuthenticator.Decrypt();

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

                    MessageBox.Show("Could not decrypt " + type + " locked authenticator.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    this.RefreshAuthenticatorData();
                }
            }
        }
        private void DecryptAuthenticator()
        {
            if (Settings.SettingsDatabase.SelectedAuthenticator.EncryptionType.HasFlag(AuthAPI.Security.EncryptionProvider.EncryptionType.Password))
            {
                bool firstTry = true;

                while (true)
                {
                    AskPasswordWindow askPassWindow = new AskPasswordWindow(!firstTry);
                    askPassWindow.Title = Settings.SettingsDatabase.SelectedAuthenticator.DisplayName;
                    askPassWindow.Owner = App.MainAppWindow;
                    askPassWindow.Topmost = App.MainAppWindow.Topmost;

                    askPassWindow.ShowDialog();

                    firstTry = false;

                    if (askPassWindow.DialogResult == true)
                    {
                        bool decrypt = Settings.SettingsDatabase.SelectedAuthenticator.Decrypt(askPassWindow.PASS_Decrypt.Password);

                        if (decrypt == true)
                        {
                            this.RefreshAuthenticatorData();
                            break;
                        }
                    }
                    else
                        break;
                }
            }
            else
            {
                bool decrypt = Settings.SettingsDatabase.SelectedAuthenticator.Decrypt();

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

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