Search in sources :

Example 1 with InboundResponseFromMatchingService

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;
}
Also used : Response(org.opensaml.saml.saml2.core.Response) LevelOfAssurance(uk.gov.ida.hub.samlengine.domain.LevelOfAssurance) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto) InboundResponseFromMatchingService(uk.gov.ida.saml.hub.domain.InboundResponseFromMatchingService) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext)

Example 2 with InboundResponseFromMatchingService

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);
}
Also used : Response(org.opensaml.saml.saml2.core.Response) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) Issuer(org.opensaml.saml.saml2.core.Issuer) PersistentId(uk.gov.ida.saml.core.domain.PersistentId) InboundResponseFromMatchingService(uk.gov.ida.saml.hub.domain.InboundResponseFromMatchingService)

Aggregations

Response (org.opensaml.saml.saml2.core.Response)2 InboundResponseFromMatchingService (uk.gov.ida.saml.hub.domain.InboundResponseFromMatchingService)2 Issuer (org.opensaml.saml.saml2.core.Issuer)1 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto)1 LevelOfAssurance (uk.gov.ida.hub.samlengine.domain.LevelOfAssurance)1 AuthnContext (uk.gov.ida.saml.core.domain.AuthnContext)1 PassthroughAssertion (uk.gov.ida.saml.core.domain.PassthroughAssertion)1 PersistentId (uk.gov.ida.saml.core.domain.PersistentId)1