protected boolean doesClientIdBelongToRegisteredService(final OAuthRegisteredService registeredService, final Service service) {
        LOGGER.trace("Attempting to locate service [{}] via [{}]", service, registeredService);
        val clientIdAttribute = service.getAttributes().get(OAuth20Constants.CLIENT_ID);
        val clientId = CollectionUtils.firstElement(clientIdAttribute).map(Object::toString).orElse(StringUtils.EMPTY);
        return StringUtils.isNotBlank(clientId) && StringUtils.equals(registeredService.getClientId(), clientId);
    }
This is {@link OAuth20ServicesManagerRegisteredServiceLocator}.

@author Misagh Moayyed
@since 6.3.0
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/services/OAuth20ServicesManagerRegisteredServiceLocator.java