public void SetUp()
        {
            IDataStore knownPublicKeysStore = new FakeInMemoryDataStoreItem("knownpublickeys.txt");

            TypeMap.Register.Singleton <IAsymmetricFactory>(() => new BouncyCastleAsymmetricFactory());
            TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser());
            TypeMap.Register.Singleton <AxCryptOnlineState>(() => new AxCryptOnlineState());
            TypeMap.Register.Singleton <FileLocker>(() => new FileLocker());
            TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory());
            TypeMap.Register.Singleton <INow>(() => new FakeNow());
            TypeMap.Register.Singleton <UserPublicKeyUpdateStatus>(() => new UserPublicKeyUpdateStatus());
            TypeMap.Register.Singleton <KnownIdentities>(() => new KnownIdentities(Resolve.FileSystemState, Resolve.SessionNotify));
            TypeMap.Register.Singleton <FileSystemState>(() => FileSystemState.Create(Resolve.WorkFolder.FileInfo.FileItemInfo("FileSystemState.txt")));
            TypeMap.Register.Singleton <WorkFolder>(() => new WorkFolder(Path.GetPathRoot(Environment.CurrentDirectory) + @"WorkFolder\"));
            TypeMap.Register.Singleton <SessionNotify>(() => new SessionNotify());
            TypeMap.Register.Singleton <UserSettingsVersion>(() => new UserSettingsVersion());
            TypeMap.Register.Singleton <ISettingsStore>(() => new SettingsStore(null));
            TypeMap.Register.Singleton <UserSettings>(() => (new FakeUserSettings(new IterationCalculator())).Initialize());

            TypeMap.Register.New <IStringSerializer>(() => new StringSerializer(New <IAsymmetricFactory>().GetSerializers()));
            TypeMap.Register.New <KnownPublicKeys>(() => KnownPublicKeys.Load(knownPublicKeysStore, Resolve.Serializer));
            TypeMap.Register.New <ILogging>(() => new Logging());
            TypeMap.Register.New <string, IDataStore>((path) => new FakeDataStore(path));
            TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
            TypeMap.Register.New <string, IDataContainer>((path) => new FakeDataContainer(path));

            New <AxCryptOnlineState>().IsOnline = true;
        }
        public void TestAddingIdentiticalPublicKey()
        {
            Mock <FakeInMemoryDataStoreItem> storeMock = new Mock <FakeInMemoryDataStoreItem>("KnownPublicKeys.txt")
            {
                CallBase = true,
            };

            IAsymmetricPublicKey key1           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey1);
            UserPublicKey        userPublicKey1 = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key1);
            IAsymmetricPublicKey key2           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey2);
            UserPublicKey        userPublicKey2 = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key2);

            using (KnownPublicKeys knownPublicKeys = KnownPublicKeys.Load(storeMock.Object, Resolve.Serializer))
            {
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(0), "There should be no entries now.");

                knownPublicKeys.AddOrReplace(userPublicKey1);
                knownPublicKeys.AddOrReplace(userPublicKey2);
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(2), "There should be two entries now.");
            }
            storeMock.Verify(m => m.OpenWrite(), Times.Once);

            Assert.That(userPublicKey1, Is.Not.EqualTo(userPublicKey2), "Checking that the two public keys really are different.");

            storeMock.ResetCalls();
            using (KnownPublicKeys knownPublicKeys = KnownPublicKeys.Load(storeMock.Object, Resolve.Serializer))
            {
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(2), "There should be two entries now.");

                knownPublicKeys.AddOrReplace(userPublicKey2);
                knownPublicKeys.AddOrReplace(userPublicKey1);
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(2), "There should be two entries now.");
            }
            storeMock.Verify(m => m.OpenWrite(), Times.Never);
        }
        public async Task TestRemoveNonexistingFromShared()
        {
            IAsymmetricPublicKey key1           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey1);
            UserPublicKey        userPublicKey1 = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key1);

            IAsymmetricPublicKey key2           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey2);
            UserPublicKey        userPublicKey2 = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key2);

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                knownPublicKeys.AddOrReplace(userPublicKey1);
                knownPublicKeys.AddOrReplace(userPublicKey2);
            }

            SharingListViewModel model = await SharingListViewModel.CreateForFilesAsync(new string[0], LogOnIdentity.Empty);

            Assert.That(model.SharedWith.Any(), Is.False, "There are no known public keys, and none are set as shared.");
            Assert.That(model.NotSharedWith.Count(), Is.EqualTo(2), "There are two known public keys, so they should be available as unshared.");

            await model.AddKeyShares.ExecuteAsync(new[] { userPublicKey1.Email, });

            Assert.That(model.SharedWith.Count(), Is.EqualTo(1), "One was set as shared, so there should be one here now.");
            Assert.That(model.NotSharedWith.Count(), Is.EqualTo(1), "One unshared was set as shared, so there should be one here now.");

            await model.RemoveKeyShares.ExecuteAsync(new[] { userPublicKey2, });

            Assert.That(model.SharedWith.Count(), Is.EqualTo(1), "A key that was not set as shared was attempted to remove, nothing should happen.");
            Assert.That(model.NotSharedWith.Count(), Is.EqualTo(1), "A key that was not set as shared was attempted to remove, nothing should happen.");
        }
