class ClientCredentialsRequestValidatorImpl implements ClientCredentialsRequestValidator {

    public void validateRequest(OAuth2Request request, ClientRegistration clientRegistration)
            throws UnauthorizedClientException {

        if (!clientRegistration.isConfidential()) {
            logger.error("Client is not confidential. Public clients cannot use the client credentials grant.");
            throw new UnauthorizedClientException("Public clients can't use client credentials grant.");
        }
    }

}