Is a privilege (on a resource) allowed, or not

@param string|\Zend\Permissions\Acl\Resource\ResourceInterface $resource
@param string $privilege
@return bool
327484
public function isAllowed( $resource, $privilege = self::PRIVILEGE_DEFAULT, $role = null )
    {
        if ( empty( $role ) )
        {
            $role = $this->getRole();
        }

        $role       = $this->checkRole( $role );
        $resource   = $this->checkResource( $resource );

        return $this->getAcl()
                    ->isAllowed( $role,
                                 $resource,
                                 $privilege ?: self::PRIVILEGE_DEFAULT );
    }
261478
public function can($permissions, $resourceName = null, $resourceId = null)
    {
        return $this->caller()->can($permissions, $resourceName, $resourceId);
    }
538965
public function hasExclusiveLock($resource = null): bool
    {
        if (null !== $resource) {
            return $this->exclusiveLock === $this->getResourceId($resource);
        }

        return null !== $this->exclusiveLock;
    }
1138506
public function canDo(string $privilege): bool
    {
        // $privileges = CacheFile::fromMap('privileges');
        $privileges = cache('privileges') ?? Privilege::getModel()->privileges();

        return $privileges[$privilege][$this->role] ?? false;
    }
238399
public function handleAddAcl(string $role, string $resource = null, string $privilege = null)
    {
        $idRole = $this->identityAuthorizator->getIdRoleByName($role);

        $idResource = null;
        if ($resource) {
            $idResource = $this->identityAuthorizator->getIdResourceByName($resource);
        }

        $idPrivilege = null;
        if ($privilege) {
            $idPrivilege = $this->identityAuthorizator->getIdPrivilegeByName($privilege);
            if (!$idPrivilege) {
                $this->identityAuthorizator->savePrivilege(['id' => null, 'privilege' => $privilege]);
                $idPrivilege = $this->identityAuthorizator->getIdPrivilegeByName($privilege);
            }
        } else {
            $idPrivilege = 'all';
        }

        if ($idResource && $idPrivilege) {
            // save acl by one
            if ($this->identityAuthorizator->saveAcl($idRole, [$idResource => [$idPrivilege]], false)) {
                $this->flashMessage('Save ACL');
            }
        }
        $this->redirect('this');
    }
1016259
public function check($user, $permissions, $resourceName = null, $resourceId = null)
    {
        return $this->manager->caller($user)->can($permissions, $resourceName, (int)$resourceId);
    }
1241581
public function canAccess(?ResourceAccessCheckerInterface $resourceAccessChecker, ResourceMetadata $resourceMetadata, string $resourceClass, ResolveInfo $info, $object = null, string $operationName = null): void
    {
        if (null === $resourceAccessChecker) {
            return;
        }

        $isGranted = $resourceMetadata->getGraphqlAttribute($operationName ?? '', 'access_control', null, true);
        if (null === $isGranted || $resourceAccessChecker->isGranted($resourceClass, $isGranted, ['object' => $object])) {
            return;
        }

        throw Error::createLocatedError($resourceMetadata->getGraphqlAttribute($operationName ?? '', 'access_control_message', 'Access Denied.'), $info->fieldNodes, $info->path);
    }
489190
public function allowedUsers( $privilege = self::PRIVILEGE_DEFAULT )
    {
        $auth = $this->getAuthenticationService();

        if ( $auth->hasIdentity() )
        {
            $identity = $auth->getIdentity();

            return array(
                $identity->id => $identity->displayName,
            );
        }
        else
        {
            return array();
        }
    }
854547
public function isAccessible(SecurableInterface $securable)
    {
        $allowedRoles = $securable->getAllowedRoles();

        if (empty($allowedRoles)) {
            return true;
        }

        $authorizationChecker = $this->getAuthorizationChecker();

        foreach ($allowedRoles as $allowedRole) {
            if ($authorizationChecker->isGranted($allowedRole)) {
                return true;
            }
        }

        return false;
    }
935286
public function isLocked(core_kernel_classes_Resource $resource)
    {       
        $values = $resource->getPropertyValues($this->getLockProperty());

        if ((is_array($values)) && (count($values)>0)) {
            return true;
        }
        return false;
    }
861605
protected function assertIsGrantedOr403($intention, $resource = null)
    {
        if (!$this->checkSecurity($intention, $resource)) {
            throw new AccessDeniedHttpException(sprintf(
                'Access denied while trying to "%s" an "%s" object.',
                $intention,
                is_object($resource) ? get_class($resource) : 'unknown'
            ));
        }
    }
595405
public function allowed($action, $resourceType)
    {
        $this->assertLockInstanceIsSet();

        return $this->lock->allowed($action, $resourceType);
    }
107045
public function hasResource($resource) {

		if(null !== $resource && false === is_string($resource)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
		}

		return true === array_key_exists($resource, $this -> resources);
	}
12522
protected static function isCertificateResource($resource): bool {
        if(!is_resource($resource)) {
            return FALSE;
        }
        if(get_resource_type($resource) != 'OpenSSL X.509') {
            return FALSE;
        }
        return TRUE;
    }
690957
public boolean hasPermission(Authentication authentication,
                                 Object resource,
                                 Object privilege) {
        boolean logPermission = isLogPermission(resource);
        return checkRole(authentication, privilege, logPermission)
            || checkPermission(authentication, resource, privilege, true, logPermission);
    }
1271722
public function deny($action, $resource = null, $resourceId = null, $conditions = [])
    {
        $this->assertLockInstanceIsSet();

        $this->lock->deny($action, $resource, $resourceId, $conditions);
    }
522433
public function checkResource( $resource, $parent = null )
    {
        if ( null === $resource )
        {
            return null;
        }

        if ( $resource instanceof Acl\Resource\ResourceInterface )
        {
            $resource = $resource->getResourceId();
        }

        $acl = $this->getAcl();

        if ( ! $acl->hasResource( $resource ) )
        {
            if ( null === $parent )
            {
                $parent = $this->getParentId( $resource );
            }
            elseif ( $parent instanceof Acl\Resource\ResourceInterface )
            {
                $parent = $parent->getResourceId();
            }

            $parent = $this->checkResource( $parent );
            $acl->addResource( $resource, $parent );
        }

        return $resource;
    }