Sets a token
@param string|null $token
@return string
3031
public function setToken($token = null)
    {
        if (isset($token)) {
            return $this->token = $token;
        }

        return $this->token = gplcart_string_encode(crypt(session_id(), $this->config->getKey()));
    }
1080788
public function parse(Token $token)
    {
        $value = $this->tokenizer->detokenize($token->getValue());
        $realValue = preg_replace('/^<\((.*)\)>$/', '<identity($1)>', $value);

        return $this->decoratedTokenParser->parse(
            new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE))
        );
    }
1007516
private function ConsumeChar( $token )
	{
		$curr = new CurrentToken();
		$curr->token = $token;
		$curr->value = null;
		$curr->anchor = $this->m_anchor;
		$curr->length = 1;
		array_push( $this->m_token, $curr );
	}
245309
public function renewToken(?Token $token) : Token
    {
        if ($token === null) {
            throw new NullValueException("Token cannot be null");
        }

        $token->updateExisting([
            'token' => $this->generateToken($this->config->get('app.key')),
        ]);

        $this->fireUpdatedEvent($token->user, $token);

        return $token;
    }
1334115
protected function decrypt($token)
    {
        // Decrypt the token if there is an Encrypter instance
        if ($this->encrypter instanceof Encrypter) {
            $token = $this->encrypter->decrypt($token);
        }
        
        // Return the unserialized token
        return @unserialize($token);
    }
721959
protected function _put($token = null)
    {
        $entity = $this->_verify($this->_token($token));

        $subject = $this->_subject(compact('entity'));
        if ($this->_save($subject)) {
            return $this->_success($subject);
        }

        return $this->_error($subject);
    }
475376
public function authenticatedChannel($token = null)
    {
        $token = $this->getToken($token);

        $channelAPI = new Channels($token);

        return $channelAPI->authenticatedChannel();
    }
1339634
public function setToken($token) : self
    {
        if (! (is_string($token) || is_null($token))) {
            throw new InvalidArgumentException(
                sprintf('Invalid $token type: "%s". Must be "string" or "null"', gettype($token))
            );
        }

        $this->token = $token;
        return $this;
    }
1368450
protected function _setToken($token)
    {
        //Prevents an empty value is serialized
        if (!$token) {
            return $token;
        }
        $token = is_string($token) ? $token : serialize($token);

        return substr(Security::hash($token, 'sha1', Configure::read('Tokens.tokenSalt')), 0, 25);
    }
438276
protected static function setTokenMap($payload, $token)
    {
        $map = [
            'user_id' => $payload->get('user_id'),
            'iat'     => $payload->get('iat'),
            'exp'     => $payload->get('exp'),
            'token'   => $token
        ];

        return DB::table('token_map')->insert($map);
    }
255349
public function addToken($token)
    {
        if (!in_array($token, $this->tokens)) {
            $this->tokens[] = $token;
        }

        return $this;
    }
968531
private function retrieveByToken(string $token)
    {
        $token = $this->validateToken($token);
        if (!$token) {
            return NULL;
        }
        $user = new User();
        if ($token->hasClaim('sub')) {
            $user->id = $token->getClaim('sub');
        }
        if ($token->hasClaim('name')) {
            $user->name = $token->getClaim('name');
        }
        if ($token->hasClaim('email')) {
            $user->email = $token->getClaim('email');
        }
        if ($token->hasClaim('roles')) {
            $user->roles = explode(' ', $token->getClaim('roles'));
        }
        if ($token->hasClaim('registries')) {
            $user->registries = explode(' ', $token->getClaim('registries'));
        }
        if ($token->hasClaim('cpf')) {
            $user->cpf = $token->getClaim('cpf');
        }
        if ($token->hasClaim('avatar')) {
            $user->avatar = $token->getClaim('avatar');
        }

        return $user;
    }
279017
public function createToken(string $tokenSalt): Token
    {
        $this->setToken(Token::create($this, $tokenSalt));
        return $this->token();
    }
450321
public function decorate(Token $token): string
    {
        $style = $token->style();
        $value = $token->value();

        foreach ($this->decorators as $decorator) {
            $value = $decorator->decorate($style, $value);
        }

        return $value;
    }
922752
public function setAccessToken($token)
    {
        if ($token instanceof Token\TokenInterface) {
            $this->rawToken = $token;
        } else {
            $this->rawToken = is_array($token) ?
                $this->tokenFactory($token) :
                $this->tokenFactory(['access_token' => $token]);
        }

        if ($this->rawToken === null) {
            throw new Exception\OAuth2Exception("setAccessToken() takes a string, array or TokenInterface object");
        }

        return $this;
    }
54657
public function verify($token = null)
    {
        $token = isset($token)
            ? $token
            : input()->postGet('csrf-token');

        if (is_string($token)) {
            return hash_equals($this->getToken(), $token);
        }

        return false;
    }
4250
public function getUserIdByResetPasswordToken($token)
    {
        $tokenData = (new UserPasswordReset())->getTokenData($token);
        return $tokenData == false ? null : $tokenData->user_id;
    }