예제 #1
0
        private static IServiceCollection AddAPIConfiguration(this IServiceCollection services,
                                                              IConfiguration configuration)
        {
            var appsettingsConfig = configuration.GetSection("AppSettings").Get <AppSettingsConfig>();

            ModelValidator.ValidateContract(appsettingsConfig);

            var logValidationRulesConfig = configuration.GetSection("LogValidationRules").Get <LogValidationRulesConfig>();

            ModelValidator.ValidateContract(logValidationRulesConfig);

            var keyValidationRulesConfig = configuration.GetSection("KeyValidationRules").Get <KeyValidationConfiguration>();

            ModelValidator.ValidateContract(logValidationRulesConfig);

            services.AddSingleton(appsettingsConfig);
            services.AddSingleton <IOriginSpecificSettings>(appsettingsConfig);
            services.AddSingleton <IZipPackageBuilderConfig>(appsettingsConfig);
            services.AddSingleton(logValidationRulesConfig);
            services.AddSingleton(keyValidationRulesConfig);

            var jwtAuthorizationConfig = configuration.GetSection(nameof(JwtAuthorization)).Get <JwtAuthorization>();

            ModelValidator.ValidateContract(jwtAuthorizationConfig);
            services.AddSingleton(jwtAuthorizationConfig);

            services.AddSingleton(configuration);

            return(services);
        }
        public GatewayUploadState GetGatewayUploadState()
        {
            var dto = _syncStateDao.GetUploadState();

            ModelValidator.ValidateContract(dto);
            return(dto);
        }
        public static IServiceCollection AddJobsDependencies(this IServiceCollection services, IConfiguration configuration)
        {
            var hangfireConfig = configuration.Get <HangfireConfig>();

            ModelValidator.ValidateContract(hangfireConfig);
            var gateWayConfig  = hangfireConfig.EuGateway;
            var eventLogConfig = hangfireConfig.Logging.EventLog;

            services.Configure <EventLogSettings>(config =>
            {
                config.SourceName  = eventLogConfig.SourceName;
                config.LogName     = eventLogConfig.LogName;
                config.MachineName = eventLogConfig.MachineName;
            });
            services.AddSingleton(gateWayConfig);
            services.AddSingleton(hangfireConfig.Jobs.UploadKeysToTheGateway);
            services.AddSingleton(hangfireConfig.Jobs.DownloadKeysFromTheGateway);

            services.AddHangfire(x => x.UseSqlServerStorage(hangfireConfig.HangFireConnectionString));
            services.AddDbContext <DigNDB_SmittestopContext>(opts =>
                                                             opts.UseSqlServer(hangfireConfig.SmittestopConnectionString));

            services.AddControllers().AddControllersAsServices();
            services.AddLogging();
            services.AddAutoMapper(Assembly.GetExecutingAssembly());
            services.AddAutoMapper(typeof(CountryMapper));

            services.AddScoped <IDatabaseKeysValidationService, DatabaseKeysValidationService>();
            services.AddScoped <IZipFileService, ZipFileService>();
            services.AddScoped <ISettingsService, SettingsService>();

            services.AddSingleton(hangfireConfig);
            services.AddSingleton <IOriginSpecificSettings>(hangfireConfig);
            services.AddSingleton <IZipPackageBuilderConfig>(hangfireConfig);
            services.AddScoped <IZipFileService, ZipFileService>();

            services.AddScoped <IGatewayHttpClient, GatewayHttpClient>();
            services.AddScoped <ITemporaryExposureKeyRepository, TemporaryExposureKeyRepository>();
            services.AddScoped <ISignatureService, SignatureService>();
            services.AddScoped <IEncodingService, EncodingService>();
            services.AddScoped <IGatewayWebContextReader, GatewayWebContextReader>();
            services.AddScoped <IEpochConverter, EpochConverter>();
            services.AddScoped <IEFGSKeyStoreService, EFGSKeyStoreService>();
            services.AddScoped <IGatewayKeyProvider, GatewayKeyProvider>();
            services.AddScoped <IRiskCalculator, RiskCalculator>();
            services.AddScoped <IDaysSinceOnsetOfSymptomsDecoder, DaysSinceOnsetOfSymptomsDecoder>();
            services.AddScoped <IKeyFilter, KeyFilter>();
            services.AddScoped <IGatewaySyncStateSettingsDao, GatewaySyncStateSettingsDao>();
            services.AddScoped <IEuGatewayService, EuGatewayService>();
            services.AddSingleton <IGatewayKeyProvider>(
                new GatewayKeyProvider(gateWayConfig.AuthenticationCertificateFingerprint, gateWayConfig.SigningCertificateFingerprint));


            return(services);
        }
        public ExposureConfigurationService(IConfiguration configuration)
        {
            _exposureConfiguration = RetrieveExposureConfigurationFromConfig(configuration.GetSection("ExposureConfig"));
            ModelValidator.ValidateContract(_exposureConfiguration);

            _exposureConfigurationV1_2 = new ExposureConfigurationV1_2()
            {
                Configuration            = RetrieveExposureConfigurationFromConfig(configuration.GetSection("ExposureConfigV1_2")),
                AttenuationBucketsParams = RetrieveAttentuationBucketsParametersFromConfig(configuration.GetSection("AttenuationBucketsParams"))
            };
            ModelValidator.ValidateContract(_exposureConfigurationV1_2);
        }
