Verify access for an action and a resource

@param string $action
@param mixed $resource
@return boolean
@throws AccessDeniedException
421373
public function checkAccess($action, $resource)
    {
        if ((is_null($resource) || is_null($resource->getId())) && (empty($action) || in_array(strtolower($action), array('list', 'create', 'post')))) {
            return true;
        }

        if (!is_null($resource)) {
            $query = $this->createQueryBuilder();
            $query->andWhere($query->getRootAliases()[0] . '.id = ' . $this->addNamedParameter('id', $resource, $query));
            $result = $this->getOneOrNullResultFromQueryBuilder($query);
            if ($result) {
                return true;
            } else {
                $this->throwException('Access for this resource has been denied', 'access-denied');
            }
        }
    }
83834
public function hasResourceParams($controller, $action = null)
    {
        $this->buildAcl();
        $resource = $this->buildResource($controller, $action);
        return parent::hasResource($resource);
    }
438999
public function canExecute($action)
    {
        if ($this->getItem() && $this->getItem()->blocking(get_viewer())) {
            return false;
        }

        //if the action is an admin action then check if the viewer is an admin
        if ($this->isAdministrable()) {
            $methods = $this->getBehavior('administrable')->getMethods();

            if (in_array('_action'.ucfirst($action), $methods) && $this->canAdminister() === false) {
                return false;
            }
        }

        return parent::canExecute($action);
    }
374188
public function onKernelRequestAuthorize($event)
  {
    // This is basically the master firewall
    $requestRoles = $event->getRequest()->getAttribute('_roles');
    if (!$requestRoles) return;

    // Need a token
    $authToken = $event->getRequest()->getAttribute('authToken');
    if (!$authToken)
    {
      throw new AccessDeniedException();
    }
    $userRoles = $authToken->getRoles();

    if ($this->roleHierarchy->isAuthorized($requestRoles,$userRoles)) return;
    
    throw new AccessDeniedException();
  }
311082
public function cannot($action, $resource = null, $resourceId = null)
    {
        return ! $this->can($action, $resource, $resourceId);
    }
838829
public function canExecute($action)
    {
        if (
            $this->isOwnable() &&
            $this->actor &&
            $this->actor->authorize('access') === false
            ) {
            return false;
        }

        return parent::canExecute($action);
    }
865860
public function auth($request)
    {
        $channelName = $this->normalizeChannelName($request->channel_name);

        if ($this->isGuardedChannel($request->channel_name) &&
            ! $this->retrieveUser($request, $channelName)) {
            throw new AccessDeniedHttpException;
        }

        return parent::verifyUserCanAccessChannel(
            $request, $channelName
        );
    }
209202
public function authorize($action, $model = null)
    {
        // for most cases it is enough to set
        // permissions in Resource object.
        if (method_exists($this->module, 'authorize')) {
            return $this->module->authorize($action, $model);
        }

        // Ask Actions Service for action permissions.
        return $this->service->authorize($action, $model, $this->module);
    }
102040
public function revokeUserAccess($resource, string $action)
    {
        $resourceRule = $this->getUserPermission($resource);

        if (!$resourceRule) {
            return;
        }

        // make sure we can work with this
        if ($resourceRule && !($resourceRule instanceof UserPermissionInterface)) {
            throw new PermissionExpectedException(UserPermissionInterface::class, \get_class($resourceRule));
        }

        if ($resourceRule) {
            if (!\in_array($action, $resourceRule->getActions(), true)) {
                return;
            }
            $resourceRule->removeAction($action);
            $this->userPermissions->update($resourceRule);
        }
    }
72994
public static function hasAccess(User $user, $controller, $action, $parameters) {
        $access = true;
        foreach (self::getImplementations() as $impl) {
            $access = $access && $impl->hasAccess($user, $controller, $action, $parameters);
        }
        return $access;
    }
1131962
public function isGranted(string $action): bool
    {
        if (empty($this->allowed)) {
            return false;
        }

        if (isset($this->denied[$action]) || isset($this->denied[self::WILDCARD])) {
            return false;
        }

        $rules = $this->getRules($action);

        foreach ($rules as $rule) {
            if (isset($this->denied[$rule])) {
                return false;
            }
        }

        foreach ($rules as $rule) {
            if (isset($this->allowed[$rule])) {
                return true;
            }
        }

        return false;
    }
1355802
private function validateAction($action)
    {
        $actionAvailable = [self::ACTION_ADDFORCE, self::ACTION_ADDNOFORCE, self::ACTION_REMOVE, self::ACTION_UNSUB];
        if (in_array($action, $actionAvailable)) {
            return true;
        }
        return false;
    }
327052
public function checkAccess($action, $access = null, $param = null) {
		return $this->domain->rbac->checkAccess($action, $access, $param);
	}
880276
protected function getNecessaryPermission($action)
    {
        $parsed = $this->parseAction($action);

        return ResourcePermissions::permissionFor($parsed['resource'], $parsed['action']);
    }
422553
public function applyScope($resource, $action = null)
    {
        $request = $this->getController()->request;
        if ($action === null) {
            $action = $this->getDefaultAction($request);
        }
        $identity = $this->getIdentity($request);

        return $identity->applyScope($action, $resource);
    }
1041073
public final void checkPermission( String resource , String action ) throws JMSException
    {
        if (securityContext == null)
            return; // Security is disabled

        securityContext.checkPermission(resource, action);        
    }
37711
public function clear($action, $resource = null, $resourceId = null)
    {
        $this->assertLockInstanceIsSet();

        $this->lock->clear($action, $resource, $resourceId);
    }