Example #4
0
        private async Task <UserPublicKey> OtherUserPublicKeysAsync(Func <Task <UserPublicKey> > localServiceOtherUserPublicKey, Func <Task <UserPublicKey> > remoteServiceOtherUserPublicKey)
        {
            UserPublicKey publicKey = await localServiceOtherUserPublicKey().Free();

            if (New <AxCryptOnlineState>().IsOffline)
            {
                return(NonNullPublicKey(publicKey));
            }

            try
            {
                publicKey = await remoteServiceOtherUserPublicKey().Free();

                using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
                {
                    knownPublicKeys.AddOrReplace(publicKey);
                }
            }
            catch (ApiException aex)
            {
                await aex.HandleApiExceptionAsync();
            }

            return(publicKey);
        }
        public async Task <SubscriptionLevel> ValidateLevelAsync(UserAccount userAccount)
        {
            if (userAccount == null)
            {
                throw new ArgumentNullException(nameof(userAccount));
            }

            if (userAccount.SubscriptionLevel <= SubscriptionLevel.Free)
            {
                return(userAccount.SubscriptionLevel);
            }
            if (userAccount.Signature == string.Empty)
            {
                return(SubscriptionLevel.Unknown);
            }

            IAsymmetricPublicKey publicKey = await New <ILicenseAuthority>().PublicKeyAsync();

            if (new Verifier(publicKey).Verify(Convert.FromBase64String(userAccount.Signature), SignedFields(userAccount)))
            {
                return(userAccount.SubscriptionLevel);
            }

            using (KnownPublicKeys knownKeys = New <KnownPublicKeys>())
            {
                publicKey = (await knownKeys.GetAsync(EmailAddress.Parse(New <UserSettings>().LicenseAuthorityEmail), New <KnownIdentities>().DefaultEncryptionIdentity))?.PublicKey;
                if (publicKey != null && new Verifier(publicKey).Verify(Convert.FromBase64String(userAccount.Signature), SignedFields(userAccount)))
                {
                    return(userAccount.SubscriptionLevel);
                }
            }

            return(SubscriptionLevel.Unknown);
        }
Example #6
0
        public static void RegisterTypeFactories(string workFolderPath, IEnumerable <Assembly> assemblies)
        {
            RegisterTypeFactories(assemblies);

            TypeMap.Register.Singleton <WorkFolderWatcher>(() => new WorkFolderWatcher());
            TypeMap.Register.Singleton <WorkFolder>(() => new WorkFolder(workFolderPath), () => New <WorkFolderWatcher>());
            TypeMap.Register.New <KnownPublicKeys>(() => KnownPublicKeys.Load(Resolve.WorkFolder.FileInfo.FileItemInfo("UserPublicKeys.txt"), New <IStringSerializer>()));
            TypeMap.Register.Singleton <FileSystemState>(() => FileSystemState.Create(Resolve.WorkFolder.FileInfo.FileItemInfo("FileSystemState.txt")));
        }
        public async Task TestInitialEmptyState()
        {
            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
            }
            SharingListViewModel model = await SharingListViewModel.CreateForFilesAsync(new string[0], LogOnIdentity.Empty);

            Assert.That(model.SharedWith.Any(), Is.False, "There are no known public keys, and none are set as shared.");
            Assert.That(model.NotSharedWith.Any(), Is.False, "There are no known public kyes, so none can be unshared either.");
        }
