Return if access token is valid

@return bool
425464
public function valid()
    {
        $this->jwt();
        
        $data = new ValidationData();
        
        if ($this->leeway != 0) {
          $data->setCurrentTime(time() + $this->leeway);
        }
        
        return $this->jwt->validate($data);
    }
84709
public function isValid()
    {
        $localSign = generate_sign($this->getNotify()->except('sign')->all(), $this->merchant->key, 'md5');

        return $localSign === $this->getNotify()->get('sign');
    }
1286028
public function checkAccessToken($access_token = null)
    {
        $token = is_null($access_token) ? $this->access_token : $access_token;
        if (is_null($token)) return false;

        $rs = $this->api('getUserSettings', array('access_token' => $token));
        return isset($rs['response']);
    }
996661
public function valid()
        {
            // Return true if and only if all parts of the URI have passed validation
            return $this->validateUsername()
               && $this->validatePassword()
               && $this->validateHost()
               && $this->validatePort()
               && $this->validatePath()
               && $this->validateQuery()
               && $this->validateFragment();
        }
1141939
public static function isAccessTokenValid($token)
    {
        if (empty($token)) {
            return false;
        }
        $data = Yii::$app->jwt->getValidationData(); // It will use the current time to validate (iat, nbf and exp)
        $data->setIssuer(Yii::getAlias("@restIssuer"));
        $data->setAudience(Yii::getAlias("@restAudience"));
        $data->setId(Yii::getAlias("@restId")+strtotime(date('Y-m-d',time())), true);
        if (is_string($token))
            $token = Yii::$app->jwt->getParser()->parse($token);

        return $token->validate($data);
    }
377420
public function valid()
    {

        if ($this->container['region'] === null) {
            return false;
        }
        $allowed_values = $this->getRegionAllowableValues();
        if (!in_array($this->container['region'], $allowed_values)) {
            return false;
        }
        if ($this->container['machineType'] === null) {
            return false;
        }
        $allowed_values = $this->getMachineTypeAllowableValues();
        if (!in_array($this->container['machineType'], $allowed_values)) {
            return false;
        }
        if ($this->container['size'] === null) {
            return false;
        }
        if ($this->container['billingType'] === null) {
            return false;
        }
        $allowed_values = $this->getBillingTypeAllowableValues();
        if (!in_array($this->container['billingType'], $allowed_values)) {
            return false;
        }
        if ($this->container['machineName'] === null) {
            return false;
        }
        if ($this->container['templateId'] === null) {
            return false;
        }
        return true;
    }
305430
public function check_access() {
        global $CFG;
        $context = empty($this->context) ? context_system::instance() : $this->context;
        foreach($this->req_capability as $cap) {
            if (has_capability($cap, $context)) {
                return true;
            }
        }
        return false;
    }
501388
public function isAccessible()
    {
        $root = $this->getRootParagraph();

        if ( ! empty( $root->allAccess ) )
        {
            return true;
        }

        $user = $this->getAuthenticatedUser();

        if ( empty( $user ) )
        {
            return ! empty( $root->accessUsers ) && in_array( '', $root->accessUsers )
                || ! empty( $root->accessGroups ) && in_array( '', $root->accessGroups );
        }

        return ! empty( $root->accessUsers ) && in_array( $user->id, $root->accessUsers )
            || ! empty( $root->accessGroups ) && in_array( $user->groupId, $root->accessGroups )
            || $this->getServiceLocator()
                    ->get( 'Grid\User\Model\Permissions\Model' )
                    ->isAllowed( $root, 'view' );
    }
1225827
public function isAuthenticated()
    {
        try {
            $session = $this->sessionStorage->retrieveAccessToken($this->getServiceName());
            if (!$session) {
                return false;
            }
            return $session->getEndOfLife() > time();
        } catch (TokenNotFoundException $e) {
            return false;
        }
    }
1059659
public function validateToken($token)
    {
        /*
         | Return false if given token is not string
         */
        if (!is_string($token)) {
            return false;
        }

        if (isset($this->storage->csrf_tokens[$token])) {
            $this->storage->csrf_tokens = [trim($token) => null];

            return true;
        }

        return false;
    }
645889
public function isAccessTokenExpired()
  {
    if (!$this->token || !isset($this->token['created'])) {
      return true;
    }

    // If the token is set to expire in the next 30 seconds.
    $expired = ($this->token['created']
        + ($this->token['expires_in'] - 30)) < time();

    return $expired;
  }
443942
public function canAccess()
    {
        //Check if the user needs to be authentic to access
        if($this->hasProperty('access') && !empty($this->access))
        {
            if(!$this->getObject('user')->isAuthentic()) {
                return false;
            }
        }

        //Check if the user is in the group(s) to access
        if($this->hasProperty('access_group') && !empty($this->access_group))
        {
            $groups = $this->getObject('user')->getGroups();

            if(!in_array($this->access_group, $groups)) {
                return false;
            }
        }

        //Check if the user has the right role(s) to access
        if($this->hasProperty('access_role') && !empty($this->access_role))
        {
            if(!$this->getObject('user')->hasRole($this->access_role)) {
                return false;
            }
        }

        return true;
    }
930997
public function check(): bool
    {
        $auth = $this->parseAuthenticationConfiguration(\config('auth'));

        try {
            $this->description = Str::replace($this->description, ['model' => $auth['provider']['model']]);

            return $this->validateUserProvider($auth) && $this->validateUserInstance($auth);
        } catch (ReflectionException $e) {
            // Catch ReflectionException and return false.
        } finally {
            // Catch any exception.
        }

        return false;
    }
382369
def is_token_valid(self, token):
        

        try:
            _tinfo = self.handler.info(token)
        except KeyError:
            return False

        if is_expired(int(_tinfo['exp'])) or _tinfo['black_listed']:
            return False

        # Dependent on what state the session is in.
        session_info = self[_tinfo['sid']]

        if session_info["oauth_state"] == "authz":
            if _tinfo['handler'] != self.handler['code']:
                return False
        elif session_info["oauth_state"] == "token":
            if _tinfo['handler'] != self.handler['access_token']:
                return False

        return True
417103
public function checkOauth2AccessToken($accessToken, $openId)
    {
        $result = $this->httpGet(self::WECHAT_SNS_AUTH_PREFIX, [
            'access_token' => $accessToken,
            'openid' => $openId
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
904095
public function isValidVerifyTokenRequest()
    {
        if ($this->getRequest()->getMethod() !== 'GET') {
            return false;
        }

        $params = $this->getRequest()->getQueryParams();

        if (!isset($params['hub_verify_token'])) {
            return false;
        }

        return  $params['hub_verify_token'] === $this->verifyToken;
    }
517161
public function getAccessToken($access_token)
    {
        return isset($this->accessTokens[$access_token]) ? $this->accessTokens[$access_token] : false;
    }