Search in sources :

Example 1 with WebFingerLink

use of org.xdi.oxauth.model.discovery.WebFingerLink in project oxAuth by GluuFederation.

the class OpenIdConnectDiscoveryClient method _exec2.

private OpenIdConnectDiscoveryResponse _exec2() {
    // Prepare request parameters
    clientRequest.accept(MEDIA_TYPE);
    clientRequest.setHttpMethod(getHttpMethod());
    if (StringUtils.isNotBlank(getRequest().getResource())) {
        clientRequest.queryParameter(RESOURCE, getRequest().getResource());
    }
    clientRequest.queryParameter(REL, REL_VALUE);
    // Call REST Service and handle response
    ClientResponse<String> clientResponse1;
    try {
        clientResponse1 = clientRequest.get(String.class);
        int status = clientResponse1.getStatus();
        setResponse(new OpenIdConnectDiscoveryResponse(status));
        String entity = clientResponse1.getEntity(String.class);
        getResponse().setEntity(entity);
        getResponse().setHeaders(clientResponse1.getMetadata());
        if (StringUtils.isNotBlank(entity)) {
            JSONObject jsonObj = new JSONObject(entity);
            getResponse().setSubject(jsonObj.getString(SUBJECT));
            JSONArray linksJsonArray = jsonObj.getJSONArray(LINKS);
            for (int i = 0; i < linksJsonArray.length(); i++) {
                WebFingerLink webFingerLink = new WebFingerLink();
                webFingerLink.setRel(linksJsonArray.getJSONObject(i).getString(REL));
                webFingerLink.setHref(linksJsonArray.getJSONObject(i).getString(HREF));
                getResponse().getLinks().add(webFingerLink);
            }
        }
    } catch (JSONException e) {
        LOG.error(e.getMessage(), e);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
    return getResponse();
}
Also used : WebFingerLink(org.xdi.oxauth.model.discovery.WebFingerLink) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) JSONException(org.codehaus.jettison.json.JSONException) URISyntaxException(java.net.URISyntaxException) JSONException(org.codehaus.jettison.json.JSONException)

Aggregations

URISyntaxException (java.net.URISyntaxException)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONException (org.codehaus.jettison.json.JSONException)1 JSONObject (org.codehaus.jettison.json.JSONObject)1 WebFingerLink (org.xdi.oxauth.model.discovery.WebFingerLink)1