use of io.jans.as.model.uma.UmaScopeDescription in project jans by JanssenProject.
the class ScopeHttpTest method scopePresence.
@Test
@Parameters({ "umaMetaDataUrl" })
public void scopePresence(final String umaMetaDataUrl) {
final UmaMetadata metadata = UmaClientFactory.instance().createMetadataService(umaMetaDataUrl).getMetadata();
final UmaScopeService scopeService = UmaClientFactory.instance().createScopeService(metadata.getScopeEndpoint());
final UmaScopeDescription modifyScope = scopeService.getScope("modify");
UmaTestUtil.assertIt(modifyScope);
}
use of io.jans.as.model.uma.UmaScopeDescription in project jans by JanssenProject.
the class UmaScopeWSTest method scopePresence.
@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.assertIt(scope);
}
use of io.jans.as.model.uma.UmaScopeDescription in project jans by JanssenProject.
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);
errorResponseFactory.validateComponentEnabled(ComponentType.UMA);
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.");
}
Aggregations