use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxAuth by GluuFederation.
the class UmaScopeWS method getScopeDescription.
@GET
@Path("{id}")
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
public Response getScopeDescription(@PathParam("id") String id) {
log.trace("UMA - get scope description: id: {}", id);
try {
if (StringUtils.isNotBlank(id)) {
final Scope scope = umaScopeService.getScope(id);
if (scope != null) {
final UmaScopeDescription jsonScope = new UmaScopeDescription();
jsonScope.setIconUri(scope.getIconUrl());
jsonScope.setName(scope.getId());
jsonScope.setDescription(scope.getDescription());
return Response.status(Response.Status.OK).entity(ServerUtil.asJson(jsonScope)).build();
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw errorResponseFactory.createWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, UmaErrorResponseType.SERVER_ERROR, "Internal error.");
}
throw errorResponseFactory.createWebApplicationException(Response.Status.NOT_FOUND, UmaErrorResponseType.NOT_FOUND, "Not found.");
}
use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxAuth by GluuFederation.
the class UmaScopeWSTest method scopePresence.
// private MetadataConfiguration m_configuration;
//
// @Parameters({"umaConfigurationPath"})
// @Test
// public void init(final String umaConfigurationPath) {
// m_configuration = TUma.requestConfiguration(this, umaConfigurationPath);
// UmaTestUtil.assert_(m_configuration);
// }
@Parameters({ "umaScopePath" })
@Test
public void scopePresence(final String umaScopePath) throws Exception {
String path = umaScopePath + "/" + "modify";
System.out.println("Path: " + path);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + path).request();
request.header("Accept", UmaConstants.JSON_MEDIA_TYPE);
Response response = request.get();
String entity = response.readEntity(String.class);
BaseTest.showResponse("UMA : UmaScopeWSTest.scopePresence() : ", response, entity);
assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Unexpected response code.");
final UmaScopeDescription scope = TUma.readJsonValue(entity, UmaScopeDescription.class);
UmaTestUtil.assert_(scope);
}
Aggregations