ZTSAccessTokenFileLoader { public void preload() { File dir = new File(path); if (dir.exists() && dir.isDirectory()) { for (File domainDir: dir.listFiles()) { if (domainDir.isDirectory()) { for (File tokenFile: domainDir.listFiles()) { if (!tokenFile.isDirectory()) { AccessTokenResponse accessTokenResponse = null; try { accessTokenResponse = objectMapper.readValue(tokenFile, AccessTokenResponse.class); } catch (IOException e) { LOG.error("Failed to load or parse token file: {}", tokenFile); } if (accessTokenResponse == null) { continue; } AccessTokenResponseCacheEntry cacheEntry = new AccessTokenResponseCacheEntry(accessTokenResponse); if (!cacheEntry.isExpired(-1)) { addToRoleMap(domainDir.getName(), tokenFile.getName(), accessTokenResponse); } } } } } } } ZTSAccessTokenFileLoader(JwtsSigningKeyResolver resolver); void preload(); AccessTokenResponse lookupAccessTokenFromDisk(String domain, List<String> rolesName); static final String ACCESS_TOKEN_PATH_PROPERTY; }
@Test public void voidTestPreload() { ZTSAccessTokenFileLoader ztsAccessTokenFileLoader = new ZTSAccessTokenFileLoader(resolver); ztsAccessTokenFileLoader.preload(); }