protected SAML2AuthenticationCredentials buildSAML2Credentials(final SAML2MessageContext context,
                                                                   final StatusResponseType response) {
        val subjectAssertion = context.getSubjectAssertion();

        val samlAttributes = collectAssertionAttributes(subjectAssertion);
        val attributes = SAML2AuthenticationCredentials.SAMLAttribute.from(configuration.getSamlAttributeConverter(), samlAttributes);

        val samlNameId = determineNameID(context, attributes);
        val sessionIndex = getSessionIndex(subjectAssertion);
        val sloKey = computeSloKey(sessionIndex, samlNameId);
        if (sloKey != null && logoutHandler != null) {
            logoutHandler.recordSession(context.getCallContext(), sloKey);
        }

        val issuerEntityId = subjectAssertion.getIssuer().getValue();
        val authnStatements = subjectAssertion.getAuthnStatements();
        final List<String> authnContexts = new ArrayList<>();
        final List<String> authnContextAuthorities = new ArrayList<>();
        for (val authnStatement : authnStatements) {
            if (authnStatement.getAuthnContext().getAuthenticatingAuthorities() != null) {
                authnContextAuthorities.addAll(authnStatement.getAuthnContext().getAuthenticatingAuthorities()
                    .stream().map(XSURI::getURI).toList());
            }
            if (authnStatement.getAuthnContext().getAuthnContextClassRef() != null) {
                authnContexts.add(authnStatement.getAuthnContext().getAuthnContextClassRef().getURI());
            }
        }
        return new SAML2AuthenticationCredentials(samlNameId, issuerEntityId, attributes,
            subjectAssertion.getConditions(), sessionIndex,
            authnContexts, authnContextAuthorities,
            response.getInResponseTo());
    }
<p>buildSAML2Credentials.</p>

@param context a {@link SAML2MessageContext} object
@param response a {@link Response} object
@return a {@link SAML2AuthenticationCredentials} object
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java