default <T> T getFirstAttribute(final String name, final Class<T> clazz) {
        val values = getAttributeAs(name, List.class);
        return values == null || values.isEmpty() ? null : clazz.cast(values.getFirst());
    }
Gets first attribute value with requested type.

@param <T>   the type parameter
@param name  the name
@param clazz the clazz
@return the first attribute
api/cas-server-core-api-authentication/src/main/java/org/apereo/cas/authentication/principal/Service.java