예제 #5
0
        private void RegisterConfigurationDtos(IServiceCollection services)
        {
            var appsettingsConfig = Configuration.GetSection("AppSettings").Get <AppSettingsConfig>();

            ModelValidator.ValidateContract(appsettingsConfig);
            services.AddSingleton(appsettingsConfig);
            services.AddSingleton <IOriginSpecificSettings>(appsettingsConfig);
            services.AddSingleton <IZipPackageBuilderConfig>(appsettingsConfig);

            var logValidationRulesConfig = Configuration.GetSection("LogValidationRules").Get <LogValidationRulesConfig>();

            ModelValidator.ValidateContract(logValidationRulesConfig);
            services.AddSingleton(logValidationRulesConfig);

            var keyValidationRulesConfig = Configuration.GetSection("KeyValidationRules").Get <KeyValidationConfiguration>();

            ModelValidator.ValidateContract(keyValidationRulesConfig);
            services.AddSingleton(keyValidationRulesConfig);

            services.AddSingleton <IExposureConfigurationService>(new ExposureConfigurationService(Configuration));
        }
예제 #6
0
        public static IServiceCollection AddJobsDependencies(this IServiceCollection services, IConfiguration configuration)
        {
            var hangfireConfig = configuration.Get <HangfireConfig>();

            ModelValidator.ValidateContract(hangfireConfig);
            var gateWayConfig  = hangfireConfig.EuGateway;
            var eventLogConfig = hangfireConfig.Logging.EventLog;

            services.Configure <EventLogSettings>(config =>
            {
                config.SourceName  = eventLogConfig.SourceName;
                config.LogName     = eventLogConfig.LogName;
                config.MachineName = eventLogConfig.MachineName;
            });
            services.AddSingleton(gateWayConfig);

            services.AddHangfire(x => x.UseSqlServerStorage(hangfireConfig.HangFireConnectionString));
            services.AddDbContext <DigNDB_SmittestopContext>(opts =>
                                                             opts.UseSqlServer(hangfireConfig.SmittestopConnectionString));

            services.AddControllers().AddControllersAsServices();
            services.AddLogging();
            services.AddAutoMapper(Assembly.GetExecutingAssembly());
            services.AddAutoMapper(typeof(CountryMapper));

            services.AddScoped <IDatabaseKeysValidationService, DatabaseKeysValidationService>();
            services.AddScoped <IZipFileService, ZipFileService>();

            services.AddSingleton(hangfireConfig);
            services.AddSingleton <IOriginSpecificSettings>(hangfireConfig);
            services.AddSingleton <IZipPackageBuilderConfig>(hangfireConfig);



            return(services);
        }
        public static IServiceCollection AddJobsDependencies(this IServiceCollection services, IConfiguration configuration)
        {
            var hangfireConfig = configuration.Get <HangfireConfig>();

            ModelValidator.ValidateContract(hangfireConfig);
            var gateWayConfig  = hangfireConfig.EuGateway;
            var eventLogConfig = hangfireConfig.Logging.EventLog;

            services.Configure <EventLogSettings>(config =>
            {
                config.SourceName  = eventLogConfig.SourceName;
                config.LogName     = eventLogConfig.LogName;
                config.MachineName = eventLogConfig.MachineName;
            });
            services.AddSingleton(gateWayConfig);
            services.AddSingleton(hangfireConfig.Jobs.UploadKeysToTheGateway);

            services.AddSingleton <IGatewayKeyProvider>(
                new GatewayKeyProvider(gateWayConfig.AuthenticationCertificateFingerprint, gateWayConfig.SigningCertificateFingerprint));

            services.AddHangfire(x => x.UseSqlServerStorage(hangfireConfig.HangFireConnectionString));
            services.AddDbContext <DigNDB_SmittestopContext>(opts =>
                                                             opts.UseSqlServer(hangfireConfig.SmittestopConnectionString));

            services.AddControllers().AddControllersAsServices();
            services.AddLogging();
            services.AddAutoMapper(Assembly.GetExecutingAssembly());
            services.AddAutoMapper(typeof(CountryMapper));

            services.AddScoped <IGatewayWebContextReader, GatewayWebContextReader>();
            services.AddScoped <ISettingsService, SettingsService>();
            services.AddScoped <IDatabaseKeysValidationService, DatabaseKeysValidationService>();
            services.AddScoped <IZipFileService, ZipFileService>();

            return(services);
        }
 public void SaveGatewaySyncState(GatewayDownloadState lastSyncState)
 {
     ModelValidator.ValidateContract(lastSyncState);
     _syncStateDao.Save(lastSyncState);
 }