use of uk.gov.ida.saml.core.domain.PassthroughAssertion 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.saml.core.domain.PassthroughAssertion in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorServiceTest method shouldEncryptMatchingDatasetAssertion.
@Test
public void shouldEncryptMatchingDatasetAssertion() throws Exception {
PassthroughAssertion assertion = Mockito.mock(PassthroughAssertion.class);
when(assertion.getUnderlyingAssertionBlob()).thenReturn(matchingDatasetUnderlyingAssertionBlob);
when(responseFromIdp.getMatchingDatasetAssertion()).thenReturn(of(assertion));
String expectedEncryptedBlob = "some-value";
final String entityId = "entity-id";
when(responseContainer.getMatchingServiceEntityId()).thenReturn(entityId);
when(assertionBlobEncrypter.encryptAssertionBlob(entityId, matchingDatasetUnderlyingAssertionBlob)).thenReturn(expectedEncryptedBlob);
InboundResponseFromIdpDto result = translateAndCheckCommonFields();
assertThat(result.getEncryptedMatchingDatasetAssertion().get()).isEqualTo(expectedEncryptedBlob);
}
use of uk.gov.ida.saml.core.domain.PassthroughAssertion 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);
}
Aggregations