public static <T extends OAuthRegisteredService> T getRegisteredOAuthServiceByClientId(final ServicesManager servicesManager,
                                                                                           final String clientId,
                                                                                           final Class<T> clazz) {
        return FunctionUtils.doIfNotBlank(clientId,
            () -> {
                val query = RegisteredServiceQuery.of(OAuthRegisteredService.class, "clientId", clientId).withIncludeAssignableTypes(true);
                return servicesManager.findServicesBy(query).findFirst().map(clazz::cast).orElse(null);
            },
            () -> null);
    }
Gets registered oauth service by client id.

@param <T>             the type parameter
@param servicesManager the services manager
@param clientId        the client id
@param clazz           the clazz
@return the registered o auth service by client id
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java