Search in sources :

Example 1 with AuthnContext

use of org.opensaml.saml2.core.AuthnContext in project webcert by sklintyg.

the class BaseFakeAuthenticationProvider method attachAuthenticationContext.

protected void attachAuthenticationContext(Assertion assertion, String authContextRef) {
    AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
    AuthnContext authnContext = new AuthnContextBuilder().buildObject();
    AuthnContextClassRef authnContextClassRef = new AuthnContextClassRefBuilder().buildObject();
    authnContextClassRef.setAuthnContextClassRef(authContextRef);
    authnContext.setAuthnContextClassRef(authnContextClassRef);
    authnStatement.setAuthnContext(authnContext);
    assertion.getAuthnStatements().add(authnStatement);
}
Also used : AuthnContextBuilder(org.opensaml.saml2.core.impl.AuthnContextBuilder) AuthnStatement(org.opensaml.saml2.core.AuthnStatement) AuthnContextClassRef(org.opensaml.saml2.core.AuthnContextClassRef) AuthnStatementBuilder(org.opensaml.saml2.core.impl.AuthnStatementBuilder) AuthnContextClassRefBuilder(org.opensaml.saml2.core.impl.AuthnContextClassRefBuilder) AuthnContext(org.opensaml.saml2.core.AuthnContext)

Example 2 with AuthnContext

use of org.opensaml.saml2.core.AuthnContext in project cloudstack by apache.

the class SAMLUtils method buildAuthnRequestObject.

public static AuthnRequest buildAuthnRequestObject(final String authnId, final String spId, final String idpUrl, final String consumerUrl) {
    // Issuer object
    IssuerBuilder issuerBuilder = new IssuerBuilder();
    Issuer issuer = issuerBuilder.buildObject();
    issuer.setValue(spId);
    // AuthnContextClass
    AuthnContextClassRefBuilder authnContextClassRefBuilder = new AuthnContextClassRefBuilder();
    AuthnContextClassRef authnContextClassRef = authnContextClassRefBuilder.buildObject(SAMLConstants.SAML20_NS, "AuthnContextClassRef", "saml");
    authnContextClassRef.setAuthnContextClassRef(AuthnContext.PPT_AUTHN_CTX);
    // AuthnContext
    RequestedAuthnContextBuilder requestedAuthnContextBuilder = new RequestedAuthnContextBuilder();
    RequestedAuthnContext requestedAuthnContext = requestedAuthnContextBuilder.buildObject();
    requestedAuthnContext.setComparison(AuthnContextComparisonTypeEnumeration.EXACT);
    requestedAuthnContext.getAuthnContextClassRefs().add(authnContextClassRef);
    // Creation of AuthRequestObject
    AuthnRequestBuilder authRequestBuilder = new AuthnRequestBuilder();
    AuthnRequest authnRequest = authRequestBuilder.buildObject();
    authnRequest.setID(authnId);
    authnRequest.setDestination(idpUrl);
    authnRequest.setVersion(SAMLVersion.VERSION_20);
    authnRequest.setForceAuthn(false);
    authnRequest.setIsPassive(false);
    authnRequest.setIssueInstant(new DateTime());
    authnRequest.setProtocolBinding(SAMLConstants.SAML2_POST_BINDING_URI);
    authnRequest.setAssertionConsumerServiceURL(consumerUrl);
    authnRequest.setProviderName(spId);
    authnRequest.setIssuer(issuer);
    authnRequest.setRequestedAuthnContext(requestedAuthnContext);
    return authnRequest;
}
Also used : RequestedAuthnContextBuilder(org.opensaml.saml2.core.impl.RequestedAuthnContextBuilder) RequestedAuthnContext(org.opensaml.saml2.core.RequestedAuthnContext) AuthnRequest(org.opensaml.saml2.core.AuthnRequest) Issuer(org.opensaml.saml2.core.Issuer) AuthnContextClassRef(org.opensaml.saml2.core.AuthnContextClassRef) IssuerBuilder(org.opensaml.saml2.core.impl.IssuerBuilder) AuthnRequestBuilder(org.opensaml.saml2.core.impl.AuthnRequestBuilder) AuthnContextClassRefBuilder(org.opensaml.saml2.core.impl.AuthnContextClassRefBuilder) DateTime(org.joda.time.DateTime)

Example 3 with AuthnContext

use of org.opensaml.saml2.core.AuthnContext in project cas by apereo.

the class AbstractSaml20ObjectBuilder method newAuthnStatement.

/**
 * New authn statement.
 *
 * @param contextClassRef the context class ref such as {@link AuthnContext#PASSWORD_AUTHN_CTX}
 * @param authnInstant    the authn instant
 * @param sessionIndex    the session index
 * @return the authn statement
 */
public AuthnStatement newAuthnStatement(final String contextClassRef, final ZonedDateTime authnInstant, final String sessionIndex) {
    LOGGER.debug("Building authentication statement with context class ref [{}] @ [{}] with index [{}]", contextClassRef, authnInstant, sessionIndex);
    final AuthnStatement stmt = newSamlObject(AuthnStatement.class);
    final AuthnContext ctx = newSamlObject(AuthnContext.class);
    final AuthnContextClassRef classRef = newSamlObject(AuthnContextClassRef.class);
    classRef.setAuthnContextClassRef(contextClassRef);
    ctx.setAuthnContextClassRef(classRef);
    stmt.setAuthnContext(ctx);
    stmt.setAuthnInstant(DateTimeUtils.dateTimeOf(authnInstant));
    stmt.setSessionIndex(sessionIndex);
    return stmt;
}
Also used : AuthnStatement(org.opensaml.saml.saml2.core.AuthnStatement) AuthnContextClassRef(org.opensaml.saml.saml2.core.AuthnContextClassRef) AuthnContext(org.opensaml.saml.saml2.core.AuthnContext)

Aggregations

AuthnContextClassRef (org.opensaml.saml2.core.AuthnContextClassRef)2 AuthnContextClassRefBuilder (org.opensaml.saml2.core.impl.AuthnContextClassRefBuilder)2 DateTime (org.joda.time.DateTime)1 AuthnContext (org.opensaml.saml.saml2.core.AuthnContext)1 AuthnContextClassRef (org.opensaml.saml.saml2.core.AuthnContextClassRef)1 AuthnStatement (org.opensaml.saml.saml2.core.AuthnStatement)1 AuthnContext (org.opensaml.saml2.core.AuthnContext)1 AuthnRequest (org.opensaml.saml2.core.AuthnRequest)1 AuthnStatement (org.opensaml.saml2.core.AuthnStatement)1 Issuer (org.opensaml.saml2.core.Issuer)1 RequestedAuthnContext (org.opensaml.saml2.core.RequestedAuthnContext)1 AuthnContextBuilder (org.opensaml.saml2.core.impl.AuthnContextBuilder)1 AuthnRequestBuilder (org.opensaml.saml2.core.impl.AuthnRequestBuilder)1 AuthnStatementBuilder (org.opensaml.saml2.core.impl.AuthnStatementBuilder)1 IssuerBuilder (org.opensaml.saml2.core.impl.IssuerBuilder)1 RequestedAuthnContextBuilder (org.opensaml.saml2.core.impl.RequestedAuthnContextBuilder)1