コード例 #1
0
        public static PublishingJobDbContext Publishing(IServiceProvider x, bool beginTrans = true)
        {
            var config  = new StandardEfDbConfig(x.GetRequiredService <IConfiguration>(), DatabaseConnectionStringNames.Publishing);
            var builder = new SqlServerDbContextOptionsBuilder(config, x.GetRequiredService <ILoggerFactory>());
            var result  = new PublishingJobDbContext(builder.Build());

            if (beginTrans)
            {
                result.BeginTransaction();
            }
            return(result);
        }
 public ExposureKeySetBatchJobMk2(/*IExposureKeySetBatchJobConfig jobConfig,*/ IGaenContentConfig gaenContentConfig, IExposureKeySetBuilder builder, WorkflowDbContext workflowDbContext, PublishingJobDbContext publishingDbContext, ContentDbContext contentDbContext, IUtcDateTimeProvider dateTimeProvider, IPublishingId publishingId, ILogger <ExposureKeySetBatchJobMk2> logger)
 {
     //_JobConfig = jobConfig;
     _GaenContentConfig   = gaenContentConfig ?? throw new ArgumentNullException(nameof(gaenContentConfig));
     _SetBuilder          = builder ?? throw new ArgumentNullException(nameof(builder));
     _WorkflowDbContext   = workflowDbContext ?? throw new ArgumentNullException(nameof(workflowDbContext));
     _PublishingDbContext = publishingDbContext ?? throw new ArgumentNullException(nameof(publishingDbContext));
     _ContentDbContext    = contentDbContext ?? throw new ArgumentNullException(nameof(contentDbContext));
     _PublishingId        = publishingId;
     _Logger  = logger ?? throw new ArgumentNullException(nameof(logger));
     _Used    = new List <EksCreateJobInputEntity>(_GaenContentConfig.ExposureKeySetCapacity); //
     _Start   = dateTimeProvider.Now();
     _JobName = $"ExposureKeySetsJob_{_Start:u}".Replace(" ", "_").Replace(":", "_");
 }
コード例 #3
0
 public PublishingJobDatabaseCreateCommand(PublishingJobDbContext dbContextProvider)
 {
     _DbContextProvider = dbContextProvider ?? throw new ArgumentNullException(nameof(dbContextProvider));
 }
コード例 #4
0
        private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
        {
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Workflow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "PublishingJob");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new PublishingJobDbContext(builder.Build());
                return(result);
            });

            services.AddTransient <WorkflowDatabaseCreateCommand>();
            services.AddTransient <PublishingJobDatabaseCreateCommand>();
            services.AddTransient <IccDatabaseCreateCommand>();
            services.AddTransient <ContentDatabaseCreateCommand>();

            services.AddLogging();
            services.AddSingleton <IConfiguration>(configuration);
            services.AddTransient <IJsonSerializer, StandardJsonSerializer>();
            services.AddTransient <ProvisionDatabasesCommand>();
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
            services.AddTransient <IPublishingId, StandardPublishingIdFormatter>();
            services.AddTransient <ContentValidator>();
            services.AddTransient <ContentInsertDbCommand>();
            services.AddTransient <ZippedSignedContentFormatter>();

            if (configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    //AZURE
                    services.AddScoped <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(configuration, "Certificates:NL"))));
                }
                else
                {
                    //UNIT TESTS, LOCAL DEBUG
                    services.AddScoped <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(configuration, "Certificates:NL"))));
                }
            }
            else
            {
                services.AddScoped <IContentSigner>(x => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }
        }
