Search in sources :

Example 6 with SignatureVerificationCertificate

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

the class CertificateServiceTest method findsSignatureVerificationCertificates_WhenTransactionSignatureCertificatesExists.

@Test
public void findsSignatureVerificationCertificates_WhenTransactionSignatureCertificatesExists() throws Exception {
    SignatureVerificationCertificate sigCert1 = aSignatureVerificationCertificate().withX509(CERT_ONE_X509).build();
    SignatureVerificationCertificate sigCert2 = aSignatureVerificationCertificate().withX509(CERT_TWO_X509).build();
    TransactionConfigEntityData transactionConfigEntityData = aTransactionConfigData().withEntityId(ENTITY_ID).addSignatureVerificationCertificate(sigCert1).addSignatureVerificationCertificate(sigCert2).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(true);
    List<CertificateDetails> certificateDetailsFound = certificateService.signatureVerificatonCertificatesFor(ENTITY_ID);
    assertThat(certificateDetailsFound.size()).isEqualTo(2);
    assertThat(certificateDetailsFound).contains(aCertifcateDetail(ENTITY_ID, sigCert1, FederationEntityType.RP), aCertifcateDetail(ENTITY_ID, sigCert2, FederationEntityType.RP));
}
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)

Example 7 with SignatureVerificationCertificate

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

the class ConfigDataBootstrapTest method continuesToStart_WhenCertificateCheckHasInvalidCertificates.

@Ignore
public void continuesToStart_WhenCertificateCheckHasInvalidCertificates() {
    final String idpEntityId = "idp-entity-id";
    final String matchingServiceId = "matching-service-id";
    final String rpEntityId = "rp-entity";
    String badCertificateValue = "badCertificate";
    final SignatureVerificationCertificate badCertificate = new SignatureVerificationCertificateBuilder().withX509(badCertificateValue).build();
    final IdentityProviderConfigEntityData identityProviderConfigData = anIdentityProviderConfigData().withEntityId(idpEntityId).addSignatureVerificationCertificate(badCertificate).build();
    MatchingServiceConfigEntityData matchingServiceConfigData = aMatchingServiceConfigEntityData().addSignatureVerificationCertificate(badCertificate).withEntityId(matchingServiceId).build();
    TransactionConfigEntityData transactionConfigData = aTransactionConfigData().withMatchingServiceEntityId(matchingServiceId).withEntityId(rpEntityId).build();
    InvalidCertificateDto invalidIdpCertificateDto = new InvalidCertificateDto(idpEntityId, CertPathValidatorException.BasicReason.INVALID_SIGNATURE, CertificateType.SIGNING, FederationEntityType.IDP, "certificate was bad!");
    InvalidCertificateDto invalidMatchingServiceCertificateDto = new InvalidCertificateDto(matchingServiceId, CertPathValidatorException.BasicReason.NOT_YET_VALID, CertificateType.SIGNING, FederationEntityType.MS, "certificate was not yet valid!");
    doThrow(createInvalidCertificatesException(ImmutableList.of(invalidMatchingServiceCertificateDto, invalidIdpCertificateDto))).when(certificateChainConfigValidator).validate(ImmutableSet.of(transactionConfigData), ImmutableSet.of(matchingServiceConfigData));
    CountriesConfigEntityData countriesConfigEntityData = createCountriesConfigEntityData();
    ConfigDataBootstrap configDataBootstrap = createConfigDataBootstrap(identityProviderConfigData, matchingServiceConfigData, transactionConfigData, countriesConfigEntityData);
    configDataBootstrap.start();
}
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) InvalidCertificateDto(uk.gov.ida.hub.config.dto.InvalidCertificateDto) SignatureVerificationCertificate(uk.gov.ida.hub.config.domain.SignatureVerificationCertificate) SignatureVerificationCertificateBuilder(uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder) IdentityProviderConfigEntityData(uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData) TransactionConfigEntityData(uk.gov.ida.hub.config.domain.TransactionConfigEntityData) Ignore(org.junit.Ignore)

Aggregations

SignatureVerificationCertificate (uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)7 Test (org.junit.Test)5 CertificateDetails (uk.gov.ida.hub.config.domain.CertificateDetails)5 SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate (uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder.aSignatureVerificationCertificate)5 MatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.MatchingServiceConfigEntityData)4 MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData (uk.gov.ida.hub.config.domain.builders.MatchingServiceConfigEntityDataBuilder.aMatchingServiceConfigEntityData)4 TransactionConfigEntityData (uk.gov.ida.hub.config.domain.TransactionConfigEntityData)3 Ignore (org.junit.Ignore)1 DeserializablePublicKeyConfiguration (uk.gov.ida.common.shared.configuration.DeserializablePublicKeyConfiguration)1 CountriesConfigEntityData (uk.gov.ida.hub.config.domain.CountriesConfigEntityData)1 IdentityProviderConfigEntityData (uk.gov.ida.hub.config.domain.IdentityProviderConfigEntityData)1 SignatureVerificationCertificateBuilder (uk.gov.ida.hub.config.domain.builders.SignatureVerificationCertificateBuilder)1 InvalidCertificateDto (uk.gov.ida.hub.config.dto.InvalidCertificateDto)1