/** {@inheritDoc} */ protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException { AuthnContext authnContext = (AuthnContext) parentObject; if (childObject instanceof AuthnContextClassRef) { authnContext.setAuthnContextClassRef((AuthnContextClassRef) childObject); } else if (childObject instanceof AuthnContextDecl) { authnContext.setAuthnContextDecl((AuthnContextDecl) childObject); } else if (childObject instanceof AuthnContextDeclRef) { authnContext.setAuthnContextDeclRef((AuthnContextDeclRef) childObject); } else if (childObject instanceof AuthenticatingAuthority) { authnContext.getAuthenticatingAuthorities().add((AuthenticatingAuthority) childObject); } else { super.processChildElement(parentObject, childObject); } } }
if (statement.getAuthnContext() != null) { final AuthnContext ac = statement.getAuthnContext(); if (ac.getAuthnContextClassRef() != null) { return ac.getAuthnContextClassRef().getAuthnContextClassRef(); } else if (ac.getAuthnContextDeclRef() != null) { return ac.getAuthnContextDeclRef().getAuthnContextDeclRef();
/** * New authn statement. * * @param contextClassRef the context class ref such as {@link AuthnContext#PASSWORD_AUTHN_CTX} * @param authnInstant the authn instant * @return the authn statement */ public AuthnStatement newAuthnStatement(final String contextClassRef, final DateTime authnInstant) { 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(authnInstant); return stmt; }
final Principal matchingPrincipal = requestedPrincipalContext.getMatchingPrincipal(); if (matchingPrincipal instanceof AuthnContextClassRefPrincipal) { authnContext.setAuthnContextClassRef( ((AuthnContextClassRefPrincipal) matchingPrincipal).getAuthnContextClassRef()); } else if (matchingPrincipal instanceof AuthnContextDeclRefPrincipal) { authnContext.setAuthnContextDeclRef( ((AuthnContextDeclRefPrincipal) matchingPrincipal).getAuthnContextDeclRef()); } else { authnContext.setAuthnContextClassRef( classRefLookupStrategy.apply(profileRequestContext).getAuthnContextClassRef()); authnContext.setAuthnContextClassRef( classRefLookupStrategy.apply(profileRequestContext).getAuthnContextClassRef()); final AuthenticatingAuthority aa = authorityBuilder.buildObject(); aa.setURI(authority); authnContext.getAuthenticatingAuthorities().add(aa);
final List<String> authnContexts = new ArrayList<>(); for (final AuthnStatement authnStatement : authnStatements) { if(authnStatement.getAuthnContext().getAuthnContextClassRef() != null) { authnContexts.add(authnStatement.getAuthnContext().getAuthnContextClassRef().getAuthnContextClassRef());
); AuthnContext authnContext = authnContextBuilder.buildObject(); authnContext.setAuthnContextClassRef(authnContextClassRef); authnStatement.setAuthnContext(authnContext);
protected List<AuthenticationStatement> getAuthenticationStatements( List<AuthnStatement> authnStatements ) { List<AuthenticationStatement> result = new LinkedList<>(); for (AuthnStatement s : ofNullable(authnStatements).orElse(emptyList())) { AuthnContext authnContext = s.getAuthnContext(); AuthnContextClassRef authnContextClassRef = authnContext.getAuthnContextClassRef(); String ref = null; if (authnContextClassRef.getAuthnContextClassRef() != null) { ref = authnContextClassRef.getAuthnContextClassRef(); } result.add( new AuthenticationStatement() .setSessionIndex(s.getSessionIndex()) .setAuthInstant(s.getAuthnInstant()) .setSessionNotOnOrAfter(s.getSessionNotOnOrAfter()) .setAuthenticationContext( authnContext != null ? new AuthenticationContext() .setClassReference(AuthenticationContextClassReference.fromUrn(ref)) : null ) ); } return result; }
AuthnContextClassRef authCtxClassRef = new AuthnContextClassRefBuilder().buildObject(); authCtxClassRef.setAuthnContextClassRef(AuthnContext.PASSWORD_AUTHN_CTX); authContext.setAuthnContextClassRef(authCtxClassRef); authStmt.setAuthnContext(authContext); samlAssertion.getAuthnStatements().add(authStmt);
AuthnContextClassRef authCtxClassRef = new AuthnContextClassRefBuilder().buildObject(); authCtxClassRef.setAuthnContextClassRef(AuthnContext.PASSWORD_AUTHN_CTX); authContext.setAuthnContextClassRef(authCtxClassRef); authStmt.setAuthnContext(authContext); samlAssertion.getAuthnStatements().add(authStmt);
buildSAMLObject(org.opensaml.saml.saml2.core.AuthnContextClassRef.class); aref.setAuthnContextClassRef(stmt.getAuthenticationContext().getClassReference().toString()); actx.setAuthnContextClassRef(aref); authnStatement.setAuthnContext(actx); a.getAuthnStatements().add(authnStatement);