class CountryAuthnResponseTranslatorService {

    public InboundResponseFromCountry translate(SamlAuthnResponseTranslatorDto samlResponseDto) {
        Response response = unmarshall(samlResponseDto);
        ValidatedResponse validatedResponse = validateResponse(response);
        List<Assertion> assertions = assertionDecrypter.decryptAssertions(validatedResponse);
        Optional<Assertion> validatedIdentityAssertion = validateAssertion(validatedResponse, assertions);
        List<String> base64EncryptedSecretKeys;
        Optional<CountrySignedResponseContainer> countrySignedResponseContainer;

        if (areAssertionsUnsigned(assertions)) {
            base64EncryptedSecretKeys = assertionDecrypter.getReEncryptedKeys(
                    validatedResponse,
                    secretKeyEncrypter,
                    samlResponseDto.getMatchingServiceEntityId()
            );
            countrySignedResponseContainer = Optional.of(
                    new CountrySignedResponseContainer(
                            samlResponseDto.getSamlResponse(),
                            base64EncryptedSecretKeys,
                            response.getIssuer().getValue()
                    )
            );
        } else {
            countrySignedResponseContainer = Optional.empty();
        }

        return toModel(validatedResponse,
                validatedIdentityAssertion,
                samlResponseDto.getMatchingServiceEntityId(),
                countrySignedResponseContainer);
    }

    @Inject public  CountryAuthnResponseTranslatorService(StringToOpenSamlObjectTransformer<Response> stringToOpenSamlResponseTransformer,
                                                 ResponseFromCountryValidator responseFromCountryValidator,
                                                 ResponseAssertionsFromCountryValidator responseAssertionFromCountryValidator,
                                                 DestinationValidator validateSamlResponseIssuedByIdpDestination,
                                                 AssertionDecrypter assertionDecrypter,
                                                 SecretKeyEncrypter secretKeyEncrypter,
                                                 AssertionBlobEncrypter assertionBlobEncrypter,
                                                 EidasValidatorFactory eidasValidatorFactory,
                                                 PassthroughAssertionUnmarshaller passthroughAssertionUnmarshaller,
                                                 CountryAuthenticationStatusUnmarshaller countryAuthenticationStatusUnmarshaller);

}