@@ -0,0 +1,1141 @@
+package org.owasp.appsensor.rest;%0A%0Aimport javax.ws.rs.container.ContainerRequestContext;%0A%0Aimport org.owasp.appsensor.AppSensorServer;%0Aimport org.owasp.appsensor.ClientApplication;%0Aimport org.owasp.appsensor.RequestHandler;%0Aimport org.owasp.appsensor.accesscontrol.Action;%0Aimport org.owasp.appsensor.exceptions.NotAuthorizedException;%0A%0Apublic class AccessControlUtils %7B%0A%0A%09/**%0A%09 * Check authz before performing action.%0A%09 * @param action desired action%0A%09 * @throws NotAuthorizedException thrown if user does not have role.%0A%09 */%0A%09public static void checkAuthorization(Action action, ContainerRequestContext requestContext) throws NotAuthorizedException %7B%0A%09%09String clientApplicationName = (String)requestContext.getProperty(RequestHandler.APPSENSOR_CLIENT_APPLICATION_IDENTIFIER_ATTR);%0A%0A%09%09ClientApplication clientApplication = AppSensorServer.getInstance().getConfiguration().findClientApplication(clientApplicationName);%0A%09%09%0A%09%09org.owasp.appsensor.accesscontrol.Context context = new org.owasp.appsensor.accesscontrol.Context();%0A%09%09%0A%09%09AppSensorServer.getInstance().getAccessController().assertAuthorized(clientApplication, action, context);%0A%09%7D%0A%09%0A%7D%0A

access control helper