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
        }
Exemple #2
0
        public static void RegisterLocalServices()
        {
            if (ServiceContainer.Resolve <INativeLogService>("nativeLogService", true) == null)
            {
                ServiceContainer.Register <INativeLogService>("nativeLogService", new ConsoleLogService());
            }

            ILogger logger = null;

            if (ServiceContainer.Resolve <ILogger>("logger", true) == null)
            {
#if DEBUG
                logger = DebugLogger.Instance;
#else
                logger = Logger.Instance;
#endif
                ServiceContainer.Register("logger", logger);
            }

            var preferencesStorage = new PreferencesStorageService(AppGroupId);
            var appGroupContainer  = new NSFileManager().GetContainerUrl(AppGroupId);
            var liteDbStorage      = new LiteDbStorageService(
                Path.Combine(appGroupContainer.Path, "Library", "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 KeyChainStorageService(AppId, AccessGroup,
                                                                  () => ServiceContainer.Resolve <IAppIdService>("appIdService").GetAppIdAsync());
            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 deviceActionService  = new DeviceActionService(stateService, messagingService);
            var clipboardService     = new ClipboardService(stateService);
            var platformUtilsService = new MobilePlatformUtilsService(deviceActionService, clipboardService,
                                                                      messagingService, broadcasterService);
            var biometricService        = new BiometricService(mobileStorageService);
            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 <IDeviceActionService>("deviceActionService", deviceActionService);
            ServiceContainer.Register <IClipboardService>("clipboardService", clipboardService);
            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);
        }
Exemple #3
0
        public static void RegisterLocalServices()
        {
            if (ServiceContainer.Resolve <ILogService>("logService", true) == null)
            {
                ServiceContainer.Register <ILogService>("logService", new ConsoleLogService());
            }

            var preferencesStorage = new PreferencesStorageService(AppGroupId);
            var appGroupContainer  = new NSFileManager().GetContainerUrl(AppGroupId);
            var liteDbStorage      = new LiteDbStorageService(
                Path.Combine(appGroupContainer.Path, "Library", "bitwarden.db"));
            var localizeService      = new LocalizeService();
            var broadcasterService   = new BroadcasterService();
            var messagingService     = new MobileBroadcasterMessagingService(broadcasterService);
            var i18nService          = new MobileI18nService(localizeService.GetCurrentCultureInfo());
            var secureStorageService = new KeyChainStorageService(AppId, AccessGroup,
                                                                  () => ServiceContainer.Resolve <IAppIdService>("appIdService").GetAppIdAsync());
            var cryptoPrimitiveService = new CryptoPrimitiveService();
            var mobileStorageService   = new MobileStorageService(preferencesStorage, liteDbStorage);
            var deviceActionService    = new DeviceActionService(mobileStorageService, messagingService);
            var platformUtilsService   = new MobilePlatformUtilsService(deviceActionService, messagingService,
                                                                        broadcasterService);
            var biometricService = new BiometricService(mobileStorageService);

            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);
        }
Exemple #4
0
        public BiometricsController()
        {
            var sqlConnStr = ConfigurationManager.AppSettings["SQLConnStr"];

            _biometrics = new BiometricService(sqlConnStr);
        }
Exemple #5
0
        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
        }