use of io.jans.as.model.uma.RPTResponse in project jans by JanssenProject.
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.assertIt(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