use of org.gluu.oxauth.model.uma.RPTResponse in project oxAuth by GluuFederation.
the class TTokenRequest method requestRpt.
// todo UMA2
public RPTResponse requestRpt(final String p_rptPath) {
final Holder<RPTResponse> h = new Holder<RPTResponse>();
try {
Builder request = ResteasyClientBuilder.newClient().target(baseUri.toString() + p_rptPath).request();
request.header("Accept", UmaConstants.JSON_MEDIA_TYPE);
// request.header("Authorization", "Bearer " + p_aat.getAccessToken());
Response response = request.post(Entity.form(new Form()));
String entity = response.readEntity(String.class);
BaseTest.showResponse("UMA : TTokenRequest.requestRpt() : ", response, entity);
assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(), "Unexpected response code.");
try {
String tokenResponse = entity;
final JSONObject jsonObj = new JSONObject(tokenResponse);
if (jsonObj.has("requesterPermissionTokenResponse")) {
tokenResponse = jsonObj.get("requesterPermissionTokenResponse").toString();
}
System.out.println("Token response = " + tokenResponse);
RPTResponse result = ServerUtil.createJsonMapper().readValue(tokenResponse, RPTResponse.class);
UmaTestUtil.assert_(result);
h.setT(result);
} catch (IOException e) {
e.printStackTrace();
fail();
} catch (JSONException e) {
e.printStackTrace();
fail();
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
return h.getT();
}
Aggregations