use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromCountry in project verify-hub by alphagov.
the class CountryAuthnResponseTranslatorService method toModel.
private InboundResponseFromCountry toModel(ValidatedResponse response, Optional<Assertion> validatedIdentityAssertionOptional, String matchingServiceEntityId) {
Optional<PassthroughAssertion> passthroughAssertion = validatedIdentityAssertionOptional.map(validatedIdentityAssertion -> passthroughAssertionUnmarshaller.fromAssertion(validatedIdentityAssertion, true));
Optional<LevelOfAssurance> levelOfAssurance = passthroughAssertion.flatMap(assertion -> assertion.getAuthnContext()).map(AuthnContext::name).filter(string -> !isNullOrEmpty(string)).map(LevelOfAssurance::valueOf);
IdpIdaStatus status = statusUnmarshaller.fromSaml(response.getStatus());
return new InboundResponseFromCountry(response.getIssuer().getValue(), validatedIdentityAssertionOptional.map(Assertion::getSubject).map(Subject::getNameID).map(NameID::getValue), Optional.ofNullable(status).map(IdpIdaStatus::getStatusCode).map(IdpIdaStatus.Status::name), status.getMessage(), passthroughAssertion.map(assertion -> assertionBlobEncrypter.encryptAssertionBlob(matchingServiceEntityId, assertion.getUnderlyingAssertionBlob())), levelOfAssurance);
}
use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromCountry in project verify-hub by alphagov.
the class CountryAuthnResponseTranslatorResourceTest method shouldReturnSuccessResponse.
@Test
public void shouldReturnSuccessResponse() throws Exception {
SamlAuthnResponseTranslatorDto dto = createAuthnResponseSignedByKeyPair(TestCertificateStrings.STUB_IDP_PUBLIC_PRIMARY_CERT, TestCertificateStrings.STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY);
org.opensaml.saml.saml2.core.Response originalAuthnResponse = new HubTransformersFactory().getStringToResponseTransformer().apply(dto.getSamlResponse());
Response response = postAuthnResponseToSamlEngine(dto);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
InboundResponseFromCountry inboundResponseFromCountry = response.readEntity(InboundResponseFromCountry.class);
assertThat(inboundResponseFromCountry.getStatus()).isEqualTo(Optional.of("Success"));
assertThat(inboundResponseFromCountry.getIssuer()).isEqualTo(samlEngineAppRule.getCountryMetadataUri());
assertThatDecryptedAssertionsAreTheSame(inboundResponseFromCountry, originalAuthnResponse);
}
use of uk.gov.ida.hub.samlengine.domain.InboundResponseFromCountry in project verify-hub by alphagov.
the class CountryAuthnResponseTranslatorServiceTest method shouldExtractAuthnStatementAssertionDetails.
@Test
public void shouldExtractAuthnStatementAssertionDetails() {
InboundResponseFromCountry result = service.translate(samlAuthnResponseTranslatorDto);
assertThat(result.getIssuer()).isEqualTo(responseIssuer);
assertThat(result.getStatus().isPresent()).isTrue();
assertThat(result.getStatus().get()).isEqualTo("Success");
assertThat(result.getStatusMessage().isPresent()).isFalse();
assertThat(result.getLevelOfAssurance().isPresent()).isTrue();
assertThat(result.getLevelOfAssurance().get()).isEqualTo(LEVEL_3);
assertThat(result.getPersistentId().isPresent()).isTrue();
assertThat(result.getPersistentId().get()).isEqualTo(persistentIdName);
assertThat(result.getEncryptedIdentityAssertionBlob().isPresent()).isTrue();
assertThat(result.getEncryptedIdentityAssertionBlob().get()).isEqualTo(identityUnderlyingAssertionBlob);
}
Aggregations