コード例 #5
0
        private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
        {
            var _Configuration = configuration; //Temp hack before extension method.

            services.AddLogging();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "PublishingJob");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new PublishingJobDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(configuration, "Workflow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IConfiguration>(configuration);
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddScoped(x =>
                               new ExposureKeySetBatchJobMk2(
                                   x.GetRequiredService <IGaenContentConfig>(),
                                   x.GetRequiredService <IExposureKeySetBuilder>(),
                                   x.GetRequiredService <WorkflowDbContext>(),
                                   x.GetRequiredService <PublishingJobDbContext>(),
                                   x.GetRequiredService <ContentDbContext>(),
                                   x.GetRequiredService <IUtcDateTimeProvider>(),
                                   x.GetRequiredService <IPublishingId>(),
                                   x.GetRequiredService <ILogger <ExposureKeySetBatchJobMk2> >()
                                   ));

            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
            services.AddScoped <IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();

            if (_Configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (_Configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    //AZURE
                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:GA"))),
                                                                    new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
                else
                {
                    //UNIT TESTS, LOCAL DEBUG
                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"))),
                                                                    new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
            }
            else
            {
                //PROD
                services.AddScoped <IExposureKeySetBuilder>(x =>
                                                            new ExposureKeySetBuilderV1(
                                                                x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                new EcdSaSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                new GeneratedProtobufContentFormatter(),
                                                                x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                ));

                services.AddScoped <IContentSigner>(x => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }
        }
コード例 #6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging();

            services.AddControllers(options =>
            {
                options.RespectBrowserAcceptHeader = true;
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "PublishingJob");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new PublishingJobDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddTransient(x =>
                                  new ExposureKeySetBatchJobMk2(
                                      x.GetService <IGaenContentConfig>(),
                                      x.GetService <IExposureKeySetBuilder>(),
                                      x.GetService <WorkflowDbContext>(),
                                      x.GetService <PublishingJobDbContext>(),
                                      x.GetService <ContentDbContext>(),
                                      x.GetService <IUtcDateTimeProvider>(),
                                      x.GetService <IPublishingId>(),
                                      x.GetService <ILogger <ExposureKeySetBatchJobMk2> >()
                                      ));

            if (_Configuration.GetValue("DevelopmentFlags:UseCertificatesFromResources", false))
            {
                if (_Configuration.GetValue("DevelopmentFlags:Azure", false))
                {
                    //AZURE

                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:GA"))),
                                                                    new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new AzureResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
                else
                {
                    //UNIT TESTS, LOCAL DEBUG

                    services.AddScoped <IExposureKeySetBuilder>(x =>
                                                                new ExposureKeySetBuilderV1(
                                                                    x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                    new EcdSaSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"))),
                                                                    new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"))),
                                                                    x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                    new GeneratedProtobufContentFormatter(),
                                                                    x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                    ));

                    services.AddScoped <IContentSigner>(x => new CmsSigner(new LocalResourceCertificateProvider(new StandardCertificateLocationConfig(_Configuration, "Certificates:NL"))));
                }
            }
            else
            {
                //PROD
                services.AddScoped <IExposureKeySetBuilder>(x =>
                                                            new ExposureKeySetBuilderV1(
                                                                x.GetRequiredService <IExposureKeySetHeaderInfoConfig>(),
                                                                new EcdSaSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:GA"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())),
                                                                x.GetRequiredService <IUtcDateTimeProvider>(), //TODO pass in time thru execute
                                                                new GeneratedProtobufContentFormatter(),
                                                                x.GetRequiredService <ILogger <ExposureKeySetBuilderV1> >()
                                                                ));

                services.AddScoped <IContentSigner>(x => new CmsSigner(new X509CertificateProvider(new CertificateProviderConfig(x.GetRequiredService <IConfiguration>(), "Certificates:NL"), x.GetRequiredService <ILogger <X509CertificateProvider> >())));
            }

            services.AddScoped <IExposureKeySetHeaderInfoConfig, ExposureKeySetHeaderInfoConfig>();
            services.AddScoped <IPublishingId, StandardPublishingIdFormatter>();

            services.AddLogging();
            services.AddSingleton(_Configuration);
            services.AddTransient <ManifestBatchJob>();
            services.AddTransient <ManifestBuilder>();
            services.AddTransient <ManifestBuilderAndFormatter>();
            services.AddTransient <IContentEntityFormatter, StandardContentEntityFormatter>();
            services.AddTransient <ZippedSignedContentFormatter>();
            services.AddSingleton <IGaenContentConfig, StandardGaenContentConfig>();
            services.AddTransient <IJsonSerializer, StandardJsonSerializer>();
            services.AddSingleton(_Configuration);

            services.AddTransient <WorkflowDatabaseCreateCommand>();
            services.AddTransient <PublishingJobDatabaseCreateCommand>();
            services.AddTransient <IccDatabaseCreateCommand>();
            services.AddTransient <ContentDatabaseCreateCommand>();
            services.AddTransient <ProvisionDatabasesCommand>();
            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddTransient <IPublishingId, StandardPublishingIdFormatter>();
            services.AddTransient <ContentValidator>();
            services.AddTransient <ContentInsertDbCommand>();
            services.AddTransient <ZippedSignedContentFormatter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }