Search in sources :

Example 6 with TokenEntry

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);
}
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

TokenEntry (org.codice.ddf.security.token.storage.api.TokenInformation.TokenEntry)6 IOException (java.io.IOException)4 ParseException (com.nimbusds.oauth2.sdk.ParseException)3 OIDCProviderMetadata (com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata)3 URL (java.net.URL)3 Session (org.apache.shiro.session.Session)3 TokenInformation (org.codice.ddf.security.token.storage.api.TokenInformation)3 StopProcessingException (ddf.catalog.plugin.StopProcessingException)2 OAuthFederatedSource (ddf.catalog.source.OAuthFederatedSource)2 Subject (ddf.security.Subject)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 OAuthServiceException (org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException)2 DISCOVERY_URL (org.codice.ddf.security.token.storage.api.TokenStorage.DISCOVERY_URL)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 DefaultResourceRetriever (com.nimbusds.jose.util.DefaultResourceRetriever)1 ResourceRetriever (com.nimbusds.jose.util.ResourceRetriever)1 Scope (com.nimbusds.oauth2.sdk.Scope)1