Search in sources :

Example 1 with ResourceSetWithId

use of org.xdi.oxauth.model.uma.ResourceSetWithId in project oxAuth by GluuFederation.

the class RegisterResourceSetFlowHttpTest method testGetOneResourceSet.

/**
     * Test for getting UMA resource set descriptions
     */
@Test(dependsOnMethods = { "testModifyResourceSet" })
public void testGetOneResourceSet() throws Exception {
    showTitle("testGetResourceSets");
    ResourceSetRegistrationService resourceSetRegistrationService = UmaClientFactory.instance().createResourceSetRegistrationService(this.metadataConfiguration);
    // Get list of resource set descriptions
    ResourceSetWithId resourceSets = null;
    try {
        resourceSets = resourceSetRegistrationService.getResourceSet("Bearer " + m_pat.getAccessToken(), this.resourceSetId);
    } catch (ClientResponseFailure ex) {
        System.err.println(ex.getResponse().getEntity(String.class));
        throw ex;
    }
    assertNotNull(resourceSets, "Resource set descriptions is null");
}
Also used : ResourceSetRegistrationService(org.xdi.oxauth.client.uma.ResourceSetRegistrationService) ResourceSetWithId(org.xdi.oxauth.model.uma.ResourceSetWithId) ClientResponseFailure(org.jboss.resteasy.client.ClientResponseFailure) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 2 with ResourceSetWithId

use of org.xdi.oxauth.model.uma.ResourceSetWithId in project oxAuth by GluuFederation.

the class ResourceSetRegistrationWS method getResourceSet.

@GET
@Path("{rsid}")
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "Reads a previously registered resource set description using the GET method.", notes = "Reads a previously registered resource set description using the GET method. If the request is successful, the authorization server MUST respond with a status message that includes a body containing the referenced resource set description, along with an \"_id\" property.", response = ResourceSet.class)
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized") })
public Response getResourceSet(@HeaderParam("Authorization") String authorization, @PathParam("rsid") @ApiParam(value = "Resource set description object ID", required = true) String rsid) {
    try {
        umaValidationService.assertHasProtectionScope(authorization);
        log.debug("Getting resource set description: '{}'", rsid);
        final org.xdi.oxauth.model.uma.persistence.ResourceSet ldapResourceSet = resourceSetService.getResourceSetById(rsid);
        final ResourceSetWithId response = new ResourceSetWithId();
        response.setId(ldapResourceSet.getId());
        response.setName(ldapResourceSet.getName());
        response.setUri(ldapResourceSet.getUrl());
        response.setIconUri(ldapResourceSet.getIconUri());
        response.setScopes(umaScopeService.getScopeUrlsByDns(ldapResourceSet.getScopes()));
        final ResponseBuilder builder = Response.ok();
        // convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
        builder.entity(ServerUtil.asJson(response));
        return builder.build();
    } catch (Exception ex) {
        log.error("Exception happened", ex);
        if (ex instanceof WebApplicationException) {
            throw (WebApplicationException) ex;
        }
        errorResponseFactory.throwUmaInternalErrorException();
        // redundant but required statement by java
        return null;
    }
}
Also used : ResourceSetWithId(org.xdi.oxauth.model.uma.ResourceSetWithId) WebApplicationException(javax.ws.rs.WebApplicationException) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Aggregations

ResourceSetWithId (org.xdi.oxauth.model.uma.ResourceSetWithId)2 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 ClientResponseFailure (org.jboss.resteasy.client.ClientResponseFailure)1 Test (org.testng.annotations.Test)1 BaseTest (org.xdi.oxauth.BaseTest)1 ResourceSetRegistrationService (org.xdi.oxauth.client.uma.ResourceSetRegistrationService)1