private QueryResult <EncryptionPasswords> QueryEncryptionPassword(bool askOwnerPassword, bool askUserPassword)
        {
            var pwInteraction = new EncryptionPasswordInteraction(true, askOwnerPassword, askUserPassword);

            _interactionInvoker.Invoke(pwInteraction);

            var result = new QueryResult <EncryptionPasswords>();

            switch (pwInteraction.Response)
            {
            case PasswordResult.Skip:
                _logger.Info("User skipped encryption password dialog. Encryption disabled.");
                return(result);

            case PasswordResult.StorePassword:
                var password = new EncryptionPasswords
                {
                    OwnerPassword = pwInteraction.OwnerPassword,
                    UserPassword  = pwInteraction.UserPassword
                };
                result.Data = password;

                result.Success = true;
                return(result);
            }

            throw new AbortWorkflowException("Cancelled setting encryption passwords.");
        }
        private void SecurityPasswordExecute(object obj)
        {
            var askUserPassword = CurrentProfile.PdfSettings.Security.RequireUserPassword;

            var interaction = new EncryptionPasswordInteraction(false, true, askUserPassword);

            interaction.OwnerPassword = CurrentProfile.PdfSettings.Security.OwnerPassword;
            interaction.UserPassword  = CurrentProfile.PdfSettings.Security.UserPassword;

            _interactionRequest.Raise(interaction, securityPasswordsCallback);
        }
Пример #3
0
        public void OnInteractionSet_SetsPasswordsInView()
        {
            var viewModel   = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());
            var interaction = new EncryptionPasswordInteraction(false, true, true);

            var actionWasCalled = false;

            viewModel.SetPasswordInUi = (x, y) => actionWasCalled = true;

            viewModel.SetInteraction(interaction);
            Assert.IsTrue(actionWasCalled);
        }
Пример #4
0
        public void OkCommand_OnExecute_CompletesInteraction()
        {
            var viewModel   = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());
            var interaction = new EncryptionPasswordInteraction(false, true, true);

            var helper = new InteractionHelper <EncryptionPasswordInteraction>(viewModel, interaction);

            viewModel.OkCommand.Execute(null);

            Assert.AreEqual(PasswordResult.StorePassword, interaction.Response);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
        public void RemoveCommand_OnExecute_CompletesInteraction()
        {
            var viewModel   = new EncryptionPasswordViewModel();
            var interaction = new EncryptionPasswordInteraction(false, true, true);
            var helper      = new InteractionHelper <EncryptionPasswordInteraction>(viewModel, interaction);

            viewModel.RemoveCommand.Execute(null);

            Assert.AreEqual(PasswordResult.RemovePassword, interaction.Response);
            Assert.IsTrue(helper.InteractionIsFinished);
            Assert.AreEqual("", interaction.OwnerPassword);
            Assert.AreEqual("", interaction.UserPassword);
        }
Пример #6
0
        public void SetingUserPassword_WritesToInteractionAndCallsCanExecuteChanged()
        {
            var viewModel         = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());
            var canExecuteChanged = false;

            viewModel.OkCommand.CanExecuteChanged += (sender, args) => canExecuteChanged = true;
            var interaction = new EncryptionPasswordInteraction(false, true, true);

            viewModel.SetInteraction(interaction);

            viewModel.UserPassword = "******";

            Assert.AreEqual("MyPassword", interaction.UserPassword);
            Assert.IsTrue(canExecuteChanged);
        }
        private void securityPasswordsCallback(EncryptionPasswordInteraction interaction)
        {
            switch (interaction.Response)
            {
            case PasswordResult.StorePassword:
                CurrentProfile.PdfSettings.Security.OwnerPassword = interaction.OwnerPassword;
                CurrentProfile.PdfSettings.Security.UserPassword  = interaction.UserPassword;
                break;

            case PasswordResult.RemovePassword:
                CurrentProfile.PdfSettings.Security.UserPassword  = "";
                CurrentProfile.PdfSettings.Security.OwnerPassword = "";
                break;
            }
        }
Пример #8
0
        private void SecurityPasswordExecute(object obj)
        {
            var askUserPassword = CurrentProfile.PdfSettings.Security.RequireUserPassword;

            var interaction = new EncryptionPasswordInteraction(false, true, askUserPassword);

            interaction.OwnerPassword = CurrentProfile.PdfSettings.Security.OwnerPassword;
            interaction.UserPassword  = CurrentProfile.PdfSettings.Security.UserPassword;

            _interactionInvoker.Invoke(interaction);

            switch (interaction.Response)
            {
            case PasswordResult.StorePassword:
                CurrentProfile.PdfSettings.Security.OwnerPassword = interaction.OwnerPassword;
                CurrentProfile.PdfSettings.Security.UserPassword  = interaction.UserPassword;
                break;

            case PasswordResult.RemovePassword:
                CurrentProfile.PdfSettings.Security.UserPassword  = "";
                CurrentProfile.PdfSettings.Security.OwnerPassword = "";
                break;
            }
        }