### Question:
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  CountryAuthnResponseTranslatorService(StringToOpenSamlObjectTransformer<Response> stringToOpenSamlResponseTransformer,
                                                 ResponseFromCountryValidator responseFromCountryValidator,
                                                 ResponseAssertionsFromCountryValidator responseAssertionFromCountryValidator,
                                                 DestinationValidator validateSamlResponseIssuedByIdpDestination,
                                                 AssertionDecrypter assertionDecrypter,
                                                 SecretKeyEncrypter secretKeyEncrypter,
                                                 AssertionBlobEncrypter assertionBlobEncrypter,
                                                 EidasValidatorFactory eidasValidatorFactory,
                                                 PassthroughAssertionUnmarshaller passthroughAssertionUnmarshaller,
                                                 CountryAuthenticationStatusUnmarshaller countryAuthenticationStatusUnmarshaller); InboundResponseFromCountry translate(SamlAuthnResponseTranslatorDto samlResponseDto);  }### Answer:
@Test public void shouldExtractAuthnStatementAssertionDetailsSignedAssertions() throws Exception { setupSigned(); InboundResponseFromCountry result = service.translate(samlAuthnResponseTranslatorDto); assertThat(result.getIssuer()).isEqualTo(responseIssuer); assertThat(result.getStatus().isPresent()).isTrue(); assertThat(result.getStatus().get()).isEqualTo(successStatus); assertThat(result.getStatusMessage()).isNotPresent(); assertThat(result.getLevelOfAssurance().isPresent()).isTrue(); assertThat(result.getLevelOfAssurance().get()).isEqualTo(LEVEL_2); assertThat(result.getPersistentId().isPresent()).isTrue(); assertThat(result.getPersistentId().get()).isEqualTo(persistentIdName); assertThat(result.getEncryptedIdentityAssertionBlob().isPresent()).isTrue(); assertThat(result.getEncryptedIdentityAssertionBlob().get()).isEqualTo(identityUnderlyingAssertionBlob); }
@Test public void shouldExtractAuthnStatementAssertionDetailsUnsignedAssertions() throws Exception { setupUnsigned(); InboundResponseFromCountry result = service.translate(samlAuthnResponseTranslatorDto); assertThat(result.getCountrySignedResponseContainer().isPresent()).isTrue(); CountrySignedResponseContainer countrySignedResponseContainer = result.getCountrySignedResponseContainer().get(); assertThat(countrySignedResponseContainer.getBase64SamlResponse()).isEqualTo(samlResponse); assertThat(countrySignedResponseContainer.getCountryEntityId()).isEqualTo(responseIssuer); assertThat(countrySignedResponseContainer.getBase64encryptedKeys()).isEqualTo(List.of(reEncryptedKey)); }