Search in sources :

Example 1 with RPTResponse

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();
}
Also used : RPTResponse(org.gluu.oxauth.model.uma.RPTResponse) RptIntrospectionResponse(org.gluu.oxauth.model.uma.RptIntrospectionResponse) Response(javax.ws.rs.core.Response) JSONObject(org.json.JSONObject) Form(javax.ws.rs.core.Form) Holder(org.gluu.oxauth.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(org.gluu.oxauth.model.uma.RPTResponse) JSONException(org.json.JSONException) IOException(java.io.IOException)

Aggregations

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 Holder (org.gluu.oxauth.model.common.Holder)1 RPTResponse (org.gluu.oxauth.model.uma.RPTResponse)1 RptIntrospectionResponse (org.gluu.oxauth.model.uma.RptIntrospectionResponse)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1