Search in sources :

Example 1 with ConfigDataBootstrap

use of uk.gov.ida.hub.config.data.ConfigDataBootstrap in project verify-hub by alphagov.

the class ConfigValidCommand method run.

@Override
public void run(Bootstrap<ConfigConfiguration> bootstrap, Namespace namespace, ConfigConfiguration configuration) throws Exception {
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfigEntityData>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfigEntityData>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfigEntityData>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigurationFactoryFactory<CountriesConfigEntityData>>() {
            }).toInstance(new DefaultConfigurationFactoryFactory<>());
            bind(new TypeLiteral<ConfigDataSource<TransactionConfigEntityData>>() {
            }).to(FileBackedTransactionConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigDataSource<MatchingServiceConfigEntityData>>() {
            }).to(FileBackedMatchingServiceConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigDataSource<IdentityProviderConfigEntityData>>() {
            }).to(FileBackedIdentityProviderConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigDataSource<CountriesConfigEntityData>>() {
            }).to(FileBackedCountriesConfigDataSource.class).asEagerSingleton();
            bind(new TypeLiteral<ConfigEntityDataRepository<TransactionConfigEntityData>>() {
            }).asEagerSingleton();
            bind(new TypeLiteral<ConfigEntityDataRepository<CountriesConfigEntityData>>() {
            }).asEagerSingleton();
            bind(new TypeLiteral<ConfigEntityDataRepository<MatchingServiceConfigEntityData>>() {
            }).asEagerSingleton();
            bind(new TypeLiteral<ConfigEntityDataRepository<IdentityProviderConfigEntityData>>() {
            }).asEagerSingleton();
            bind(ConfigConfiguration.class).toInstance(configuration);
            bind(LevelsOfAssuranceConfigValidator.class).toInstance(new LevelsOfAssuranceConfigValidator());
            bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
            bind(TrustStoreForCertificateProvider.class);
            bind(CertificateChainConfigValidator.class).annotatedWith(CertificateConfigValidator.class).to(ThrowingCertificateChainConfigValidator.class);
        }
    });
    ConfigDataBootstrap checkConfigValid = injector.getInstance(ConfigDataBootstrap.class);
    try {
        checkConfigValid.start();
    } catch (ConfigValidationException e) {
        LOG.info(e.getMessage());
        throw e;
    }
}
Also used : TrustStoreForCertificateProvider(uk.gov.ida.hub.config.truststore.TrustStoreForCertificateProvider) ConfigEntityDataRepository(uk.gov.ida.hub.config.data.ConfigEntityDataRepository) DefaultConfigurationFactoryFactory(io.dropwizard.configuration.DefaultConfigurationFactoryFactory) ConfigurationFactoryFactory(io.dropwizard.configuration.ConfigurationFactoryFactory) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) LevelsOfAssuranceConfigValidator(uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator) CertificateChainConfigValidator(uk.gov.ida.hub.config.domain.CertificateChainConfigValidator) ThrowingCertificateChainConfigValidator(uk.gov.ida.hub.config.domain.ThrowingCertificateChainConfigValidator) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) ThrowingCertificateChainConfigValidator(uk.gov.ida.hub.config.domain.ThrowingCertificateChainConfigValidator) AbstractModule(com.google.inject.AbstractModule) DefaultConfigurationFactoryFactory(io.dropwizard.configuration.DefaultConfigurationFactoryFactory) ConfigDataBootstrap(uk.gov.ida.hub.config.data.ConfigDataBootstrap)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 TypeLiteral (com.google.inject.TypeLiteral)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)1 ConfigEntityDataRepository (uk.gov.ida.hub.config.data.ConfigEntityDataRepository)1 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)1 CertificateChainConfigValidator (uk.gov.ida.hub.config.domain.CertificateChainConfigValidator)1 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)1 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)1 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)1 ThrowingCertificateChainConfigValidator (uk.gov.ida.hub.config.domain.ThrowingCertificateChainConfigValidator)1 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)1 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)1 TrustStoreForCertificateProvider (uk.gov.ida.hub.config.truststore.TrustStoreForCertificateProvider)1