Search in sources :

Example 1 with RPTResponse

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();
}
Also used : RptIntrospectionResponse(io.jans.as.model.uma.RptIntrospectionResponse) RPTResponse(io.jans.as.model.uma.RPTResponse) Response(javax.ws.rs.core.Response) JSONObject(org.json.JSONObject) Form(javax.ws.rs.core.Form) Holder(io.jans.as.model.common.Holder) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) JSONException(org.json.JSONException) IOException(java.io.IOException) RPTResponse(io.jans.as.model.uma.RPTResponse) JSONException(org.json.JSONException) IOException(java.io.IOException)

Aggregations

Holder (io.jans.as.model.common.Holder)1 RPTResponse (io.jans.as.model.uma.RPTResponse)1 RptIntrospectionResponse (io.jans.as.model.uma.RptIntrospectionResponse)1 IOException (java.io.IOException)1 Builder (javax.ws.rs.client.Invocation.Builder)1 Form (javax.ws.rs.core.Form)1 Response (javax.ws.rs.core.Response)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1