Search in sources :

Example 1 with MatchingServiceConfigEntityData

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

the class CertificatesResource method getCertHealthCheckDtos.

private List<CertificateHealthCheckDto> getCertHealthCheckDtos() throws CertificateException {
    List<CertificateHealthCheckDto> certs = new LinkedList<>();
    // IDP certs are now in the federation metadata and checked for expiry and OCSP status in separate sensu checks
    for (TransactionConfigEntityData transaction : transactionDataSource.getAllData()) {
        certs.add(createCertificateHealthCheckDto(transaction.getEntityId(), transaction.getEncryptionCertificate(), configuration.getCertificateWarningPeriod()));
        addCertificateHealthCheckDtos(certs, transaction.getEntityId(), transaction.getSignatureVerificationCertificates());
    }
    for (MatchingServiceConfigEntityData ms : matchingServiceDataSource.getAllData()) {
        certs.add(createCertificateHealthCheckDto(ms.getEntityId(), ms.getEncryptionCertificate(), configuration.getCertificateWarningPeriod()));
        addCertificateHealthCheckDtos(certs, ms.getEntityId(), ms.getSignatureVerificationCertificates());
    }
    return certs;
}
Also used : MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CertificateHealthCheckDto(uk.gov.ida.hub.config.dto.CertificateHealthCheckDto) CertificateHealthCheckDto.createCertificateHealthCheckDto(uk.gov.ida.hub.config.dto.CertificateHealthCheckDto.createCertificateHealthCheckDto) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) LinkedList(java.util.LinkedList)

Example 2 with MatchingServiceConfigEntityData

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

the class CertificateServiceTest method findsOnlyValidSignatureVerificationCertificates_WhenMatchingSignatureCertificatesExists.

@Test
public void findsOnlyValidSignatureVerificationCertificates_WhenMatchingSignatureCertificatesExists() throws Exception {
    SignatureVerificationCertificate validSigCert = aSignatureVerificationCertificate().withX509(CERT_ONE_X509).build();
    SignatureVerificationCertificate invalidSigCert = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
    MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(validSigCert).addSignatureVerificationCertificate(invalidSigCert).build();
    CertificateDetails validCertificate = new CertificateDetails(ENTITY_ID, validSigCert, FederationEntityType.MS);
    CertificateDetails invalidCertificate = new CertificateDetails(ENTITY_ID, invalidSigCert, FederationEntityType.MS);
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
    when(certificateValidityChecker.isValid(invalidCertificate)).thenReturn(false);
    when(certificateValidityChecker.isValid(validCertificate)).thenReturn(true);
    List<CertificateDetails> certificateDetailsFound = certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
    assertThat(certificateDetailsFound.size()).isEqualTo(1);
    assertThat(certificateDetailsFound.get(0)).isEqualTo(validCertificate);
}
Also used : MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate(uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate) SignatureVerificationCertificate(uk.gov.ida.hub.config.domain.SignatureVerificationCertificate) Test(org.junit.Test)

Example 3 with MatchingServiceConfigEntityData

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

the class ConfigDataBootstrapTest method start_shouldOnlyValidateCertificateChainIfIdentityProviderIsEnabled.

@Test
public void start_shouldOnlyValidateCertificateChainIfIdentityProviderIsEnabled() throws Exception {
    IdentityProviderConfigEntityData disabledIdp = anIdentityProviderConfigData().withEntityId("idp1EntityId").withEnabled(false).build();
    MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().withEntityId("matchingServiceId").build();
    TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId("matchingServiceId").withEntityId("rpEntityId").build();
    CountriesConfigEntityData countriesConfigData = new CountriesConfigEntityData() {
    };
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(disabledIdp, matchingServiceConfigData, transactionConfigData, countriesConfigData);
    configDataBootstrap.start();
    verify(certificateChainConfigValidator).validate(ImmutableSet.of(transactionConfigData), ImmutableSet.of(matchingServiceConfigData));
}
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) Test(org.junit.Test)

Example 4 with MatchingServiceConfigEntityData

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

the class MatchingServiceResource method getMatchingServices.

@GET
@Timed
public Collection<MatchingServiceConfigEntityDataDto> getMatchingServices() {
    Collection<MatchingServiceConfigEntityDataDto> matchingServices = new ArrayList<>();
    for (TransactionConfigEntityData transactionConfigEntityData : transactionConfigEntityDataRepository.getAllData()) {
        MatchingServiceConfigEntityData matchingServiceConfigEntityData = matchingServiceConfigEntityDataRepository.getData(transactionConfigEntityData.getMatchingServiceEntityId()).get();
        matchingServices.add(new MatchingServiceConfigEntityDataDto(matchingServiceConfigEntityData.getEntityId(), matchingServiceConfigEntityData.getUri(), transactionConfigEntityData.getEntityId(), matchingServiceConfigEntityData.getHealthCheckEnabled(), matchingServiceConfigEntityData.getOnboarding(), matchingServiceConfigEntityData.getUserAccountCreationUri()));
    }
    return matchingServices;
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.config.dto.MatchingServiceConfigEntityDataDto) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) ArrayList(java.util.ArrayList) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 5 with MatchingServiceConfigEntityData

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

the class CertificateServiceTest method throwsNoCertificateFoundException_WhenMatchingSignatureCertificatesExistButAreInvalid.

@Test(expected = NoCertificateFoundException.class)
public void throwsNoCertificateFoundException_WhenMatchingSignatureCertificatesExistButAreInvalid() throws Exception {
    SignatureVerificationCertificate invalidSigCert = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
    MatchingServiceConfigEntityData matchingServiceConfigEntityData = aMatchingServiceConfigEntityData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(invalidSigCert).build();
    CertificateDetails invalidCertificate = new CertificateDetails(ENTITY_ID, invalidSigCert, FederationEntityType.MS);
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(matchingServiceConfigEntityData));
    when(certificateValidityChecker.isValid(invalidCertificate)).thenReturn(false);
    certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
}
Also used : MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData) MatchingServiceConfigEntityData(uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData) CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate(uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate) SignatureVerificationCertificate(uk.gov.ida.hub.config.domain.SignatureVerificationCertificate) Test(org.junit.Test)

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