use of com.sun.identity.rest.RestException in project OpenAM by OpenRock.
the class PrivilegeResource method privilege.
@GET
@Produces("application/json")
@Path("/{name}")
public String privilege(@Context HttpHeaders headers, @Context HttpServletRequest request, @QueryParam("realm") @DefaultValue("/") String realm, @PathParam("name") String name) {
try {
Subject caller = getCaller(request);
PrivilegeManager pm = PrivilegeManager.getInstance(realm, caller);
Privilege privilege = pm.findByName(name);
JSONObject jo = new JSONObject();
jo.put(RESULT, privilege.toMinimalJSONObject());
return createResponseJSONString(200, headers, jo);
} catch (JSONException e) {
PrivilegeManager.debug.error("PrivilegeResource.privilege", e);
throw getWebApplicationException(e, MimeType.JSON);
} catch (RestException e) {
PrivilegeManager.debug.error("PrivilegeResource.privilege", e);
throw getWebApplicationException(headers, e, MimeType.JSON);
} catch (EntitlementException e) {
PrivilegeManager.debug.error("PrivilegeResource.privilege", e);
throw getWebApplicationException(headers, e, MimeType.JSON);
}
}
Aggregations