Beispiel #1
0
        public async Task PrepareForTest()
        {
            this.thisTestInfo = await Utils.GetDatabaseInfoForTest(TestContext);

            this.reader = new KdbxReader();
            Assert.AreEqual(ReaderResult.Success, await this.reader.ReadHeaderAsync(await this.thisTestInfo.Database.AsIStorageFile.OpenReadAsync(), new CancellationTokenSource().Token));
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="syncContext">Synchronization context used for marshalling to the UI thread.</param>
        /// <param name="file">The candidate document file.</param>
        /// <param name="isSampleFile">Whether the file is a PassKeep sample.</param>
        /// <param name="futureAccessList">A database access list for persisting permission to the database.</param>
        /// <param name="reader">The IKdbxReader implementation used for parsing document files.</param>
        /// <param name="proxyProvider">Generates file proxies that the app controls.</param>
        /// <param name="candidateFactory">Factory used to generate new candidate files as needed.</param>
        /// <param name="keyChangeVmFactory">Factory used to generate the objects used to modify the master key of the database.</param>
        /// <param name="taskNotificationService">A service used to notify the UI of blocking operations.</param>
        /// <param name="identityService">The service used to verify the user's consent for saving credentials.</param>
        /// <param name="credentialProvider">The provider used to store/load saved credentials.</param>
        /// <param name="credentialViewModelFactory">A factory used to generate <see cref="ISavedCredentialsViewModel"/> instances.</param>
        public DatabaseUnlockViewModel(
            ISyncContext syncContext,
            IDatabaseCandidate file,
            bool isSampleFile,
            IDatabaseAccessList futureAccessList,
            IKdbxReader reader,
            IFileProxyProvider proxyProvider,
            IDatabaseCandidateFactory candidateFactory,
            IMasterKeyChangeViewModelFactory keyChangeVmFactory,
            ITaskNotificationService taskNotificationService,
            IIdentityVerificationService identityService,
            ICredentialStorageProvider credentialProvider,
            ISavedCredentialsViewModelFactory credentialViewModelFactory
            )
        {
            this.syncContext                = syncContext ?? throw new ArgumentNullException(nameof(syncContext));
            this.futureAccessList           = futureAccessList;
            this.kdbxReader                 = reader ?? throw new ArgumentNullException(nameof(reader));
            this.proxyProvider              = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider));
            this.candidateFactory           = candidateFactory ?? throw new ArgumentNullException(nameof(candidateFactory));
            this.keyChangeVmFactory         = keyChangeVmFactory ?? throw new ArgumentNullException(nameof(keyChangeVmFactory));
            this.taskNotificationService    = taskNotificationService ?? throw new ArgumentNullException(nameof(taskNotificationService));
            this.identityService            = identityService ?? throw new ArgumentNullException(nameof(identityService));
            this.credentialProvider         = credentialProvider ?? throw new ArgumentNullException(nameof(credentialProvider));
            this.credentialViewModelFactory = credentialViewModelFactory ?? throw new ArgumentNullException(nameof(credentialViewModelFactory));

            SaveCredentials            = false;
            IdentityVerifiability      = UserConsentVerifierAvailability.Available;
            UnlockCommand              = new AsyncActionCommand(CanUnlock, DoUnlockAsync);
            UseSavedCredentialsCommand = new AsyncActionCommand(
                () => UnlockCommand.CanExecute(null) && HasSavedCredentials,
                DoUnlockWithSavedCredentials
                );
            IsSampleFile     = isSampleFile;
            RememberDatabase = true;

            this.initialConstruction = UpdateCandidateFileAsync(file);
        }