use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class SamlEngineStubRule method prepareForHealthCheckSamlGeneration.
public void prepareForHealthCheckSamlGeneration() throws JsonProcessingException {
AttributeQuery attributeQuery = AttributeQueryBuilder.anAttributeQuery().withSignature(SignatureBuilder.aSignature().withSigningCredential(signingCredential).build()).withIssuer(IssuerBuilder.anIssuer().withIssuerId(HUB_ENTITY_ID).build()).build();
SamlMessageDto samlMessageDto = new SamlMessageDto(XmlUtils.writeToString(attributeQuery.getDOM()));
register(Urls.SamlEngineUrls.GENERATE_MSA_HEALTHCHECK_ATTRIBUTE_QUERY_RESOURCE, Response.Status.OK.getStatusCode(), samlMessageDto);
}
use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class SamlEngineStubExtension method prepareForHealthCheckSamlGeneration.
public void prepareForHealthCheckSamlGeneration() throws JsonProcessingException {
AttributeQuery attributeQuery = anAttributeQuery().withSignature(aSignature().withSigningCredential(signingCredential).build()).withIssuer(anIssuer().withIssuerId(HUB_ENTITY_ID).build()).build();
SamlMessageDto samlMessageDto = new SamlMessageDto(XmlUtils.writeToString(attributeQuery.getDOM()));
register(GENERATE_MSA_HEALTHCHECK_ATTRIBUTE_QUERY_RESOURCE, OK.getStatusCode(), samlMessageDto);
}
use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class SamlEngineStubExtension method prepareForHealthCheckSamlGeneration.
public void prepareForHealthCheckSamlGeneration(final MatchingServiceHealthCheckerRequestDto msaHealthCheckerRequest) throws JsonProcessingException {
final AttributeQuery attributeQuery = anAttributeQuery().withSignature(aSignature().withSigningCredential(signingCredential).build()).withIssuer(anIssuer().withIssuerId(HUB_ENTITY_ID).build()).build();
final SamlMessageDto samlMessage = new SamlMessageDto(XmlUtils.writeToString(attributeQuery.getDOM()));
final RequestAndResponse requestAndResponse = expectRequest().withPath(GENERATE_MSA_HEALTHCHECK_ATTRIBUTE_QUERY_RESOURCE).withMethod("POST").withBody(msaHealthCheckerRequest).andWillRespondWith().withStatus(OK.getStatusCode()).withContentType(MediaType.APPLICATION_JSON).withBody(samlMessage).build();
register(requestAndResponse);
}
use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class PrometheusMetricsIntegrationTest method setUp.
@BeforeEach
public void setUp() throws JsonProcessingException {
client = samlSoapProxyApp.getClient();
final MatchingServiceDetails msaOneDetails = new MatchingServiceDetails(msaStubOne.getAttributeQueryRequestUri(), MSA_ONE_ENTITY_ID, RP_ONE_ENTITY_ID);
final MatchingServiceDetails msaTwoDetails = new MatchingServiceDetails(msaStubTwo.getAttributeQueryRequestUri(), MSA_TWO_ENTITY_ID, RP_TWO_ENTITY_ID);
final MatchingServiceDetails msaThreeDetails = new MatchingServiceDetails(msaStubThree.getAttributeQueryRequestUri(), MSA_THREE_ENTITY_ID, RP_THREE_ENTITY_ID);
final MatchingServiceDetails msaFourDetails = new MatchingServiceDetails(msaStubFour.getAttributeQueryRequestUri(), MSA_FOUR_ENTITY_ID, RP_FOUR_ENTITY_ID);
Set<MatchingServiceDetails> msaDetailsSet = new HashSet<>(Set.of(msaOneDetails, msaTwoDetails, msaThreeDetails, msaFourDetails));
final Element msaOneResponse = aHealthyHealthCheckResponse(MSA_ONE_ENTITY_ID, MSA_ONE_RESPONSE_ID, MSA_ONE_VERSION);
final Element msaTwoResponse = aHealthyHealthCheckResponse(MSA_TWO_ENTITY_ID, MSA_TWO_RESPONSE_ID, MSA_TWO_VERSION);
final Element msaFourResponse = aHealthyHealthCheckResponse(MSA_FOUR_ENTITY_ID, MSA_FOUR_RESPONSE_ID, MSA_FOUR_VERSION);
final SamlMessageDto msaOneSamlMessage = new SamlMessageDto(Base64.getEncoder().encodeToString(XmlUtils.writeToString(msaOneResponse).getBytes()));
final SamlMessageDto msaTwoSamlMessage = new SamlMessageDto(Base64.getEncoder().encodeToString(XmlUtils.writeToString(msaTwoResponse).getBytes()));
final SamlMessageDto msaFourSamlMessage = new SamlMessageDto(Base64.getEncoder().encodeToString(XmlUtils.writeToString(msaFourResponse).getBytes()));
final MatchingServiceHealthCheckerRequestDto msaOneHealthCheckerRequest = new MatchingServiceHealthCheckerRequestDto(RP_ONE_ENTITY_ID, MSA_ONE_ENTITY_ID);
final MatchingServiceHealthCheckerRequestDto msaTwoHealthCheckerRequest = new MatchingServiceHealthCheckerRequestDto(RP_TWO_ENTITY_ID, MSA_TWO_ENTITY_ID);
final MatchingServiceHealthCheckerRequestDto msaThreeHealthCheckerRequest = new MatchingServiceHealthCheckerRequestDto(RP_THREE_ENTITY_ID, MSA_THREE_ENTITY_ID);
final MatchingServiceHealthCheckerRequestDto msaFourHealthCheckerRequest = new MatchingServiceHealthCheckerRequestDto(RP_FOUR_ENTITY_ID, MSA_FOUR_ENTITY_ID);
eventSinkStub.setupStubForLogging();
configStub.setUpStubForMatchingServiceHealthCheckRequests(msaDetailsSet);
configStub.setupStubForCertificates(MSA_ONE_ENTITY_ID, TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PUBLIC_ENCRYPTION_CERT);
configStub.setupStubForCertificates(MSA_TWO_ENTITY_ID, TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PUBLIC_ENCRYPTION_CERT);
configStub.setupStubForCertificates(MSA_FOUR_ENTITY_ID, TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PUBLIC_ENCRYPTION_CERT);
msaStubOne.prepareForHealthCheckRequest(XmlUtils.writeToString(SOAP_MESSAGE_MANAGER.wrapWithSoapEnvelope(msaOneResponse)));
msaStubTwo.prepareForHealthCheckRequest(XmlUtils.writeToString(SOAP_MESSAGE_MANAGER.wrapWithSoapEnvelope(msaTwoResponse)));
msaStubFour.prepareForHealthCheckRequest(XmlUtils.writeToString(SOAP_MESSAGE_MANAGER.wrapWithSoapEnvelope(msaFourResponse)));
samlEngineStub.prepareForHealthCheckSamlGeneration(msaOneHealthCheckerRequest);
samlEngineStub.prepareForHealthCheckSamlGeneration(msaTwoHealthCheckerRequest);
samlEngineStub.prepareForHealthCheckSamlGeneration(msaThreeHealthCheckerRequest);
samlEngineStub.prepareForHealthCheckSamlGeneration(msaFourHealthCheckerRequest);
samlEngineStub.setupStubForAttributeResponseTranslate(msaOneSamlMessage, anInboundResponseFromMatchingServiceDto().withIssuer(MSA_ONE_ENTITY_ID).withStatus(Healthy).build());
samlEngineStub.setupStubForAttributeResponseTranslate(msaTwoSamlMessage, anInboundResponseFromMatchingServiceDto().withIssuer(MSA_TWO_ENTITY_ID).withStatus(Healthy).build());
samlEngineStub.setupStubForAttributeResponseTranslate(msaFourSamlMessage, anInboundResponseFromMatchingServiceDto().withIssuer(MSA_FOUR_ENTITY_ID).withStatus(Healthy).build());
}
use of uk.gov.ida.hub.samlsoapproxy.contract.SamlMessageDto in project verify-hub by alphagov.
the class MatchingServiceHealthChecker method isHealthyResponse.
private boolean isHealthyResponse(final URI matchingServiceUri, Optional<String> response) {
if (response.isEmpty()) {
return false;
}
String exceptionMessage = format("Matching service health check failed for URI {0}", matchingServiceUri);
try {
// Saml-engine expects the saml to be base64 encoded
String base64Response = Base64.getEncoder().encodeToString(response.get().getBytes(Charset.defaultCharset()));
final SamlMessageDto samlMessageDto = new SamlMessageDto(base64Response);
final MatchingServiceHealthCheckerResponseDto responseFromMatchingService = samlEngineProxy.translateHealthcheckMatchingServiceResponse(samlMessageDto);
if (responseFromMatchingService.getStatus() != MatchingServiceIdaStatus.Healthy) {
return false;
}
} catch (ApplicationException e) {
eventLogger.logException(e, exceptionMessage);
return false;
} catch (RuntimeException e) {
LOG.warn(format("Matching service health check failed for URI {0}", matchingServiceUri), e);
return false;
}
return true;
}
Aggregations