@Test public void testLogin() { String example = "{\"accessToken\":\"ttttttttttttttttt\",\"tokenTtl\":1000}"; JsonNode obj = JacksonUtils.toObj(example); if (obj.has(Constants.ACCESS_TOKEN)) { if (obj.has(Constants.ACCESS_TOKEN)) { assertEquals("ttttttttttttttttt", obj.get(Constants.ACCESS_TOKEN).asText()); assertEquals(1000, obj.get(Constants.TOKEN_TTL).asInt()); } } }
public boolean login(List<String> servers) { try { if ((System.currentTimeMillis() - lastRefreshTime) < TimeUnit.SECONDS .toMillis(tokenTtl - tokenRefreshWindow)) { return true; } for (String server : servers) { if (login(server)) { lastRefreshTime = System.currentTimeMillis(); return true; } } } catch (Throwable ignore) { } return false; }
SecurityProxy { public boolean login(List<String> servers) { try { if ((System.currentTimeMillis() - lastRefreshTime) < TimeUnit.SECONDS .toMillis(tokenTtl - tokenRefreshWindow)) { return true; } for (String server : servers) { if (login(server)) { lastRefreshTime = System.currentTimeMillis(); return true; } } } catch (Throwable ignore) { } return false; } }
SecurityProxy { public boolean login(List<String> servers) { try { if ((System.currentTimeMillis() - lastRefreshTime) < TimeUnit.SECONDS .toMillis(tokenTtl - tokenRefreshWindow)) { return true; } for (String server : servers) { if (login(server)) { lastRefreshTime = System.currentTimeMillis(); return true; } } } catch (Throwable ignore) { } return false; } SecurityProxy(Properties properties, NacosRestTemplate nacosRestTemplate); }
SecurityProxy { public boolean login(List<String> servers) { try { if ((System.currentTimeMillis() - lastRefreshTime) < TimeUnit.SECONDS .toMillis(tokenTtl - tokenRefreshWindow)) { return true; } for (String server : servers) { if (login(server)) { lastRefreshTime = System.currentTimeMillis(); return true; } } } catch (Throwable ignore) { } return false; } SecurityProxy(Properties properties, NacosRestTemplate nacosRestTemplate); boolean login(List<String> servers); boolean login(String server); String getAccessToken(); }
SecurityProxy { public boolean login(List<String> servers) { try { if ((System.currentTimeMillis() - lastRefreshTime) < TimeUnit.SECONDS .toMillis(tokenTtl - tokenRefreshWindow)) { return true; } for (String server : servers) { if (login(server)) { lastRefreshTime = System.currentTimeMillis(); return true; } } } catch (Throwable ignore) { } return false; } SecurityProxy(Properties properties, NacosRestTemplate nacosRestTemplate); boolean login(List<String> servers); boolean login(String server); String getAccessToken();  }