Example #8
0
 private static void UpdateKnownKeys(IEnumerable <UserPublicKey> sharedWith)
 {
     using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
     {
         IEnumerable <UserPublicKey> previouslyUnknown = sharedWith.Where(shared => !knownPublicKeys.PublicKeys.Any(known => known.Email == shared.Email));
         foreach (UserPublicKey newPublicKey in previouslyUnknown)
         {
             knownPublicKeys.AddOrReplace(newPublicKey);
         }
     }
 }
Example #9
0
        private void SetSharedAndNotSharedWith(IEnumerable <UserPublicKey> sharedWith)
        {
            EmailAddress userEmail = _identity.ActiveEncryptionKeyPair.UserEmail;

            SharedWith = sharedWith.Where(sw => sw.Email != userEmail).OrderBy(e => e.Email.Address).ToList();

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                NotSharedWith = knownPublicKeys.PublicKeys.Where(upk => upk.Email != userEmail && upk.Email.Address != New <UserSettings>().LicenseAuthorityEmail&& !sharedWith.Any(sw => upk.Email == sw.Email)).OrderBy(e => e.Email.Address);
            }
        }
Example #10
0
        private static IEnumerable <UserPublicKey> GetAllPublicKeyRecipientsFromWatchedFolders(IEnumerable <string> folderPaths)
        {
            IEnumerable <EmailAddress> sharedWithEmailAddresses = folderPaths.ToWatchedFolders().SharedWith();

            IEnumerable <UserPublicKey> sharedWith;

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                sharedWith = knownPublicKeys.PublicKeys.Where(pk => sharedWithEmailAddresses.Any(s => s == pk.Email)).ToList();
            }

            return(sharedWith);
        }
        public async Task TestInitialOneKeyState()
        {
            IAsymmetricPublicKey key           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey1);
            UserPublicKey        userPublicKey = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key);

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                knownPublicKeys.AddOrReplace(userPublicKey);
            }

            SharingListViewModel model = await SharingListViewModel.CreateForFilesAsync(new string[0], LogOnIdentity.Empty);

            Assert.That(model.SharedWith.Any(), Is.False, "There are no known public keys, and none are set as shared.");
            Assert.That(model.NotSharedWith.Count(), Is.EqualTo(1), "There is one known public key, so this should be available as unshared.");
        }
        public async Task <UserPublicKey> OtherPublicKeyAsync(EmailAddress email)
        {
            if (Identity.UserEmail == EmailAddress.Empty)
            {
                throw new InvalidOperationException("The account service requires a user.");
            }

            return(await Task.Run(() =>
            {
                using (KnownPublicKeys knowPublicKeys = New <KnownPublicKeys>())
                {
                    UserPublicKey publicKey = knowPublicKeys.PublicKeys.Where(pk => pk.Email == email).FirstOrDefault();
                    return publicKey;
                }
            }).Free());
        }
Example #13
0
        private void ImportFilesAction(IEnumerable <string> files)
        {
            List <string> failed = new List <string>();

            using (KnownPublicKeys knownPublicKeys = _createKnownPublicKeys())
            {
                foreach (string file in files)
                {
                    IDataStore publicKeyData = New <IDataStore>(file);
                    if (!knownPublicKeys.UserImport(publicKeyData))
                    {
                        failed.Add(file);
                    }
                }
            }
            FailedFiles = failed;
        }
        public static async Task <IEnumerable <UserPublicKey> > ToAvailableKnownPublicKeysAsync(this IEnumerable <EmailAddress> emails, LogOnIdentity identity)
        {
            List <UserPublicKey> availablePublicKeys = new List <UserPublicKey>();

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                foreach (EmailAddress email in emails)
                {
                    UserPublicKey key = await knownPublicKeys.GetAsync(email, identity);

                    if (key != null)
                    {
                        availablePublicKeys.Add(key);
                    }
                }
            }
            return(availablePublicKeys);
        }
