Search in sources :

Example 6 with MatchingServiceConfig

use of uk.gov.ida.hub.config.domain.MatchingServiceConfig 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).asEagerSingleton();
    bind(TrustStoreConfiguration.class).to(ConfigConfiguration.class);
    bind(new TypeLiteral<ConfigurationFactoryFactory<IdentityProviderConfig>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<>());
    bind(new TypeLiteral<ConfigurationFactoryFactory<TransactionConfig>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<>());
    bind(new TypeLiteral<ConfigurationFactoryFactory<MatchingServiceConfig>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<>());
    bind(new TypeLiteral<ConfigurationFactoryFactory<TranslationData>>() {
    }).toInstance(new DefaultConfigurationFactoryFactory<>());
    bind(new TypeLiteral<ConfigDataSource<TransactionConfig>>() {
    }).to(FileBackedTransactionConfigDataSource.class).asEagerSingleton();
    bind(new TypeLiteral<ConfigDataSource<TranslationData>>() {
    }).to(FileBackedTranslationsDataSource.class).asEagerSingleton();
    bind(new TypeLiteral<ConfigDataSource<MatchingServiceConfig>>() {
    }).to(FileBackedMatchingServiceConfigDataSource.class).asEagerSingleton();
    bind(new TypeLiteral<ConfigDataSource<IdentityProviderConfig>>() {
    }).to(FileBackedIdentityProviderConfigDataSource.class).asEagerSingleton();
    bind(new TypeLiteral<LocalConfigRepository<TransactionConfig>>() {
    }).asEagerSingleton();
    bind(new TypeLiteral<LocalConfigRepository<TranslationData>>() {
    }).asEagerSingleton();
    bind(new TypeLiteral<LocalConfigRepository<MatchingServiceConfig>>() {
    }).asEagerSingleton();
    bind(new TypeLiteral<LocalConfigRepository<IdentityProviderConfig>>() {
    }).asEagerSingleton();
    bind(new TypeLiteral<ManagedEntityConfigRepository<TransactionConfig>>() {
    }).asEagerSingleton();
    bind(new TypeLiteral<ManagedEntityConfigRepository<MatchingServiceConfig>>() {
    }).asEagerSingleton();
    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(OCSPCertificateChainValidator.class);
    bind(IdpPredicateFactory.class);
    bind(KeyStoreLoader.class).toInstance(new KeyStoreLoader());
    bind(OCSPPKIXParametersProvider.class).toInstance(new OCSPPKIXParametersProvider());
    bind(PKIXParametersProvider.class).toInstance(new PKIXParametersProvider());
}
Also used : TrustStoreConfiguration(uk.gov.ida.truststore.TrustStoreConfiguration) FileBackedTranslationsDataSource(uk.gov.ida.hub.config.data.FileBackedTranslationsDataSource) KeyStoreLoader(uk.gov.ida.truststore.KeyStoreLoader) OCSPPKIXParametersProvider(uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider) TranslationData(uk.gov.ida.hub.config.domain.TranslationData) IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) FileBackedIdentityProviderConfigDataSource(uk.gov.ida.hub.config.data.FileBackedIdentityProviderConfigDataSource) OCSPPKIXParametersProvider(uk.gov.ida.common.shared.security.verification.OCSPPKIXParametersProvider) PKIXParametersProvider(uk.gov.ida.common.shared.security.verification.PKIXParametersProvider) X509CertificateFactory(uk.gov.ida.common.shared.security.X509CertificateFactory) TypeLiteral(com.google.inject.TypeLiteral) MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) FileBackedTransactionConfigDataSource(uk.gov.ida.hub.config.data.FileBackedTransactionConfigDataSource) FileBackedMatchingServiceConfigDataSource(uk.gov.ida.hub.config.data.FileBackedMatchingServiceConfigDataSource) ConfigDataBootstrap(uk.gov.ida.hub.config.data.ConfigDataBootstrap) 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) CertificateChainConfigValidator(uk.gov.ida.hub.config.domain.CertificateChainConfigValidator) LevelsOfAssuranceConfigValidator(uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)

Example 7 with MatchingServiceConfig

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

the class CertificateServiceTest method getAllCertificatesReturnsAllTransactionAndMatchingServiceCertificate.

