ResourceServer resourceServer = getResourceServer(request, resourceServerId);
return clientRepository.findByIdAndResourceServer(clientId, resourceServer);
}
private ResourceServer getResourceServer(HttpServletRequest request, Long id) {
ResourceServer resourceServer;
if (isAdminPrincipal(request)) {
resourceServer = resourceServerRepository.findOne(id);
} else {
String owner = getUserId(request);
resourceServer = resourceServerRepository.findByIdAndOwner(id, owner);