use of org.codice.ddf.security.token.storage.api.TokenInformation.TokenEntry in project ddf by codice.
the class TokenInformationUtil method fromJson.
/**
* Creates a token information from a json representation
*
* @param idHash - the ID's hash
* @param json - the JSON representation of the data
*/
static TokenInformation fromJson(String idHash, String json) {
Map<String, Object> jsonMap = GSON.fromJson(json, MAP_STRING_TO_OBJECT_TYPE);
Map<String, TokenEntry> tokenEntryMap = new HashMap<>();
Set<String> discoveryUrls = new HashSet<>();
for (Map.Entry<String, Object> sourceVal : jsonMap.entrySet()) {
Map tokens = (Map) sourceVal.getValue();
discoveryUrls.add((String) tokens.get(DISCOVERY_URL));
tokenEntryMap.put(sourceVal.getKey(), new TokenInformationImpl.TokenEntryImpl((String) tokens.get(ACCESS_TOKEN), (String) tokens.get(REFRESH_TOKEN), (String) tokens.get(DISCOVERY_URL)));
}
return new TokenInformationImpl(idHash, tokenEntryMap, discoveryUrls, json);
}
Aggregations