Search in sources :

Example 6 with Client

use of org.forgerock.openidconnect.Client in project OpenAM by OpenRock.

the class TokenResource method handleResponse.

private Promise<QueryResponse, ResourceException> handleResponse(QueryResourceHandler handler, JsonValue response, Context context) throws UnauthorizedClientException, CoreTokenException, InternalServerErrorException, NotFoundException {
    ResourceResponse resource = newResourceResponse("result", "1", response);
    JsonValue value = resource.getContent();
    String acceptLanguage = context.asContext(HttpContext.class).getHeaderAsString("accept-language");
    Set<HashMap<String, Set<String>>> list = (Set<HashMap<String, Set<String>>>) value.getObject();
    ResourceResponse res;
    JsonValue val;
    if (list != null && !list.isEmpty()) {
        for (HashMap<String, Set<String>> entry : list) {
            val = new JsonValue(entry);
            res = newResourceResponse("result", "1", val);
            Client client = getClient(val);
            val.put(EXPIRE_TIME_KEY, getExpiryDate(json(entry), context));
            val.put(OAuth2Constants.ShortClientAttributeNames.DISPLAY_NAME.getType(), getClientName(client));
            val.put(OAuth2Constants.ShortClientAttributeNames.SCOPES.getType(), getScopes(client, val, acceptLanguage));
            handler.handleResource(res);
        }
    }
    return newResultPromise(newQueryResponse());
}
Also used : Set(java.util.Set) ResourceResponse(org.forgerock.json.resource.ResourceResponse) HashMap(java.util.HashMap) JsonValue(org.forgerock.json.JsonValue) HttpContext(org.forgerock.json.resource.http.HttpContext) Client(org.forgerock.openidconnect.Client)

Aggregations

Client (org.forgerock.openidconnect.Client)6 JsonValue (org.forgerock.json.JsonValue)3 InvalidRequestException (org.forgerock.oauth2.core.exceptions.InvalidRequestException)3 UnauthorizedClientException (org.forgerock.oauth2.core.exceptions.UnauthorizedClientException)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 InvalidTokenException (org.forgerock.oauth2.core.exceptions.InvalidTokenException)2 InvalidClientMetadata (org.forgerock.openidconnect.exceptions.InvalidClientMetadata)2 SSOException (com.iplanet.sso.SSOException)1 SSOToken (com.iplanet.sso.SSOToken)1 AMIdentity (com.sun.identity.idm.AMIdentity)1 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 IdSearchControl (com.sun.identity.idm.IdSearchControl)1 IdSearchResults (com.sun.identity.idm.IdSearchResults)1 ValidationException (com.sun.identity.shared.validation.ValidationException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1