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");
}
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;
}
}
Aggregations