Example #1
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddCors();

            var container = new WindsorContainer();

            var componentContainer = new WindsorComponentContainer(container);

            componentContainer.RegisterInstance <IAccessConfiguration>(AccessSection.Configuration());

            componentContainer.RegisterSuffixed("Shuttle.Sentinel");
            componentContainer.RegisterSuffixed("Shuttle.Access.Sql");

            componentContainer.Register <IInspectionQueue, DefaultInspectionQueue>();
            componentContainer.Register <IHttpContextAccessor, HttpContextAccessor>();
            componentContainer.Register <IDatabaseContextCache, ContextDatabaseContextCache>();

            ServiceBus.Register(componentContainer);
            EventStore.Register(componentContainer);

            componentContainer.Resolve <IDataStoreDatabaseContextFactory>().ConfigureWith("Sentinel");
            componentContainer.Resolve <IDatabaseContextFactory>().ConfigureWith("Sentinel");
            var inspectionQueue = componentContainer.Resolve <IInspectionQueue>();

            _bus = ServiceBus.Create(componentContainer).Start();

            return(WindsorRegistrationHelper.CreateServiceProvider(container, services));
        }
Example #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IWindsorContainer>(new WindsorContainer());
            services.AddSingleton <IControllerActivator, ControllerActivator>();

            services.AddSingleton(AccessSection.Configuration());
            services.AddSingleton(SentinelSection.Configuration());
            services.AddSingleton <IDbProviderFactories, DbProviderFactories>();
            services.AddSingleton <IConnectionConfigurationProvider, ConnectionConfigurationProvider>();
            services.AddSingleton <IDatabaseContextCache, ContextDatabaseContextCache>();
            services.AddSingleton <IDatabaseContextFactory, DatabaseContextFactory>();
            services.AddSingleton <IDatabaseGateway, DatabaseGateway>();
            services.AddSingleton <IDbConnectionFactory, DbConnectionFactory>();
            services.AddSingleton <IDbCommandFactory, DbCommandFactory>();
            services.AddSingleton <IQueryMapper, QueryMapper>();
            services.AddSingleton <ISessionQueryFactory, SessionQueryFactory>();
            services.AddSingleton <ISessionQuery, SessionQuery>();

            services.AddMvc();
            services.AddCors();
        }
Example #3
0
        public static void UpdateSettings(dynamic model, Site site, string path, string configScope = null)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            AccessSection section = GetAccessSection(site, path, configScope);

            int newFlags = (int)section.SslFlags;

            bool?requireSsl = DynamicHelper.To <bool>(model.require_ssl);

            if (requireSsl != null)
            {
                if (requireSsl.Value)
                {
                    SetFlag(ref newFlags, (int)HttpAccessSslFlags.Ssl);
                }
                else
                {
                    ClearFlag(ref newFlags, (int)HttpAccessSslFlags.Ssl);
                    ClearFlag(ref newFlags, (int)HttpAccessSslFlags.Ssl128);
                }
            }

            ClientCertificateSettings?certSettings = DynamicHelper.To <ClientCertificateSettings>(model.client_certificates);

            if (certSettings != null)
            {
                // Client certificate settings
                switch (certSettings.Value)
                {
                case ClientCertificateSettings.ACCEPT:
                    SetFlag(ref newFlags, (int)HttpAccessSslFlags.SslNegotiateCert);
                    ClearFlag(ref newFlags, (int)HttpAccessSslFlags.SslRequireCert);
                    break;

                case ClientCertificateSettings.IGNORE:
                    ClearFlag(ref newFlags, (int)HttpAccessSslFlags.SslNegotiateCert);
                    ClearFlag(ref newFlags, (int)HttpAccessSslFlags.SslRequireCert);
                    break;

                case ClientCertificateSettings.REQUIRE:
                    SetFlag(ref newFlags, (int)HttpAccessSslFlags.SslNegotiateCert);
                    SetFlag(ref newFlags, (int)HttpAccessSslFlags.SslRequireCert);
                    break;

                default:
                    break;
                }
            }

            try {
                if (model.metadata != null)
                {
                    DynamicHelper.If <OverrideMode>((object)model.metadata.override_mode, v => {
                        section.OverrideMode = v;
                    });
                }

                section.SslFlags = (HttpAccessSslFlags)newFlags;
            }
            catch (FileLoadException e) {
                throw new LockedException(section.SectionPath, e);
            }
            catch (DirectoryNotFoundException e) {
                throw new ConfigScopeNotFoundException(e);
            }
        }