protected SAML2AuthenticationCredentials.SAMLNameID determineNameID(final SAML2MessageContext context,
                final Collection<SAML2AuthenticationCredentials.SAMLAttribute> attributes) {
        var configContext = context.getConfigurationContext();
        if (configContext.getNameIdAttribute() != null) {
            val nameId = attributes
                .stream()
                .filter(attribute -> attribute.getName().equals(configContext.getNameIdAttribute()))
                .findFirst()
                .map(SAML2AuthenticationCredentials.SAMLNameID::from);
            if (nameId.isPresent()) {
                return nameId.get();
            }
        }
        val nameId = Objects.requireNonNull(context.getSAMLSubjectNameIdentifierContext().getSAML2SubjectNameID());
        return SAML2AuthenticationCredentials.SAMLNameID.from(nameId);
    }
<p>determineNameID.</p>

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