Search in sources :

Example 6 with CountriesConfigEntityData

use of uk.gov.ida.hub.config.domain.CountriesConfigEntityData in project verify-hub by alphagov.

the class CountriesResourceIntegrationTest method getShouldReturnCountriesForEidas.

@Test
public void getShouldReturnCountriesForEidas() {
    URI uri = configAppRule.getUri(Urls.ConfigUrls.COUNTRIES_ROOT).build();
    Response response = client.target(uri).request().get();
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    Collection<CountriesConfigEntityData> result = response.readEntity(new GenericType<Collection<CountriesConfigEntityData>>() {
    });
    assertNotNull(result);
    assertThat(result.size()).isGreaterThan(0);
    CountriesConfigEntityData countryConfigEntityData = result.stream().filter(countriesConfigEntityData -> countriesConfigEntityData.getSimpleId().equals(COUNTRY_ID)).findAny().get();
    assertThat(countryConfigEntityData.getEntityId()).isEqualTo(COUNTRY_ID);
    assertThat(countryConfigEntityData.getOverriddenSsoUrl()).isEqualTo(SSO_URL);
}
Also used : Response(javax.ws.rs.core.Response) Collection(java.util.Collection) CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) CountriesConfigEntityDataBuilder.aCountriesConfigEntityData(uk.gov.ida.hub.config.domain.builders.CountriesConfigEntityDataBuilder.aCountriesConfigEntityData) URI(java.net.URI) Test(org.junit.Test)

Example 7 with CountriesConfigEntityData

use of uk.gov.ida.hub.config.domain.CountriesConfigEntityData in project verify-hub by alphagov.

the class ConfigModule method configure.

@Override
protected void configure() {
    bind(ConfigHealthCheck.class).asEagerSingleton();
    bind(ConfigDataBootstrap.class).asEagerSingleton();
    bind(CertificateChainConfigValidator.class).annotatedWith(CertificateConfigValidator.class).to(LoggingCertificateChainConfigValidator.class);
    bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
    bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfigEntityData>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<IdentityProviderConfigEntityData>());
    bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfigEntityData>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<TransactionConfigEntityData>());
    bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfigEntityData>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<MatchingServiceConfigEntityData>());
    bind(new TypeLiteral<ConfigurationFactoryFactory<CountriesConfigEntityData>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<CountriesConfigEntityData>());
    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(ObjectMapper.class).toInstance(new ObjectMapper().registerModule(new GuavaModule()));
    bind(LevelsOfAssuranceConfigValidator.class).toInstance(new LevelsOfAssuranceConfigValidator());
    bind(CertificateChainValidator.class);
    bind(TrustStoreForCertificateProvider.class);
    bind(X509CertificateFactory.class).toInstance(new X509CertificateFactory());
    bind(KeyStoreCache.class);
    bind(ExceptionFactory.class);
    bind(OCSPCertificateChainValidityChecker.class);
    bind(EntityConfigDataToCertificateDtoTransformer.class);
    bind(OCSPCertificateChainValidator.class);
    bind(IdpPredicateFactory.class);
    bind(KeyStoreLoader.class).toInstance(new KeyStoreLoader());
    bind(OCSPPKIXParametersProvider.class).toInstance(new OCSPPKIXParametersProvider());
    bind(PKIXParametersProvider.class).toInstance(new PKIXParametersProvider());
    bind(CertificateService.class);
}
Also used : TrustStoreConfiguration(uk.gov.ida.truststore.TrustStoreConfiguration) KeyStoreLoader(uk.gov.ida.truststore.KeyStoreLoader) FileBackedIdentityProviderConfigDataSource(uk.gov.ida.hub.config.data.FileBackedIdentityProviderConfigDataSource) TypeLiteral(com.google.inject.TypeLiteral) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LevelsOfAssuranceConfigValidator(uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) FileBackedCountriesConfigDataSource(uk.gov.ida.hub.config.data.FileBackedCountriesConfigDataSource) OCSPPKIXParametersProvider(uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider) CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) OCSPPKIXParametersProvider(uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider) PKIXParametersProvider(uk.gov.ida.common.shared.security.verification.PKIXParametersProvider) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule) X509CertificateFactory(uk.gov.ida.common.shared.security.X509CertificateFactory) CertificateConfigValidator(uk.gov.ida.hub.config.annotations.CertificateConfigValidator) FileBackedTransactionConfigDataSource(uk.gov.ida.hub.config.data.FileBackedTransactionConfigDataSource) FileBackedMatchingServiceConfigDataSource(uk.gov.ida.hub.config.data.FileBackedMatchingServiceConfigDataSource) ConfigDataBootstrap(uk.gov.ida.hub.config.data.ConfigDataBootstrap) FileBackedCountriesConfigDataSource(uk.gov.ida.hub.config.data.FileBackedCountriesConfigDataSource) FileBackedMatchingServiceConfigDataSource(uk.gov.ida.hub.config.data.FileBackedMatchingServiceConfigDataSource) ConfigDataSource(uk.gov.ida.hub.config.data.ConfigDataSource) FileBackedTransactionConfigDataSource(uk.gov.ida.hub.config.data.FileBackedTransactionConfigDataSource) FileBackedIdentityProviderConfigDataSource(uk.gov.ida.hub.config.data.FileBackedIdentityProviderConfigDataSource) ConfigHealthCheck(uk.gov.ida.hub.config.healthcheck.ConfigHealthCheck)

Example 8 with CountriesConfigEntityData

use of uk.gov.ida.hub.config.domain.CountriesConfigEntityData 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

CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)8 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)7 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)7 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)6 Test (org.junit.Test)5 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)4 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)4 TypeLiteral (com.google.inject.TypeLiteral)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1 URI (java.net.URI)1 Collection (java.util.Collection)1 Response (javax.ws.rs.core.Response)1 Ignore (org.junit.Ignore)1