class AuthenticationService {

    public boolean distributeInvalidate(String toInstanceId) {
        final Application application = discoveryClient.getApplication(CoreService.GATEWAY.getServiceId());
        if (application == null) return false;

        final InstanceInfo instanceInfo = application.getByInstanceId(toInstanceId);
        if (instanceInfo == null) return false;

        final String url = EurekaUtils.getUrl(instanceInfo) + AuthController.CONTROLLER_PATH + "/invalidate/{}";

        final Collection<String> invalidated = cacheUtils.getAllRecords(cacheManager, CACHE_INVALIDATED_JWT_TOKENS);
        for (final String invalidatedToken : invalidated) {
            restTemplate.delete(url, invalidatedToken);
        }

        return true;
    }

}