@Test
public void getAllCertificatesReturnsAllTransactionAndMatchingServiceCertificate() {
    final TransactionConfig transactionOneConfig = aTransactionConfigData().withEntityId(RP_ONE_ENTITY_ID).withEnabled(true).build();
    final TransactionConfig transactionTwoConfig = aTransactionConfigData().withEntityId(RP_TWO_ENTITY_ID).withEnabled(true).build();
    final MatchingServiceConfig matchingServiceOneConfig = aMatchingServiceConfig().withEntityId(RP_MSA_ONE_ENTITY_ID).build();
    Set<Certificate> expectedCertificateSet = new HashSet<>();
    expectedCertificateSet.addAll(transactionOneConfig.getAllCertificates());
    expectedCertificateSet.addAll(transactionTwoConfig.getAllCertificates());
    expectedCertificateSet.addAll(matchingServiceOneConfig.getAllCertificates());
    List<TransactionConfig> transactionConfigs = new ArrayList<>();
    transactionConfigs.add(transactionOneConfig);
    transactionConfigs.add(transactionTwoConfig);
    List<MatchingServiceConfig> matchingServiceConfigs = new ArrayList<>();
    matchingServiceConfigs.add(matchingServiceOneConfig);
    when(connectedServiceConfigRepository.stream()).thenReturn(transactionConfigs.stream());
    when(matchingServiceConfigRepository.stream()).thenReturn(matchingServiceConfigs.stream());
    final Set<Certificate> actualCertificateSet = certificateService.getAllCertificates();
    assertThat(actualCertificateSet.size()).isEqualTo(6);
    assertThat(actualCertificateSet).containsAll(expectedCertificateSet);
}
Also used : MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) MatchingServiceConfigBuilder.aMatchingServiceConfig(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig) ArrayList(java.util.ArrayList) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) Certificate(uk.gov.ida.hub.config.domain.Certificate) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 8 with MatchingServiceConfig

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

the class CertificateServiceTest method signatureVerificationCertificatesForEntityIdReturnsSignatureVerificationCertificatesWhenMatchingSignatureCertificatesExists.

@Test
public void signatureVerificationCertificatesForEntityIdReturnsSignatureVerificationCertificatesWhenMatchingSignatureCertificatesExists() {
    MatchingServiceConfig matchingServiceConfig = aMatchingServiceConfig().withEntityId(RP_ONE_ENTITY_ID).addSignatureVerificationCertificate(CERT_ONE_X509).addSignatureVerificationCertificate(CERT_TWO_X509).build();
    when(matchingServiceConfigRepository.has(RP_ONE_ENTITY_ID)).thenReturn(true);
    when(matchingServiceConfigRepository.get(RP_ONE_ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfig));
    when(certificateValidityChecker.isValid(any(Certificate.class))).thenReturn(true);
    List<Certificate> CertificateFound = certificateService.signatureVerificationCertificatesFor(RP_ONE_ENTITY_ID);
    assertThat(CertificateFound.size()).isEqualTo(2);
    assertThat(CertificateFound).contains(new Certificate(RP_ONE_ENTITY_ID, FederationEntityType.RP, CERT_ONE_X509, CertificateUse.SIGNING, CertificateOrigin.FEDERATION, true), new Certificate(RP_ONE_ENTITY_ID, FederationEntityType.RP, CERT_TWO_X509, CertificateUse.SIGNING, CertificateOrigin.FEDERATION, true));
}
Also used : MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) MatchingServiceConfigBuilder.aMatchingServiceConfig(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig) Certificate(uk.gov.ida.hub.config.domain.Certificate) Test(org.junit.jupiter.api.Test)

Example 9 with MatchingServiceConfig

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

the class ConfigDataBootstrapTest method start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails.

