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