public static Optional<NameIDPolicy> getNameIDPolicy(final RequestAbstractType authnRequest) {
        if (authnRequest instanceof final AuthnRequest instance) {
            return Optional.ofNullable(instance.getNameIDPolicy());
        }
        return Optional.empty();
    }
Gets name id policy.

@param authnRequest the authn request
@return the name id policy
support/cas-server-support-saml-idp-core/src/main/java/org/apereo/cas/support/saml/SamlIdPUtils.java