use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class HealthCheckResponseFromMatchingServiceValidatorTest method validate_shouldThrowInvalidSamlExceptionIfIssuerElementIsMissing.
@Test
public void validate_shouldThrowInvalidSamlExceptionIfIssuerElementIsMissing() throws Exception {
Response response = aResponse().withIssuer(null).build();
assertValidationFailureSamlExceptionMessage(SamlTransformationErrorFactory.missingIssuer(), response);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorService method translate.
public InboundResponseFromMatchingServiceDto translate(SamlResponseContainerDto samlResponseContainerDto) {
final Response response = responseUnmarshaller.apply(samlResponseContainerDto.getSamlResponse());
MdcHelper.addContextToMdc(response);
final InboundResponseFromMatchingService responseFromMatchingService = responseToInboundResponseFromMatchingServiceTransformer.transform(response);
Optional<String> assertionBlob = Optional.empty();
Optional<LevelOfAssurance> levelOfAssurance = Optional.empty();
// FIXME?: transformer can return null
if (responseFromMatchingService.getMatchingServiceAssertion() != null && responseFromMatchingService.getMatchingServiceAssertion().isPresent()) {
assertionBlob = Optional.ofNullable(responseFromMatchingService.getMatchingServiceAssertion().get().getUnderlyingAssertionBlob());
final Optional<AuthnContext> authnContext = responseFromMatchingService.getMatchingServiceAssertion().get().getAuthnContext();
if (authnContext.isPresent()) {
levelOfAssurance = Optional.of(LevelOfAssurance.valueOf(authnContext.get().name()));
}
}
final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(responseFromMatchingService.getStatus(), responseFromMatchingService.getInResponseTo(), responseFromMatchingService.getIssuer(), assertionBlob.map(ab -> assertionBlobEncrypter.encryptAssertionBlob(samlResponseContainerDto.getAuthnRequestIssuerId(), ab)), levelOfAssurance);
return inboundResponseFromMatchingServiceDto;
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class SamlMessageSenderHandler method generateErrorResponseFromHub.
public SamlMessage generateErrorResponseFromHub(final SessionId sessionId, String principalIpAddressAsSeenByHub) {
AuthnResponseFromHubContainerDto authnResponseFromHub = sessionProxy.getErrorResponseFromHub(sessionId);
Response samlResponse = responseTransformer.apply(authnResponseFromHub.getSamlResponse());
validateAndLogSamlResponseSignature(samlResponse);
SamlMessage samlMessage = new SamlMessage(authnResponseFromHub.getSamlResponse(), SamlMessageType.SAML_RESPONSE, authnResponseFromHub.getRelayState(), authnResponseFromHub.getPostEndpoint().toString(), Optional.empty());
externalCommunicationEventLogger.logResponseFromHub(authnResponseFromHub.getResponseId(), sessionId, authnResponseFromHub.getPostEndpoint(), principalIpAddressAsSeenByHub);
return samlMessage;
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method shouldRemainNoAuthnContextIfStatusDetailPresentButUnknown.
@Test
public void shouldRemainNoAuthnContextIfStatusDetailPresentButUnknown() throws Exception {
String xml = readXmlFile("status-noauthncontext-withotherdetail.xml");
Response response = stringToOpenSamlObjectTransformer.apply(xml);
IdpIdaStatus idpIdaStatus = getStatusFrom(response);
assertThat(idpIdaStatus.getStatusCode()).isEqualTo(IdpIdaStatus.Status.NoAuthenticationContext);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method shouldThrowWhenNoMatch.
@Test
public void shouldThrowWhenNoMatch() throws Exception {
Assertions.assertThrows(IllegalStateException.class, () -> {
String xml = readXmlFile("status-unknown.xml");
Response response = stringToOpenSamlObjectTransformer.apply(xml);
getStatusFrom(response);
});
}
Aggregations