static void InitServiceContainer() { var localizeService = new LocalizeService(); var i18nService = new CliI18nService(localizeService.GetCurrentCultureInfo()); ServiceContainer.Register <ILocalizeService>(nameof(localizeService), localizeService); ServiceContainer.Register <II18nService>(nameof(i18nService), i18nService); var broadcasterService = new BroadcasterService(); var messagingService = new CliBroadcasterMessagingService(broadcasterService); ServiceContainer.Register <IBroadcasterService>(nameof(broadcasterService), broadcasterService); ServiceContainer.Register <IMessagingService> (nameof(messagingService), messagingService); var platformUtilsService = new PlatformUtilsService(IdentityClientId); ServiceContainer.Register <IPlatformUtilsService>(nameof(platformUtilsService), platformUtilsService); //var storageService = new LiteDbStorageService("bwcli.db"); var storageService = new InsecureStorageService(); ServiceContainer.Register <IStorageService>(nameof(storageService), storageService); var secureStorageService = new SecureStorageService(); ServiceContainer.Register <IStorageService>(nameof(secureStorageService), secureStorageService); var cryptoPrimitiveService = new CryptoPrimitiveService(); ServiceContainer.Register <ICryptoPrimitiveService>(nameof(cryptoPrimitiveService), cryptoPrimitiveService); ServiceContainer.Init(CustomUserAgent); }
private void RegisterLocalServices() { ServiceContainer.Register <ILogService>("logService", new AndroidLogService()); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); var biometricService = new BiometricService(); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
private async Task <AuthorizedToken> GetTokenAsync() { SecureStorageService secureStorageService = new SecureStorageService(); AuthorizedToken response = await secureStorageService.GetAsync <AuthorizedToken>(Enums.SecureStorageKey.AuthorizedToken); return(response); }
public static async Task <KidDetail> GetKidDetailsFromStorage(int kidId) { SecureStorageService secureStorageService = new SecureStorageService(); Parent userInfo = await secureStorageService.GetAsync <Parent>(Enums.SecureStorageKey.AuthorizedUserInfo); KidDetail kidDetail = userInfo.kids.Where(x => x.Id == kidId).FirstOrDefault(); return(kidDetail); }
private void RegisterLocalServices() { Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init(); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); // Push #if FDROID container.RegisterSingleton <IPushNotificationListener, NoopPushNotificationListener>(); container.RegisterSingleton <IPushNotificationService, NoopPushNotificationService>(); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
public void KeyExists_CheckExsitingForExistedKey_KeyExistedInStore() { var secureStorageMock = new SecureStorageMock(); var secureStorageService = new SecureStorageService(); secureStorageService.SetSecureStorageInstance(secureStorageMock); var key = "testKeyExists_Key"; var value = "testKeyExists_Value"; secureStorageMock.SetValue(key, value); var existed = secureStorageService.KeyExists(key); existed.Should().BeTrue(); }
public void GetValue_GetExistedValueWithCorrectKey_ReturnCorrectValue() { var secureStorageMock = new SecureStorageMock(); var secureStorageService = new SecureStorageService(); secureStorageService.SetSecureStorageInstance(secureStorageMock); var key = "testGetValue_Key"; var value = "testGetValue_Value"; secureStorageMock.SetValue(key, value); var existedValue = secureStorageService.GetValue(key); bool isSameValue = value.Equals(existedValue); isSameValue.Should().BeTrue(); }
public void SaveValue_SetValueSecureStore_ValueSaved() { var secureStorageMock = new SecureStorageMock(); var secureStorageService = new SecureStorageService(); secureStorageService.SetSecureStorageInstance(secureStorageMock); var key = "testSaveValue_Key"; var value = "testSaveValue_Value"; secureStorageService.SaveValue(key, value); var savedValue = secureStorageMock.GetValue(key); bool isSameValue = value.Equals(savedValue); isSameValue.Should().BeTrue(); }
public void Delete_DeleteExistedKeyValuePair_KeyValuePairDeleted() { var secureStorageMock = new SecureStorageMock(); var secureStorageService = new SecureStorageService(); secureStorageService.SetSecureStorageInstance(secureStorageMock); var key = "testDelete_Key"; var value = "testDelete_Value"; secureStorageMock.SetValue(key, value); var added = secureStorageMock.HasKey(key); secureStorageService.Delete(key); var deleted = !secureStorageMock.HasKey(key); (added && deleted).Should().BeTrue(); }
private void RegisterLocalServices() { ServiceContainer.Register <INativeLogService>("nativeLogService", new AndroidLogService()); #if FDROID var logger = new StubLogger(); #elif DEBUG var logger = DebugLogger.Instance; #else var logger = Logger.Instance; #endif ServiceContainer.Register("logger", logger); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false, HttpClient = new HttpClient(new AndroidClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }) }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(logger); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var stateService = new StateService(mobileStorageService, secureStorageService, messagingService); var stateMigrationService = new StateMigrationService(liteDbStorage, preferencesStorage, secureStorageService); var clipboardService = new ClipboardService(stateService); var deviceActionService = new DeviceActionService(clipboardService, stateService, messagingService, broadcasterService, () => ServiceContainer.Resolve <IEventService>("eventService")); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService, messagingService, broadcasterService); var biometricService = new BiometricService(); var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService); var cryptoService = new CryptoService(stateService, cryptoFunctionService); var passwordRepromptService = new MobilePasswordRepromptService(platformUtilsService, cryptoService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IStateService>("stateService", stateService); ServiceContainer.Register <IStateMigrationService>("stateMigrationService", stateMigrationService); ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); ServiceContainer.Register <IBiometricService>("biometricService", biometricService); ServiceContainer.Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService); ServiceContainer.Register <ICryptoService>("cryptoService", cryptoService); ServiceContainer.Register <IPasswordRepromptService>("passwordRepromptService", passwordRepromptService); ServiceContainer.Register <IAvatarImageSourcePool>("avatarImageSourcePool", new AvatarImageSourcePool()); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( stateService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }
public ExposureDetectedTests() { DependencyInjectionConfig.Init(); Preferences.Clear(); SecureStorageService.SetSecureStorageInstance(new SecureStorageMock()); }
private void SeedTestData() { var dogsRepository = Container.Resolve <IRepository <Dog> >(); dogsRepository.DeleteAll(); // **** CLEAN BD **** // Les données seront ajoutées une seul foi dans la BD. if (dogsRepository.GetAll().Count() != 0) { return; } var dog1 = new Dog() { Name = UiText.ANY_DOG_NAME, ImageUrl = UiText.ANY_DOG_IMAGE_URL, Price = UiText.ANY_DOG_PRICE, Race = UiText.ANY_DOG_RACE, Sex = UiText.ANY_DOG_SEX, Description = UiText.ANY_DOG_DESCRIPTION }; var dog2 = new Dog() { Name = "Cloud", ImageUrl = "https://images.dog.ceo/breeds/shiba/shiba-11.jpg", Price = (float)399.99, Race = "Samoyede", Sex = "Male", Description = "13 mois, chien blanc" }; var dog3 = new Dog() { Name = "Leo", ImageUrl = "https://images.dog.ceo/breeds/pug/n02110958_1975.jpg", Price = (float)269.99, Race = "Husky", Sex = "Male", Description = "Gentil et calme" }; dogsRepository.Add(dog1); dogsRepository.Add(dog2); dogsRepository.Add(dog3); var usersRepository = Container.Resolve <IRepository <User> >(); usersRepository.DeleteAll(); // **** CLEAN BD **** // Les données seront ajoutées une seul foi dans la BD. if (usersRepository.GetAll().Count() != 0) { return; } ICryptoService cryptoService = new CryptoService(); ISecureStorageService secureStorageService = new SecureStorageService(); string salt = cryptoService.GenerateSalt(); string key = cryptoService.GenerateEncryptionKey(); var user1 = new User() { Login = "******", HashedPassword = cryptoService.HashSHA512("456", salt), PasswordSalt = salt, CreditCard = cryptoService.Encrypt("1234", key), DogId = dog1.Id }; secureStorageService.SetUserEncryptionKeyAsync(user1, key); usersRepository.Add(user1); // après le add, user1 contient un id salt = cryptoService.GenerateSalt(); key = cryptoService.GenerateEncryptionKey(); var user2 = new User() { Login = "******", HashedPassword = cryptoService.HashSHA512("789", salt), PasswordSalt = salt, CreditCard = cryptoService.Encrypt("1234", key), DogId = -1 }; secureStorageService.SetUserEncryptionKeyAsync(user2, key); usersRepository.Add(user2); }
private void RegisterLocalServices() { ServiceContainer.Register <ILogService>("logService", new AndroidLogService()); ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim()); if (App.Migration.MigrationHelpers.NeedsMigration()) { ServiceContainer.Register <App.Migration.Abstractions.IOldSecureStorageService>( "oldSecureStorageService", new Migration.AndroidKeyStoreStorageService()); } Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init(); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); ZXing.Net.Mobile.Forms.Android.Platform.Init(); }); CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity); CrossFingerprint.SetDialogFragmentType <CustomFingerprintDialogFragment>(); var preferencesStorage = new PreferencesStorageService(null); var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var liteDbStorage = new LiteDbStorageService(Path.Combine(documentsPath, "bitwarden.db")); liteDbStorage.InitAsync(); var localizeService = new LocalizeService(); var broadcasterService = new BroadcasterService(); var messagingService = new MobileBroadcasterMessagingService(broadcasterService); var i18nService = new MobileI18nService(localizeService.GetCurrentCultureInfo()); var secureStorageService = new SecureStorageService(); var cryptoPrimitiveService = new CryptoPrimitiveService(); var mobileStorageService = new MobileStorageService(preferencesStorage, liteDbStorage); var deviceActionService = new DeviceActionService(mobileStorageService, messagingService, broadcasterService); var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, messagingService, broadcasterService); ServiceContainer.Register <IBroadcasterService>("broadcasterService", broadcasterService); ServiceContainer.Register <IMessagingService>("messagingService", messagingService); ServiceContainer.Register <ILocalizeService>("localizeService", localizeService); ServiceContainer.Register <II18nService>("i18nService", i18nService); ServiceContainer.Register <ICryptoPrimitiveService>("cryptoPrimitiveService", cryptoPrimitiveService); ServiceContainer.Register <IStorageService>("storageService", mobileStorageService); ServiceContainer.Register <IStorageService>("secureStorageService", secureStorageService); ServiceContainer.Register <IDeviceActionService>("deviceActionService", deviceActionService); ServiceContainer.Register <IPlatformUtilsService>("platformUtilsService", platformUtilsService); // Push #if FDROID ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", new NoopPushNotificationListenerService()); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", new NoopPushNotificationService()); #else var notificationListenerService = new PushNotificationListenerService(); ServiceContainer.Register <IPushNotificationListenerService>( "pushNotificationListenerService", notificationListenerService); var androidPushNotificationService = new AndroidPushNotificationService( mobileStorageService, notificationListenerService); ServiceContainer.Register <IPushNotificationService>( "pushNotificationService", androidPushNotificationService); #endif }