Check authz before performing action.

@param action desired action
@throws NotAuthorizedException thrown if user does not have role.
169326
public void checkAuthorization(Action action, ContainerRequestContext requestContext) throws NotAuthorizedException {
		String clientApplicationName = (String)requestContext.getProperty(RequestHandler.APPSENSOR_CLIENT_APPLICATION_IDENTIFIER_ATTR);

		ClientApplication clientApplication = appSensorServer.getConfiguration().findClientApplication(clientApplicationName);
		
		appSensorServer.getAccessController().assertAuthorized(clientApplication, action, new Context());
	}
1363924
@SuppressWarnings({"ConstantConditions","deprecation"})
    @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
    public void addAction(@Nonnull Action a) {
        if(a==null) {
            throw new IllegalArgumentException("Action must be non-null");
        }
        getActions().add(a);
    }
1221142
public static <T> T doPrivileged(PrivilegedAction<T> action,
                                     AccessControlContext context) {
        return action.run();
    }
1355851
protected boolean isAuthorizationRequest(final HttpServletRequest request, final HttpServletResponse response) {
        val requestPath = request.getRequestURI();
        return doesUriMatchPattern(requestPath, OAuth20Constants.AUTHORIZE_URL);
    }
353960
public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) {
        if (action == null)
            throw new NullPointerException();
        return new Callable<Object>() {
            public Object call() throws Exception { return action.run(); }};
    }
575083
protected void asLoginRequired(LoginHandlingResource resource) throws LoginRequiredException {
        logger.debug("...Checking login status for login required");
        if (tryAlreadyLoginOrRememberMe(resource)) {
            checkPermission(resource); // throws if denied
            return; // Good
        }
        if (needsSavingRequestedLoginRedirect(resource)) {
            saveRequestedLoginRedirectInfo();
        }
        throwLoginRequiredException("Cannot access the action: " + resource);
    }
808897
private static void checkPermission(final Subject user, 
                                      final Permission... permissions) 
  throws AuthorizationException {
    try{
      Subject.doAs(user, 
                   new PrivilegedExceptionAction<Void>() {
                     @Override
                     public Void run() throws Exception {
                       try {
                         for(Permission permission : permissions) {
                           AccessController.checkPermission(permission);
                         }
                       } catch (AccessControlException ace) {
                         LOG.info("Authorization failed for " + 
                                  UserGroupInformation.getCurrentUGI(), ace);
                         throw new AuthorizationException(ace);
                       }
                      return null;
                     }
                   }
                  );
    } catch (PrivilegedActionException e) {
      throw new AuthorizationException(e.getException());
    }
  }
285386
public void setAction(String action)
    {
        ExtendedInfo info = getInfo(action);
        if (info != null)
            info._action = action;
    }
1098551
@Override
    public boolean isCallerInRole(String role) {

        Subject callerSubject = getCallerSubject();
        AuthorizationService authService = SecurityContextHelper.getAuthorizationService();
        if (authService != null) {
            String appName = getApplicationName();
            List<String> roles = new ArrayList<String>();
            roles.add(role);

            return authService.isAuthorized(appName, roles, callerSubject);
        }
        return false;
    }
740125
def _handleAuthorizedEvents(self, component, action, data, user, client):
        """"""

        try:
            if component == "debugger":
                self.log(component, action, data, user, client, lvl=info)

            if not user and component in self.authorized_events.keys():
                self.log("Unknown client tried to do an authenticated "
                         "operation: %s",
                         component, action, data, user)
                return

            event = self.authorized_events[component][action]['event'](user, action, data, client)

            self.log('Authorized event roles:', event.roles, lvl=verbose)
            if not self._checkPermissions(user, event):
                result = {
                    'component': 'hfos.ui.clientmanager',
                    'action': 'Permission',
                    'data': _('You have no role that allows this action.', lang='de')
                }
                self.fireEvent(send(event.client.uuid, result))
                return

            self.log("Firing authorized event: ", component, action,
                     str(data)[:100], lvl=debug)
            # self.log("", (user, action, data, client), lvl=critical)
            self.fireEvent(event)
        except Exception as e:
            self.log("Critical error during authorized event handling:",
                     component, action, e,
                     type(e), lvl=critical, exc=True)
1306497
protected void asNonLoginRequired(LoginHandlingResource resource) throws LoginRequiredException {
        if (!isSuppressRememberMeOfNonLoginRequired(resource)) { // option just in case
            logger.debug("...Checking login status for non login required");
            if (tryAlreadyLoginOrRememberMe(resource)) {
                checkPermission(resource); // throws if denied
                return; // Good
            }
        }
        if (isLoginRedirectBeanKeptAction(resource)) {
            // keep login-redirect path in session
            logger.debug("...Passing login check as login action (or redirect-kept action)");
        } else {
            clearLoginRedirectBean();
            logger.debug("...Passing login check as non login required");
        }
    }
116490
function onAuthorizedAccess() {
          if (angular.isFunction(permission.onAuthorized)) {
            permission.onAuthorized()($element);
          } else {
            var onAuthorizedMethodName = $permission.defaultOnAuthorizedMethod;
            PermPermissionStrategies[onAuthorizedMethodName]($element);
          }
        }
1034073
private Action handleAddUpdateActionStatus(final JpaActionStatus actionStatus, final JpaAction action) {

        String controllerId = null;
        LOG.debug("handleAddUpdateActionStatus for action {}", action.getId());

        // information status entry - check for a potential DOS attack
        assertActionStatusQuota(action);
        assertActionStatusMessageQuota(actionStatus);

        switch (actionStatus.getStatus()) {
        case ERROR:
            final JpaTarget target = (JpaTarget) action.getTarget();
            target.setUpdateStatus(TargetUpdateStatus.ERROR);
            handleErrorOnAction(action, target);
            break;
        case FINISHED:
            controllerId = handleFinishedAndStoreInTargetStatus(action);
            break;
        case DOWNLOADED:
            controllerId = handleDownloadedActionStatus(action);
            break;
        default:
            break;
        }

        actionStatus.setAction(action);
        actionStatusRepository.save(actionStatus);
        final Action savedAction = actionRepository.save(action);

        if (controllerId != null) {
            requestControllerAttributes(controllerId);
        }

        return savedAction;
    }
607991
public boolean needAuthorization(ResponseEvent event) {
    Response response = event.getResponse();
    int status = response.getStatusCode();

    if ((status == Response.UNAUTHORIZED) || (status == Response.PROXY_AUTHENTICATION_REQUIRED)) {
      return true;
    }

    return false;
  }
1254056
def authorize_action
      YamledAcl.init(current_user_group_name, params[:controller])
      allowed_to?(params[:action]) or raise(YamledAcl::AccessDenied)
    end
732602
public static <T> T doAs(final Subject subject, final java.security.PrivilegedAction<T> action) {
      Stack<Subject> stack = SUBJECT.get();
      if (stack == null) {
         stack = new Stack<>();
         SUBJECT.set(stack);
      }
      stack.push(subject);
      try {
         return action.run();
      } finally {
         stack.pop();
         if (stack.isEmpty()) {
            SUBJECT.remove();
         }
      }
   }
120536
protected function checkPermissions($key, $action)
    {
        if (!($action & $this->options)) {
            $originalKey = is_null($this->key) ? $key : $this->key;
            $this->key = null;
            $text = Friendlification::getConstNameByValue(
                __CLASS__, $action
            );
            throw new RuntimeException(
                is_null($key)
                    ? sprintf("%s: no permissions", $text)
                    : sprintf(
                        "%s: no permissions for key '%s'", $text,
                        $originalKey
                    ),
                $action
            );
        }
    }