Example #15
0
        private async Task RemoveKnownContactsActionAsync(IEnumerable <UserPublicKey> knownContactsToRemove)
        {
            if (!knownContactsToRemove.Any())
            {
                return;
            }

            HashSet <UserPublicKey> fromSet = new HashSet <UserPublicKey>(NotSharedWith, UserPublicKey.EmailComparer);
            HashSet <UserPublicKey> toSet   = new HashSet <UserPublicKey>(UserPublicKey.EmailComparer);

            MoveKeyShares(knownContactsToRemove, fromSet, toSet);

            NotSharedWith = fromSet.OrderBy(a => a.Email.Address);

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                knownPublicKeys.Remove(knownContactsToRemove);
            }
        }
        public static async Task <UserPublicKey> GetAsync(this KnownPublicKeys knownPublicKeys, EmailAddress email, LogOnIdentity identity)
        {
            UserPublicKey key = knownPublicKeys.PublicKeys.FirstOrDefault(upk => upk.Email == email);

            if (key != null && New <UserPublicKeyUpdateStatus>().Status(key) == PublicKeyUpdateStatus.RecentlyUpdated)
            {
                return(key);
            }

            if (New <AxCryptOnlineState>().IsOffline)
            {
                return(key);
            }

            if (identity == LogOnIdentity.Empty || identity.UserEmail == EmailAddress.Empty)
            {
                return(key);
            }

            IAccountService accountService = New <LogOnIdentity, IAccountService>(identity);

            if (await accountService.IsAccountSourceLocalAsync())
            {
                return(key);
            }

            if (!New <LicensePolicy>().Capabilities.Has(LicenseCapability.KeySharing) && email != _licenseAuthorityEmail)
            {
                return(key);
            }

            AccountStorage          accountStorage = new AccountStorage(New <LogOnIdentity, IAccountService>(identity));
            CustomMessageParameters invitationMessageParameters = new CustomMessageParameters(new CultureInfo(New <UserSettings>().MessageCulture), New <UserSettings>().CustomInvitationMessage);
            UserPublicKey           userPublicKey = await accountStorage.GetOtherUserInvitePublicKeyAsync(email, invitationMessageParameters).Free();

            if (userPublicKey != null)
            {
                knownPublicKeys.AddOrReplace(userPublicKey);
                New <UserPublicKeyUpdateStatus>().SetStatus(userPublicKey, PublicKeyUpdateStatus.RecentlyUpdated);
            }
            return(userPublicKey);
        }
        public static async Task <IEnumerable <UserPublicKey> > GetKnownPublicKeysAsync(this IEnumerable <UserPublicKey> publicKeys, LogOnIdentity identity)
        {
            List <UserPublicKey> knownKeys = new List <UserPublicKey>();

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                foreach (UserPublicKey publicKey in publicKeys)
                {
                    UserPublicKey key = await knownPublicKeys.GetAsync(publicKey.Email, identity);

                    if (key == null)
                    {
                        knownKeys.Add(publicKey);
                        continue;
                    }

                    knownKeys.Add(key);
                }
            }
            return(knownKeys);
        }
        public void TestCreateSingleKey()
        {
            FakeInMemoryDataStoreItem store = new FakeInMemoryDataStoreItem("KnownPublicKeys.txt");

            IAsymmetricPublicKey key           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey1);
            UserPublicKey        userPublicKey = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key);

            using (KnownPublicKeys knownPublicKeys = KnownPublicKeys.Load(store, Resolve.Serializer))
            {
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(0), "There should be no entries now.");

                knownPublicKeys.AddOrReplace(userPublicKey);
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(1), "There should be one entry now.");
            }

            using (KnownPublicKeys knownPublicKeys = KnownPublicKeys.Load(store, Resolve.Serializer))
            {
                Assert.That(knownPublicKeys.PublicKeys.Count(), Is.EqualTo(1), "There should be one entry now.");

                Assert.That(knownPublicKeys.PublicKeys.First(), Is.EqualTo(userPublicKey), "The instances should compare equal");
            }
        }
        public async Task TestMoveTwoFromUnsharedToShared()
        {
            IAsymmetricPublicKey key1           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey1);
            UserPublicKey        userPublicKey1 = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key1);

            IAsymmetricPublicKey key2           = New <IAsymmetricFactory>().CreatePublicKey(Resources.PublicKey2);
            UserPublicKey        userPublicKey2 = new UserPublicKey(EmailAddress.Parse("*****@*****.**"), key2);

            using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
            {
                knownPublicKeys.AddOrReplace(userPublicKey1);
                knownPublicKeys.AddOrReplace(userPublicKey2);
            }

            SharingListViewModel model = await SharingListViewModel.CreateForFilesAsync(new string[0], LogOnIdentity.Empty);

            Assert.That(model.SharedWith.Any(), Is.False, "There are no known public keys, and none are set as shared.");
            Assert.That(model.NotSharedWith.Count(), Is.EqualTo(2), "There are two known public keys, so they should be available as unshared.");

            await model.AddKeyShares.ExecuteAsync(new[] { userPublicKey2.Email, userPublicKey1.Email, });

            Assert.That(model.SharedWith.Count(), Is.EqualTo(2), "Two were set as shared, so there should be two here now.");
            Assert.That(model.NotSharedWith.Count(), Is.EqualTo(0), "Both unshared were set as shared, so there should be none here now.");
        }
