Search in sources :

Example 1 with CertificateDto

use of uk.gov.ida.hub.config.dto.CertificateDto in project verify-hub by alphagov.

the class SelfServiceCertificatesResourceIntegrationTest method getEncryptionCertificateReturnsOkAndEncryptionCertificateForOverridden.

@Test
public void getEncryptionCertificateReturnsOkAndEncryptionCertificateForOverridden() {
    String entityId = REMOTE_ENABLED_ENTITY_ID;
    Response response = getForEntityIdAndPath(entityId, Urls.ConfigUrls.ENCRYPTION_CERTIFICATES_RESOURCE);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    CertificateDto certDto = response.readEntity(CertificateDto.class);
    assertThat(certDto.getCertificate()).contains(REMOTE_CERT);
}
Also used : Response(javax.ws.rs.core.Response) CertificateDto(uk.gov.ida.hub.config.dto.CertificateDto) Test(org.junit.jupiter.api.Test)

Example 2 with CertificateDto

use of uk.gov.ida.hub.config.dto.CertificateDto in project verify-hub by alphagov.

the class CertificatesResource method getEncryptionCertificate.

@GET
@Path(Urls.ConfigUrls.ENCRYPTION_CERTIFICATE_PATH)
@Timed
public CertificateDto getEncryptionCertificate(@PathParam(Urls.SharedUrls.ENTITY_ID_PARAM) String entityId) {
    try {
        Certificate certificate = certificateService.encryptionCertificateFor(entityId);
        Optional<String> base64Encoded = certificate.getBase64Encoded();
        return certificate.getBase64Encoded().map(base64 -> aCertificateDto(entityId, base64Encoded.get(), CertificateDto.KeyUse.Encryption, certificate.getFederationEntityType())).orElseThrow(() -> exceptionFactory.createNoDataForEntityException(entityId));
    } catch (NoCertificateFoundException ncfe) {
        throw exceptionFactory.createNoDataForEntityException(entityId);
    } catch (CertificateDisabledException cde) {
        throw exceptionFactory.createDisabledTransactionException(entityId);
    }
}
Also used : PathParam(javax.ws.rs.PathParam) ExceptionFactory(uk.gov.ida.hub.config.exceptions.ExceptionFactory) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) CertificateDto(uk.gov.ida.hub.config.dto.CertificateDto) Inject(javax.inject.Inject) MediaType(javax.ws.rs.core.MediaType) InvalidCertificateDto(uk.gov.ida.hub.config.dto.InvalidCertificateDto) Urls(uk.gov.ida.hub.config.Urls) NoCertificateFoundException(uk.gov.ida.hub.config.exceptions.NoCertificateFoundException) Certificate(uk.gov.ida.hub.config.domain.Certificate) Collection(java.util.Collection) CertificateDto.aCertificateDto(uk.gov.ida.hub.config.dto.CertificateDto.aCertificateDto) ConfigConfiguration(uk.gov.ida.hub.config.ConfigConfiguration) CertificateHealthCheckDto(uk.gov.ida.hub.config.dto.CertificateHealthCheckDto) Set(java.util.Set) CertificateService(uk.gov.ida.hub.config.application.CertificateService) CertificateDisabledException(uk.gov.ida.hub.config.exceptions.CertificateDisabledException) Timed(com.codahale.metrics.annotation.Timed) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Response(javax.ws.rs.core.Response) OCSPCertificateChainValidityChecker(uk.gov.ida.hub.config.domain.OCSPCertificateChainValidityChecker) Optional(java.util.Optional) NoCertificateFoundException(uk.gov.ida.hub.config.exceptions.NoCertificateFoundException) CertificateDisabledException(uk.gov.ida.hub.config.exceptions.CertificateDisabledException) Certificate(uk.gov.ida.hub.config.domain.Certificate) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

Response (javax.ws.rs.core.Response)2 CertificateDto (uk.gov.ida.hub.config.dto.CertificateDto)2 Timed (com.codahale.metrics.annotation.Timed)1 Collection (java.util.Collection)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toList (java.util.stream.Collectors.toList)1 Inject (javax.inject.Inject)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 MediaType (javax.ws.rs.core.MediaType)1 Test (org.junit.jupiter.api.Test)1 ConfigConfiguration (uk.gov.ida.hub.config.ConfigConfiguration)1 Urls (uk.gov.ida.hub.config.Urls)1 CertificateService (uk.gov.ida.hub.config.application.CertificateService)1 Certificate (uk.gov.ida.hub.config.domain.Certificate)1 OCSPCertificateChainValidityChecker (uk.gov.ida.hub.config.domain.OCSPCertificateChainValidityChecker)1