Exemple #1
0
        private async Task <LogOnIdentity> AskForLogOnAsync(LogOnIdentity identity, string encryptedFileFullName)
        {
            LogOnEventArgs logOnArgs = new LogOnEventArgs()
            {
                DisplayPassphrase     = _userSettings.DisplayEncryptPassphrase,
                Identity              = identity,
                EncryptedFileFullName = encryptedFileFullName,
            };

            await OnLoggingOnAsync(logOnArgs);

            while (logOnArgs.IsAskingForPreviouslyUnknownPassphrase)
            {
                LogOnIdentity newIdentity = await AskForNewEncryptionPassphraseAsync(logOnArgs.Passphrase, encryptedFileFullName);

                if (newIdentity != LogOnIdentity.Empty)
                {
                    return(newIdentity);
                }
                logOnArgs.IsAskingForPreviouslyUnknownPassphrase = false;
                await OnLoggingOnAsync(logOnArgs);
            }

            if (logOnArgs.Cancel || logOnArgs.Passphrase == Passphrase.Empty)
            {
                return(LogOnIdentity.Empty);
            }

            _userSettings.DisplayEncryptPassphrase = logOnArgs.DisplayPassphrase;

            return(await LogOnIdentityFromCredentialsAsync(EmailAddress.Parse(logOnArgs.UserEmail), logOnArgs.Passphrase));
        }
Exemple #2
0
        private async Task <LogOnIdentity> AskForNewEncryptionPassphraseAsync(Passphrase defaultPassphrase, string encryptedFileFullName)
        {
            LogOnEventArgs logOnArgs = new LogOnEventArgs()
            {
                IsAskingForPreviouslyUnknownPassphrase = true,
                DisplayPassphrase     = _userSettings.DisplayEncryptPassphrase,
                Passphrase            = defaultPassphrase,
                EncryptedFileFullName = encryptedFileFullName,
            };

            await OnLoggingOnAsync(logOnArgs);

            return(await AddKnownIdentityFromEventAsync(logOnArgs));
        }
Exemple #3
0
        private async Task <LogOnIdentity> AskForDecryptPassphraseActionAsync(string encryptedFileFullName)
        {
            LogOnEventArgs logOnArgs = new LogOnEventArgs()
            {
                DisplayPassphrase     = _userSettings.DisplayEncryptPassphrase,
                Identity              = LogOnIdentity.Empty,
                EncryptedFileFullName = encryptedFileFullName,
            };

            await OnLoggingOnAsync(logOnArgs);

            LogOnIdentity identy = await AddKnownIdentityFromEventAsync(logOnArgs);

            if (!_knownIdentities.IsLoggedOn && identy.UserEmail != EmailAddress.Empty)
            {
                await _knownIdentities.SetDefaultEncryptionIdentity(identy);
            }
            return(identy);
        }
Exemple #4
0
        private async Task <LogOnIdentity> AddKnownIdentityFromEventAsync(LogOnEventArgs logOnArgs)
        {
            if (logOnArgs.Cancel || logOnArgs.Passphrase == Passphrase.Empty)
            {
                return(LogOnIdentity.Empty);
            }

            _userSettings.DisplayEncryptPassphrase = logOnArgs.DisplayPassphrase;

            Passphrase    passphrase = logOnArgs.Passphrase;
            LogOnIdentity identity   = await LogOnIdentityFromCredentialsAsync(EmailAddress.Parse(logOnArgs.UserEmail), passphrase);

            if (identity == LogOnIdentity.Empty)
            {
                identity = new LogOnIdentity(passphrase);
                _fileSystemState.KnownPassphrases.Add(passphrase);
                await _fileSystemState.Save();
            }
            await _knownIdentities.AddAsync(identity);

            return(identity);
        }
Exemple #5
0
 protected virtual async Task OnLoggingOnAsync(LogOnEventArgs e)
 {
     StartSigningInWithOnlineStateRechecked();
     await(LoggingOnAsync?.Invoke(e) ?? Constant.CompletedTask);
 }