use of uk.gov.ida.saml.hub.domain.InboundResponseFromMatchingService in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorService method translate.
public InboundResponseFromMatchingServiceDto translate(SamlResponseDto samlResponseDto) {
final Response response = responseUnmarshaller.apply(samlResponseDto.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, levelOfAssurance);
return inboundResponseFromMatchingServiceDto;
}
use of uk.gov.ida.saml.hub.domain.InboundResponseFromMatchingService in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorServiceTest method setUpForTranslate.
private void setUpForTranslate(Optional<AuthnContext> authnContext, Optional<FraudDetectedDetails> fraudDetectedDetails, String underlyingAssertionBlob, String inResponseTo, String issuer, String samlResponse, MatchingServiceIdaStatus status) {
final PassthroughAssertion assertion = new PassthroughAssertion(new PersistentId("persistentId"), authnContext, underlyingAssertionBlob, fraudDetectedDetails, Optional.of("principalIpAddressAsSeenByIdp"));
final InboundResponseFromMatchingService inboundResponseFromMatchingService = InboundResponseFromMatchingServiceBuilder.anInboundResponseFromMatchingService().withInResponseTo(inResponseTo).withIssuerId(issuer).withMatchingServiceAssertion(assertion).withStatus(status).build();
Response response = mock(Response.class);
Issuer responseIssuer = mock(Issuer.class);
when(response.getIssuer()).thenReturn(responseIssuer);
when(responseUnmarshaller.apply(samlResponse)).thenReturn(response);
when(responseToInboundResponseFromMatchingServiceTransformer.transform(response)).thenReturn(inboundResponseFromMatchingService);
}
Aggregations