@Test void testDistributeInvalidateNotFoundApplication() { when(discoveryClient.getApplication("gateway")).thenReturn(null); assertFalse(authService.distributeInvalidate("instanceId")); }
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; }
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; } }
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; }  }
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; }  @PostConstruct void afterPropertiesSet(); String createJwtToken(String username, String domain, String ltpaToken); @CacheEvict(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken") @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, key = "#jwtToken", condition = "#jwtToken != null") Boolean invalidateJwtToken(String jwtToken, boolean distribute); @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, unless = "true", key = "#jwtToken", condition = "#jwtToken != null") Boolean isInvalidated(String jwtToken); @Cacheable(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication validateJwtToken(String jwtToken); @CachePut(value = "validationJwtToken", key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication createTokenAuthentication(String user, String jwtToken); boolean distributeInvalidate(String toInstanceId); TokenAuthentication validateJwtToken(TokenAuthentication token); QueryResponse parseJwtToken(String jwtToken); Optional<String> getJwtTokenFromRequest(HttpServletRequest request); String getLtpaTokenWithValidation(String jwtToken); String getLtpaToken(String jwtToken); }
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; }  @PostConstruct void afterPropertiesSet(); String createJwtToken(String username, String domain, String ltpaToken); @CacheEvict(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken") @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, key = "#jwtToken", condition = "#jwtToken != null") Boolean invalidateJwtToken(String jwtToken, boolean distribute); @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, unless = "true", key = "#jwtToken", condition = "#jwtToken != null") Boolean isInvalidated(String jwtToken); @Cacheable(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication validateJwtToken(String jwtToken); @CachePut(value = "validationJwtToken", key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication createTokenAuthentication(String user, String jwtToken); boolean distributeInvalidate(String toInstanceId); TokenAuthentication validateJwtToken(TokenAuthentication token); QueryResponse parseJwtToken(String jwtToken); Optional<String> getJwtTokenFromRequest(HttpServletRequest request); String getLtpaTokenWithValidation(String jwtToken); String getLtpaToken(String jwtToken);  }