class MatchingServiceResponseTranslatorService {

    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;
    }

    @Inject public  MatchingServiceResponseTranslatorService(
            StringToOpenSamlObjectTransformer<Response> responseUnmarshaller,
            DecoratedSamlResponseToInboundResponseFromMatchingServiceTransformer responseToInboundResponseFromMatchingServiceTransformer,
             AssertionBlobEncrypter assertionBlobEncrypter);

}