org.opensaml.saml2.core.impl.AuthnStatementBuilder Java Examples
The following examples show how to use
org.opensaml.saml2.core.impl.AuthnStatementBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthnStatementGenerator.java From MaxKey with Apache License 2.0 | 6 votes |
public AuthnStatement generateAuthnStatement(DateTime authnInstant) { //Response/Assertion/AuthnStatement/AuthContext/AuthContextClassRef AuthnContextClassRef authnContextClassRef = new AuthnContextClassRefBuilder().buildObject(); //urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport authnContextClassRef.setAuthnContextClassRef(AuthnContext.PPT_AUTHN_CTX); //Response/Assertion/AuthnStatement/AuthContext AuthnContext authnContext = new AuthnContextBuilder().buildObject(); authnContext.setAuthnContextClassRef(authnContextClassRef); //Response/Assertion/AuthnStatement AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject(); authnStatement.setAuthnContext(authnContext); authnStatement.setAuthnInstant(authnInstant); logger.debug("generateAuthnStatement authnInstant "+authnInstant); return authnStatement; }
Example #2
Source File: SamlAssertionProducer.java From saml-generator with Apache License 2.0 | 6 votes |
private AuthnStatement createAuthnStatement(final DateTime issueDate) { // create authcontextclassref object AuthnContextClassRefBuilder classRefBuilder = new AuthnContextClassRefBuilder(); AuthnContextClassRef classRef = classRefBuilder.buildObject(); classRef.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); // create authcontext object AuthnContextBuilder authContextBuilder = new AuthnContextBuilder(); AuthnContext authnContext = authContextBuilder.buildObject(); authnContext.setAuthnContextClassRef(classRef); // create authenticationstatement object AuthnStatementBuilder authStatementBuilder = new AuthnStatementBuilder(); AuthnStatement authnStatement = authStatementBuilder.buildObject(); authnStatement.setAuthnInstant(issueDate); authnStatement.setAuthnContext(authnContext); return authnStatement; }
Example #3
Source File: SAML2LoginAPIAuthenticatorCmdTest.java From cloudstack with Apache License 2.0 | 5 votes |
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; }