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);
}
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);
}
}
Aggregations