@Test
public void start_shouldThrowExceptionWhenMatchingTransactionEntityIdCheckFails() {
    final String transEntityId = "trans-entity-id";
    final String simpleId = "simple-id";
    final IdentityProviderConfig identityProviderConfigData = anIdentityProviderConfigData().withEntityId("entity-id").build();
    final TransactionConfig transactionConfigData = aTransactionConfigData().withEntityId(transEntityId).withMatchingServiceEntityId(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID).build();
    final TranslationData translationData = aTranslationData().withSimpleId(simpleId).build();
    final MatchingServiceConfig matchingServiceConfigData = aMatchingServiceConfig().withEntityId(MATCHING_SERVICE_ENTITY_ID).build();
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, translationData);
    try {
        configDataBootstrap.start();
        fail("fail");
    } catch (ConfigValidationException e) {
        assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createAbsentMatchingServiceConfigException(NON_EXISTENT_MATCHING_SERVICE_ENTITY_ID, transEntityId).getMessage());
    }
}
Also used : MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) MatchingServiceConfigBuilder.aMatchingServiceConfig(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig) TranslationDataBuilder.aTranslationData(uk.gov.ida.hub.config.domain.builders.TranslationDataBuilder.aTranslationData) TranslationData(uk.gov.ida.hub.config.domain.TranslationData) IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) ConfigValidationException(uk.gov.ida.hub.config.exceptions.ConfigValidationException) Test(org.junit.jupiter.api.Test)

Example 10 with MatchingServiceConfig

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

the class ConfigDataBootstrapTest method continuesToStart_WhenCertificateCheckHasInvalidCertificates.

@Disabled
public void continuesToStart_WhenCertificateCheckHasInvalidCertificates() {
    final String idpEntityId = "idp-entity-id";
    final String simpleId = "simple-id";
    final String matchingServiceId = "matching-service-id";
    final String rpEntityId = "rp-entity";
    String badCertificateValue = "badCertificate";
    final IdentityProviderConfig identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).build();
    MatchingServiceConfig matchingServiceConfigData = aMatchingServiceConfig().addSignatureVerificationCertificate(badCertificateValue).withEntityId(matchingServiceId).build();
    TransactionConfig transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceId).withEntityId(rpEntityId).build();
    final TranslationData translationData = aTranslationData().withSimpleId(simpleId).build();
    InvalidCertificateDto invalidIdpCertificateDto = new InvalidCertificateDto(idpEntityId, CertPathValidatorException.BasicReason.INVALID_SIGNATURE, CertificateUse.SIGNING, FederationEntityType.IDP, "certificate was bad!");
    InvalidCertificateDto invalidMatchingServiceCertificateDto = new InvalidCertificateDto(matchingServiceId, CertPathValidatorException.BasicReason.NOT_YET_VALID, CertificateUse.SIGNING, FederationEntityType.MS, "certificate was not yet valid!");
    doThrow(createInvalidCertificatesException(List.of(invalidMatchingServiceCertificateDto, invalidIdpCertificateDto))).when(certificateChainConfigValidator).validate(Set.of(transactionConfigData, matchingServiceConfigData));
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, translationData);
    configDataBootstrap.start();
}
Also used : MatchingServiceConfig(uk.gov.ida.hub.config.domain.MatchingServiceConfig) MatchingServiceConfigBuilder.aMatchingServiceConfig(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig) TranslationDataBuilder.aTranslationData(uk.gov.ida.hub.config.domain.builders.TranslationDataBuilder.aTranslationData) TranslationData(uk.gov.ida.hub.config.domain.TranslationData) IdentityProviderConfig(uk.gov.ida.hub.config.domain.IdentityProviderConfig) TransactionConfig(uk.gov.ida.hub.config.domain.TransactionConfig) InvalidCertificateDto(uk.gov.ida.hub.config.dto.InvalidCertificateDto) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

MatchingServiceConfig (uk.gov.ida.hub.config.domain.MatchingServiceConfig)12 MatchingServiceConfigBuilder.aMatchingServiceConfig (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigBuilder.aMatchingServiceConfig)10 Test (org.junit.jupiter.api.Test)9 TransactionConfig (uk.gov.ida.hub.config.domain.TransactionConfig)7 Certificate (uk.gov.ida.hub.config.domain.Certificate)6 IdentityProviderConfig (uk.gov.ida.hub.config.domain.IdentityProviderConfig)5 TranslationData (uk.gov.ida.hub.config.domain.TranslationData)5 TranslationDataBuilder.aTranslationData (uk.gov.ida.hub.config.domain.builders.TranslationDataBuilder.aTranslationData)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 CertificateChainConfigValidator (uk.gov.ida.hub.config.domain.CertificateChainConfigValidator)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 ConfigurationFactoryFactory (io.dropwizard.configuration.ConfigurationFactoryFactory)1 DefaultConfigurationFactoryFactory (io.dropwizard.configuration.DefaultConfigurationFactoryFactory)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Disabled (org.junit.jupiter.api.Disabled)1