Search in sources :

Example 6 with RptIntrospectionResponse

use of org.gluu.oxauth.model.uma.RptIntrospectionResponse in project oxAuth by GluuFederation.

the class UmaSpontaneousScopeHttpTest method rptStatus.

@Test(dependsOnMethods = { "successfulRptRequest" })
@Parameters()
public void rptStatus() {
    showTitle("rptStatus");
    final RptIntrospectionResponse status = this.rptStatusService.requestRptStatus("Bearer " + pat.getAccessToken(), rpt, "");
    assert_(status);
    // at the end scope registered by permission must be present in RPT permission with scope allowed by spontaneous scope check
    assertTrue(status.getPermissions().get(0).getScopes().contains(USER_2_SCOPE));
}
Also used : RptIntrospectionResponse(org.gluu.oxauth.model.uma.RptIntrospectionResponse) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 7 with RptIntrospectionResponse

use of org.gluu.oxauth.model.uma.RptIntrospectionResponse in project oxAuth by GluuFederation.

the class TTokenRequest method requestRptStatus.

public RptIntrospectionResponse requestRptStatus(String p_umaRptStatusPath, final String rpt) {
    final Holder<RptIntrospectionResponse> h = new Holder<RptIntrospectionResponse>();
    try {
        Builder request = ResteasyClientBuilder.newClient().target(baseUri.toString() + p_umaRptStatusPath).request();
        request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
        // todo uma2
        // request.header("Authorization", "Bearer " + p_aat.getAccessToken());
        Response response = request.post(Entity.form(new Form("token", rpt)));
        String entity = response.readEntity(String.class);
        // try {
        // final String json =
        // ServerUtil.createJsonMapper().writeValueAsString(rpt);
        // request.setContent(Util.getBytes(json));
        // request.setContentType(UmaConstants.JSON_MEDIA_TYPE);
        // } catch (IOException e) {
        // e.printStackTrace();
        // fail();
        // }
        BaseTest.showResponse("UMA : TTokenRequest.requestRptStatus() : ", response, entity);
        assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Unexpected response code.");
        try {
            final RptIntrospectionResponse result = ServerUtil.createJsonMapper().readValue(entity, RptIntrospectionResponse.class);
            Assert.assertNotNull(result);
            h.setT(result);
        } catch (IOException 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) RptIntrospectionResponse(org.gluu.oxauth.model.uma.RptIntrospectionResponse) 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) IOException(java.io.IOException) JSONException(org.json.JSONException) IOException(java.io.IOException)

Aggregations

RptIntrospectionResponse (org.gluu.oxauth.model.uma.RptIntrospectionResponse)7 BaseTest (org.gluu.oxauth.BaseTest)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 Response (javax.ws.rs.core.Response)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 LinkedList (java.util.LinkedList)1 Builder (javax.ws.rs.client.Invocation.Builder)1 Form (javax.ws.rs.core.Form)1 HttpResponse (org.apache.http.HttpResponse)1 OxIntializationException (org.gluu.exception.OxIntializationException)1 Holder (org.gluu.oxauth.model.common.Holder)1 RPTResponse (org.gluu.oxauth.model.uma.RPTResponse)1 UmaPermission (org.gluu.oxauth.model.uma.UmaPermission)1 UmaPermission (org.gluu.oxauth.model.uma.persistence.UmaPermission)1 ExternalUmaRptClaimsContext (org.gluu.oxauth.service.external.context.ExternalUmaRptClaimsContext)1 UmaPCT (org.gluu.oxauth.uma.authorization.UmaPCT)1 UmaRPT (org.gluu.oxauth.uma.authorization.UmaRPT)1 Pair (org.gluu.util.Pair)1