protected Client validateClient(BasicAuthCredentials credentials) {
String clientId = credentials.getUsername();
Client client = StringUtils.isBlank(clientId) ? null : clientRepository.findByClientId(clientId);
if (client == null) {
throw new ValidationResponseException(UNKNOWN_CLIENT_ID);
} else if (!client.verifySecret(credentials.getPassword())) {
throw new ValidationResponseException(UNAUTHORIZED_CLIENT);
}
return client;
}