use of org.opensaml.saml.saml2.ecp.Response in project verify-hub by alphagov.
the class SamlMessageSenderHandlerTest method generateAuthResponseFromHub_shouldThrowSamlTransformationException.
@Test(expected = SamlTransformationErrorException.class)
public void generateAuthResponseFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
SessionId sessionId = SessionId.createNewSessionId();
String expectedSamlMessageId = UUID.randomUUID().toString();
Response openSamlResponse = setUpAuthnResponseFromHub(sessionId, expectedSamlMessageId);
when(samlMessageSignatureValidator.validate(openSamlResponse, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));
samlMessageSenderHandler.generateAuthnResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
}
use of org.opensaml.saml.saml2.ecp.Response in project verify-hub by alphagov.
the class ProtectiveMonitoringLogFormatterTest method shouldFormatResponseWithNoIssuer.
@Test
public void shouldFormatResponseWithNoIssuer() throws IOException, URISyntaxException, MarshallingException, SignatureException {
Response response = aResponse().withIssuer(null).build();
String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(response, Direction.INBOUND, true);
assertThat(logString).contains("issuerId: ,");
}
use of org.opensaml.saml.saml2.ecp.Response in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequest method validateResponseSignature.
private void validateResponseSignature(Element responseFromMatchingService) {
Response response = elementToSamlResponseTransformer.apply(responseFromMatchingService);
SamlValidationResponse signatureValidationResponse = matchingResponseSignatureValidator.validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
String message = hasStatusMessage(response.getStatus()) ? response.getStatus().getStatusMessage().getMessage() : "";
protectiveMonitoringLogger.logAttributeQueryResponse(response.getID(), response.getInResponseTo(), response.getIssuer().getValue(), signatureValidationResponse.isOK(), response.getStatus().getStatusCode().getValue(), message);
if (!signatureValidationResponse.isOK()) {
SamlValidationSpecificationFailure failure = signatureValidationResponse.getSamlValidationSpecificationFailure();
throw new SamlTransformationErrorException(failure.getErrorMessage(), signatureValidationResponse.getCause(), Level.ERROR);
}
}
use of org.opensaml.saml.saml2.ecp.Response in project verify-hub by alphagov.
the class MatchingServiceHealthCheckerTest method mockHealthcheckResponseId.
private void mockHealthcheckResponseId(String version) {
Response response = mock(Response.class);
when(elementToResponseTransformer.apply(any())).thenReturn(response);
when(response.getID()).thenReturn(version);
}
use of org.opensaml.saml.saml2.ecp.Response in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldCallSamlMessageSignatureValidatorWithRequest.
@Test
public void run_shouldCallSamlMessageSignatureValidatorWithRequest() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
Response response = aResponse().build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingRequestSignatureValidator).validate(attributeQuery, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
Aggregations