Search in sources :

Example 1 with TokenInformationImpl

use of org.codice.ddf.security.token.storage.api.TokenInformationImpl 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);
}
Also used : TokenEntry(org.codice.ddf.security.token.storage.api.TokenInformation.TokenEntry) HashMap(java.util.HashMap) TokenInformationImpl(org.codice.ddf.security.token.storage.api.TokenInformationImpl) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TokenEntry (org.codice.ddf.security.token.storage.api.TokenInformation.TokenEntry)1 TokenInformationImpl (org.codice.ddf.security.token.storage.api.TokenInformationImpl)1