Example #20
0
        private async Task <LogOnIdentity> LogOnActionAsync()
        {
            if (_knownIdentities.IsLoggedOn)
            {
                return(_knownIdentities.DefaultEncryptionIdentity);
            }

            LogOnIdentity logOnIdentity;

            logOnIdentity = await AskForLogOnPassphraseActionAsync(LogOnIdentity.Empty, String.Empty);

            if (logOnIdentity == LogOnIdentity.Empty)
            {
                return(LogOnIdentity.Empty);
            }
            foreach (UserPublicKey userPublicKey in logOnIdentity.PublicKeys)
            {
                using (KnownPublicKeys knownPublicKeys = New <KnownPublicKeys>())
                {
                    knownPublicKeys.AddOrReplace(userPublicKey);
                }
            }
            return(logOnIdentity);
        }
Example #21
0
        public static void AssemblySetup()
        {
            IDataStore knownPublicKeysStore = new FakeInMemoryDataStoreItem("knownpublickeys.txt");

            TypeMap.Register.Singleton <INow>(() => new FakeNow());
            TypeMap.Register.Singleton <IReport>(() => new FakeReport());
            TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory());
            TypeMap.Register.Singleton <WorkFolder>(() => new WorkFolder(Path.GetPathRoot(Environment.CurrentDirectory) + @"WorkFolder\"));
            TypeMap.Register.Singleton <IRuntimeEnvironment>(() => new FakeRuntimeEnvironment());
            TypeMap.Register.Singleton <ILogging>(() => new FakeLogging());
            TypeMap.Register.Singleton <ISettingsStore>(() => new SettingsStore(null));
            TypeMap.Register.Singleton <UserSettingsVersion>(() => new UserSettingsVersion());
            TypeMap.Register.Singleton <UserSettings>(() => (new FakeUserSettings(New <IterationCalculator>())).Initialize());
            TypeMap.Register.Singleton <KnownIdentities>(() => new KnownIdentities(Resolve.FileSystemState, Resolve.SessionNotify));
            TypeMap.Register.Singleton <ProcessState>(() => new ProcessState());
            TypeMap.Register.Singleton <IUIThread>(() => new FakeUIThread());
            TypeMap.Register.Singleton <IProgressBackground>(() => new FakeProgressBackground());
            TypeMap.Register.Singleton <SessionNotify>(() => new SessionNotify());
            TypeMap.Register.Singleton <FileSystemState>(() => FileSystemState.Create(Resolve.WorkFolder.FileInfo.FileItemInfo("FileSystemState.txt")));
            TypeMap.Register.Singleton <IStatusChecker>(() => new FakeStatusChecker());
            TypeMap.Register.Singleton <IRandomGenerator>(() => new FakeRandomGenerator());
            TypeMap.Register.Singleton <CryptoFactory>(() => CreateCryptoFactory());
            TypeMap.Register.Singleton <ActiveFileWatcher>(() => new ActiveFileWatcher());
            TypeMap.Register.Singleton <IAsymmetricFactory>(() => new BouncyCastleAsymmetricFactory());
            TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser());
            TypeMap.Register.Singleton <ICache>(() => new FakeCache());
            TypeMap.Register.Singleton <AxCryptOnlineState>(() => new AxCryptOnlineState());
            TypeMap.Register.Singleton <CryptoPolicy>(() => new CryptoPolicy(new Assembly[0]));
            TypeMap.Register.Singleton <IVersion>(() => new FakeVersion());
            TypeMap.Register.Singleton <IInternetState>(() => new FakeInternetState());
            TypeMap.Register.Singleton <ICryptoPolicy>(() => New <LicensePolicy>().Capabilities.CryptoPolicy);
            TypeMap.Register.Singleton <LicensePolicy>(() => new PremiumForcedLicensePolicy());
            TypeMap.Register.Singleton <InactivitySignOut>(() => new InactivitySignOut(TimeSpan.Zero));
            TypeMap.Register.Singleton <FileLocker>(() => new FileLocker());
            TypeMap.Register.Singleton <FileFilter>(() => new FileFilter());
            TypeMap.Register.Singleton <IVerifySignInPassword>(() => new FakeVerifySignInPassword());
            TypeMap.Register.Singleton <IPopup>(() => new FakePopup());
            TypeMap.Register.Singleton <IKnownFoldersDiscovery>(() => new FakeKnownFoldersDiscovery());
            TypeMap.Register.Singleton <IGlobalNotification>(() => new FakeGlobalNotification());
            TypeMap.Register.Singleton <CanOpenEncryptedFile>(() => new CanOpenEncryptedFile());

            TypeMap.Register.New <AxCryptFactory>(() => new AxCryptFactory());
            TypeMap.Register.New <AxCryptFile>(() => new AxCryptFile());
            TypeMap.Register.New <ActiveFileAction>(() => new ActiveFileAction());
            TypeMap.Register.New <FileOperation>(() => new FileOperation(Resolve.FileSystemState, Resolve.SessionNotify));
            TypeMap.Register.New <IdentityViewModel>(() => new IdentityViewModel(Resolve.FileSystemState, Resolve.KnownIdentities, Resolve.UserSettings, Resolve.SessionNotify));
            TypeMap.Register.New <FileOperationViewModel>(() => new FileOperationViewModel(Resolve.FileSystemState, Resolve.SessionNotify, Resolve.KnownIdentities, Resolve.ParallelFileOperation, New <IStatusChecker>(), New <IdentityViewModel>()));
            TypeMap.Register.New <KnownPublicKeys>(() => KnownPublicKeys.Load(knownPublicKeysStore, New <IStringSerializer>()));
            TypeMap.Register.New <MainViewModel>(() => new MainViewModel(Resolve.FileSystemState, Resolve.UserSettings));
            TypeMap.Register.New <string, IDataStore>((path) => new FakeDataStore(path));
            TypeMap.Register.New <string, IDataContainer>((path) => new FakeDataContainer(path));
            TypeMap.Register.New <string, IDataItem>((path) => CreateDataItem(path));
            TypeMap.Register.New <string, IFileWatcher>((path) => new FakeFileWatcher(path));
            TypeMap.Register.New <IterationCalculator>(() => new FakeIterationCalculator());
            TypeMap.Register.New <IProtectedData>(() => new FakeDataProtection());
            TypeMap.Register.New <IStringSerializer>(() => new StringSerializer(New <IAsymmetricFactory>().GetSerializers()));
            TypeMap.Register.New <LogOnIdentity, IAccountService>((LogOnIdentity identity) => new DeviceAccountService(new LocalAccountService(identity, Resolve.WorkFolder.FileInfo), new NullAccountService(identity)));
            TypeMap.Register.New <ISystemCryptoPolicy>(() => new ProCryptoPolicy());
            TypeMap.Register.New <GlobalApiClient>(() => new GlobalApiClient(Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout));
            TypeMap.Register.New <AxCryptApiClient>(() => new AxCryptApiClient(Resolve.KnownIdentities.DefaultEncryptionIdentity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout));
            TypeMap.Register.New <AxCryptUpdateCheck>(() => new AxCryptUpdateCheck(New <IVersion>().Current));
            TypeMap.Register.New <ISingleThread>(() => new SingleThread());

            Resolve.UserSettings.SetKeyWrapIterations(new V1Aes128CryptoFactory().CryptoId, 1234);
            Resolve.UserSettings.ThumbprintSalt = Salt.Zero;
            Resolve.Log.SetLevel(LogLevel.Debug);
        }