Search in sources :

Example 11 with MatchingServiceConfigEntityData

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

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenDuplicateEntityIdsExist.

@Test
public void start_shouldThrowExceptionWhenDuplicateEntityIdsExist() throws Exception {
    final String entityId = "entity-id";
    final String matchingServiceEntityId = "matching-service-entity-id";
    final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(entityId).build();
    final TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withEntityId(entityId).withMatchingServiceEntityId(matchingServiceEntityId).build();
    final MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build();
    final CountriesConfigEntityData countriesConfigEntityData = new CountriesConfigEntityData() {
    };
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
    try {
        configDataBootstrap.start();
        fail("fail");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createDuplicateEntityIdException(entityId).getMessage());
    }
}
Also used : MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) CountriesConfigEntityData(uk.gov.ida.hub.config.domain.CountriesConfigEntityData) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.Test)

Example 12 with MatchingServiceConfigEntityData

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

the class TransactionConfigMatchingServiceValidatorTest method matchingServiceEntityId_shouldHaveCorrespondingConfiguration.

@Test
public void matchingServiceEntityId_shouldHaveCorrespondingConfiguration() throws Exception {
    final String matchingServiceEntityId = "matching-service-entity-id";
    TransactionConfigEntityData transactionConfig = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceEntityId).build();
    MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId(matchingServiceEntityId).build();
    when(matchingServiceConfigEntityDataRepository.getData(matchingServiceEntityId)).thenReturn(Optional.ofNullable(matchingServiceConfigData));
    validator.validate(transactionConfig, matchingServiceConfigEntityDataRepository);
}
Also used : MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Example 13 with MatchingServiceConfigEntityData

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

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

MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)14 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)10 Test (org.junit.Test)9 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)9 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)6 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)6 CertificateDetails (uk.gov.ida.hub.config.domain.CertificateDetails)5 SignatureVerificationCertificate (uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)4 SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate (uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate)3 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)3 TypeLiteral (com.google.inject.TypeLiteral)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 Timed (com.codahale.metrics.annotation.Timed)1 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