use of org.opensaml.saml2.core.AuthnStatement in project verify-hub by alphagov.
the class AuthnStatementAssertionValidatorTest method validate_shouldThrowExceptionIfAuthnContextIsAbsent.
@Test
public void validate_shouldThrowExceptionIfAuthnContextIsAbsent() throws Exception {
AuthnStatement authnStatement = AuthnStatementBuilder.anAuthnStatement().withAuthnContext(null).build();
Assertion assertion = AssertionBuilder.anAssertion().addAuthnStatement(authnStatement).buildUnencrypted();
validateFail(() -> validator.validate(assertion), authnContextMissingError());
}
use of org.opensaml.saml2.core.AuthnStatement in project verify-hub by alphagov.
the class AuthnStatementAssertionValidatorTest method validate_shouldPassValidation.
@Test
public void validate_shouldPassValidation() throws Exception {
AuthnStatement authnStatement = AuthnStatementBuilder.anAuthnStatement().build();
Assertion assertion = AssertionBuilder.anAssertion().addAuthnStatement(authnStatement).buildUnencrypted();
validator.validate(assertion);
}
use of org.opensaml.saml2.core.AuthnStatement in project verify-hub by alphagov.
the class MatchingServiceAuthnStatementToAuthnStatementTransformer method transform.
public AuthnStatement transform(MatchingServiceAuthnStatement idaAuthnStatement) {
AuthnStatement authnStatement = openSamlXmlObjectFactory.createAuthnStatement();
AuthnContext authnContext = openSamlXmlObjectFactory.createAuthnContext();
authnContext.setAuthnContextClassRef(openSamlXmlObjectFactory.createAuthnContextClassReference(idaAuthnStatement.getAuthnContext().getUri()));
authnStatement.setAuthnContext(authnContext);
authnStatement.setAuthnInstant(DateTime.now());
return authnStatement;
}
use of org.opensaml.saml2.core.AuthnStatement in project cloudstack by apache.
the class SAML2LoginAPIAuthenticatorCmdTest method buildMockResponse.
private Response buildMockResponse() throws Exception {
Response samlMessage = new ResponseBuilder().buildObject();
samlMessage.setID("foo");
samlMessage.setVersion(SAMLVersion.VERSION_20);
samlMessage.setIssueInstant(new DateTime(0));
Issuer issuer = new IssuerBuilder().buildObject();
issuer.setValue("MockedIssuer");
samlMessage.setIssuer(issuer);
Status status = new StatusBuilder().buildObject();
StatusCode statusCode = new StatusCodeBuilder().buildObject();
statusCode.setValue(StatusCode.SUCCESS_URI);
status.setStatusCode(statusCode);
samlMessage.setStatus(status);
Assertion assertion = new AssertionBuilder().buildObject();
Subject subject = new SubjectBuilder().buildObject();
NameID nameID = new NameIDBuilder().buildObject();
nameID.setValue("SOME-UNIQUE-ID");
nameID.setFormat(NameIDType.PERSISTENT);
subject.setNameID(nameID);
assertion.setSubject(subject);
AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
authnStatement.setSessionIndex("Some Session String");
assertion.getAuthnStatements().add(authnStatement);
AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
assertion.getAttributeStatements().add(attributeStatement);
samlMessage.getAssertions().add(assertion);
return samlMessage;
}
Aggregations