Search in sources :

Example 1 with TransactionConfigEntityData

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

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

the class TransactionsResource method getAssertionConsumerServiceUri.

@GET
@Path(Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_URI_PATH)
@Timed
public ResourceLocationDto getAssertionConsumerServiceUri(@PathParam(Urls.SharedUrls.ENTITY_ID_PARAM) String entityId, @QueryParam(Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_INDEX_PARAM) Optional<Integer> assertionConsumerServiceIndex) {
    final TransactionConfigEntityData configData = getTransactionConfigData(entityId);
    final Optional<URI> assertionConsumerServiceUri = configData.getAssertionConsumerServiceUri(assertionConsumerServiceIndex);
    if (!assertionConsumerServiceUri.isPresent()) {
        // we know that the index must be here because we will have pre-validated that there will be a default for the transaction
        throw exceptionFactory.createInvalidAssertionConsumerServiceIndexException(entityId, assertionConsumerServiceIndex.get());
    }
    return new ResourceLocationDto(assertionConsumerServiceUri.get());
}
Also used : TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) URI(java.net.URI) ResourceLocationDto(uk.gov.ida.hub.config.dto.ResourceLocationDto) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 3 with TransactionConfigEntityData

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

the class TransactionsResource method getEidasCountries.

@GET
@Path(Urls.ConfigUrls.EIDAS_COUNTRIES_FOR_TRANSACTION_PATH)
@Timed
public List<String> getEidasCountries(@PathParam(Urls.SharedUrls.ENTITY_ID_PARAM) String entityId) {
    final TransactionConfigEntityData configData = getTransactionConfigData(entityId);
    Optional<List<String>> eidasCountries = configData.getEidasCountries();
    return eidasCountries.isPresent() ? eidasCountries.get() : ImmutableList.of();
}
Also used : List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 4 with TransactionConfigEntityData

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

the class CertificateServiceTest method throwsNotFoundException_WhenEncryptionCertificateExistsButIsInvalid.

@Test(expected = NoCertificateFoundException.class)
public void throwsNotFoundException_WhenEncryptionCertificateExistsButIsInvalid() throws Exception {
    TransactionConfigEntityData transactionConfigEntityData = aTransactionConfigData().withEntityId(ENTITY_ID).withEnabled(true).build();
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(transactionConfigEntityData));
    when(certificateValidityChecker.isValid(any(CertificateDetails.class))).thenReturn(false);
    certificateService.encryptionCertificateFor(ENTITY_ID);
}
Also used : CertificateDetails(uk.gov.ida.hub.config.domain.CertificateDetails) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Example 5 with TransactionConfigEntityData

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

the class CertificateServiceTest method findsOnlyValidSignatureVerificationCertificates_WhenTransactionSignatureCertificatesExists.

@Test
public void findsOnlyValidSignatureVerificationCertificates_WhenTransactionSignatureCertificatesExists() throws Exception {
    SignatureVerificationCertificate validCert = aSignatureVerificationCertificate().withX509(CERT_ONE_X509).build();
    SignatureVerificationCertificate invalidCert = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
    TransactionConfigEntityData transactionConfigEntityData = aTransactionConfigData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(validCert).addSignatureVerificationCertificate(invalidCert).build();
    CertificateDetails validCertificate = aCertifcateDetail(ENTITY_ID, validCert, FederationEntityType.RP);
    CertificateDetails invalidCertificate = aCertifcateDetail(ENTITY_ID, invalidCert, FederationEntityType.RP);
    when(matchingServiceDataSource.getData(ENTITY_ID)).thenReturn(Optional.empty());
    when(transactionDataSource.getData(ENTITY_ID)).thenReturn(Optional.of(transactionConfigEntityData));
    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 : 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) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Test(org.junit.Test)

Aggregations

TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)20 Test (org.junit.Test)13 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)9 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)9 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)7 ConfigValidationException (uk.gov.ida.hub.config.exceptions.ConfigValidationException)6 CertificateDetails (uk.gov.ida.hub.config.domain.CertificateDetails)5 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)5 Timed (com.codahale.metrics.annotation.Timed)3 GET (javax.ws.rs.GET)3 SignatureVerificationCertificate (uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)3 TypeLiteral (com.google.inject.TypeLiteral)2 Path (javax.ws.rs.Path)2 ConfigDataBootstrap (uk.gov.ida.hub.config.data.ConfigDataBootstrap)2 LevelsOfAssuranceConfigValidator (uk.gov.ida.hub.config.data.LevelsOfAssuranceConfigValidator)2 SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate (uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 ImmutableList (com.google.common.collect.ImmutableList)1 AbstractModule (com.google.inject.AbstractModule)1