use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformIpAddress.
@Test
public void transform_shouldTransformIpAddress() {
String ipAddy = "1.2.3.4";
Assertion theAssertion = anAssertion().addAttributeStatement(anAttributeStatement().addAttribute(anIPAddress().withValue(ipAddy).build()).build()).buildUnencrypted();
PassthroughAssertion authnStatementAssertion = unmarshaller.fromAssertion(theAssertion);
assertThat(authnStatementAssertion.getPrincipalIpAddressAsSeenByIdp().isPresent()).isEqualTo(true);
assertThat(authnStatementAssertion.getPrincipalIpAddressAsSeenByIdp().get()).isEqualTo(ipAddy);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldHandleFraudAuthnStatementAndSetThatAssertionIsForFraudulentEventAndSetFraudDetails.
@Test
public void transform_shouldHandleFraudAuthnStatementAndSetThatAssertionIsForFraudulentEventAndSetFraudDetails() {
final AuthnContextClassRef authnContextClassRef = anAuthnContextClassRef().withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_X_AUTHN_CTX).build();
Assertion theAssertion = anAssertion().addAuthnStatement(anAuthnStatement().withAuthnContext(anAuthnContext().withAuthnContextClassRef(authnContextClassRef).build()).build()).addAttributeStatement(anAttributeStatement().addAttribute(anIdpFraudEventIdAttribute().build()).addAttribute(aGpg45StatusAttribute().build()).build()).buildUnencrypted();
when(authnContextFactory.authnContextForLevelOfAssurance(IdaAuthnContext.LEVEL_X_AUTHN_CTX)).thenReturn(AuthnContext.LEVEL_X);
when(assertionStringTransformer.apply(theAssertion)).thenReturn("AUTHN_ASSERTION");
PassthroughAssertion authnStatementAssertion = unmarshaller.fromAssertion(theAssertion);
assertThat(authnStatementAssertion.isFraudulent()).isEqualTo(true);
assertThat(authnStatementAssertion.getFraudDetectedDetails().isPresent()).isEqualTo(true);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformTheGpg45StatusIt01ForAFraudAssertion.
@Test
public void transform_shouldTransformTheGpg45StatusIt01ForAFraudAssertion() {
String gpg45Status = "IT01";
Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
PassthroughAssertion passthroughAssertion = unmarshaller.fromAssertion(theAssertion);
FraudDetectedDetails fraudDetectedDetails = passthroughAssertion.getFraudDetectedDetails().get();
assertThat(fraudDetectedDetails.getFraudIndicator()).isEqualTo(gpg45Status);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldThrowExceptionWhenFraudIndicatorAuthnStatementDoesNotContainUniqueId.
@Test
public void transform_shouldThrowExceptionWhenFraudIndicatorAuthnStatementDoesNotContainUniqueId() {
Assertions.assertThrows(IllegalStateException.class, () -> {
Assertion theAssertion = anAssertion().addAuthnStatement(anAuthnStatement().withAuthnContext(anAuthnContext().withAuthnContextClassRef(anAuthnContextClassRef().withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_X_AUTHN_CTX).build()).build()).build()).buildUnencrypted();
when(authnContextFactory.authnContextForLevelOfAssurance(IdaAuthnContext.LEVEL_X_AUTHN_CTX)).thenReturn(AuthnContext.LEVEL_X);
when(assertionStringTransformer.apply(theAssertion)).thenReturn("AUTHN_ASSERTION");
unmarshaller.fromAssertion(theAssertion);
});
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class MatchingServiceAssertionToAssertionTransformer method transform.
public Assertion transform(MatchingServiceAssertion originalAssertion) {
Assertion transformedAssertion = openSamlXmlObjectFactory.createAssertion();
transformedAssertion.setIssueInstant(originalAssertion.getIssueInstant());
Issuer transformedIssuer = openSamlXmlObjectFactory.createIssuer(originalAssertion.getIssuerId());
transformedAssertion.setIssuer(transformedIssuer);
transformedAssertion.setID(originalAssertion.getId());
Subject subject = outboundAssertionToSubjectTransformer.transform(originalAssertion);
transformedAssertion.setSubject(subject);
MatchingServiceAuthnStatement authnStatement = originalAssertion.getAuthnStatement();
transformedAssertion.getAuthnStatements().add(matchingServiceAuthnStatementToAuthnStatementTransformer.transform(authnStatement));
Conditions conditions = openSamlXmlObjectFactory.createConditions();
AudienceRestriction audienceRestriction = openSamlXmlObjectFactory.createAudienceRestriction(originalAssertion.getAudience());
conditions.getAudienceRestrictions().add(audienceRestriction);
transformedAssertion.setConditions(conditions);
List<Attribute> userAttributesForAccountCreation = originalAssertion.getUserAttributesForAccountCreation();
if (!userAttributesForAccountCreation.isEmpty()) {
addAttributes(transformedAssertion, userAttributesForAccountCreation);
}
return transformedAssertion;
}
Aggregations