Decrypts the stored authentication token out of the authentication cookie and returns it.

@return string
518918
public function getCookieToken()
    {
        // If we have accessed the cookie token this request already.
        if ($this->cookieToken !== null) {
            return $this->cookieToken;
        }

        $name = $this->config->getCookieName();
        $plain = '';
        if (isset($_COOKIE[$name])) {
            $encrypted = $_COOKIE[$name]; // Read encrypted cookie.
            $plain = Encryption::decrypt($encrypted, $this->config->getSecretKey());  // Decrypt cookie.
        }
        $this->cookieToken = $plain; // Don't access cookie again.

        return $plain;
    }
663459
public function decrypt($cipherText)
    {
        $cipherText = base64_decode($cipherText);
        $iv = substr($cipherText, 0, self::IV_SIZE);
        $cipherText = substr($cipherText, self::IV_SIZE);
        $token = mcrypt_decrypt(self::CIPHER, $this->key, $cipherText, self::MODE, $iv);
        return $token;
    }
592851
public function getTokenString()
    {
        $cacheId = $this->getCacheId();

        if ($this->cache && $data = $this->cache->fetch($cacheId)) {
            return $data['access_token'];
        }

        $response = $this->getTokenResponse();

        if ($this->cache) {
            $this->cache->save($cacheId, $response, $response['expires_in']);
        }

        return $response['access_token'];
    }
1193827
public static function getStoredToken(): Token
    {
        if (static::$token !== null) {
            return static::$token;
        }

        $sessionKeyName = static::getSessionKeyName();

        if ($sessionKeyName === null || strlen($sessionKeyName) == 0) {
            throw new Exception('Can not get stored CSRF token when session key is not set');
        }

        $token = Session::get($sessionKeyName);

        if ($token === null) {
            throw new SecurityException('There is no stored token on backend');
        }

        static::$token = $token;
        return $token;
    }
423252
private function getSigningSecret()
    {
        $secret = $this->getConsumerSecret().'&';

        if (null !== $token_secret = $this->getTokenSecret()) {
            $secret .= $token_secret;
        }

        return $secret;
    }
351319
public function generate(): string
    {
        $this->removeExpiredTokens();

        if (empty($this->id)) {
            Throw new TokenException('Cannot create AuthToken for empty id.');
        }

        // Create selector
        $selector = bin2hex($this->getSelector());

        // Create token
        $token = hash('sha256', $this->getToken());

        // Store selector and tokenb in DB
        $this->db->qb([
            'table' => 'core_auth_tokens',
            'method' => 'INSERT',
            'primary' => 'id_auth_token',
            'data' => [
                'selector' => $selector,
                'token' => $token,
                'id' => $this->id,
                'expires' => $this->expires_datetime
            ]
        ], true);

        // Set autologin token cookie only when token is stored successfully in db!!!
        if (empty($this->db->lastInsertId())) {

            $msg = 'AuthToken could not be stored in database.';

            if (isset($this->logger)) {
                $this->logger->warning($msg, __METHOD__);
            }

            Throw new TokenException($msg);

        }

        return $selector . ':' . $token;
    }
72608
protected function getTokenFromCookie()
    {
        $cookies = $this->getCookies();
        if (!empty($cookies['token']) && $cookies['token']['expiration'] > time()) {
            return $cookies['token']['value'];
        }

        return null;
    }
757025
public function parse() : string
	{
		$raw_token = $this->_Request->getHeader($this->key);

		if(!$raw_token) {
			return '';
		}

		return trim( str_ireplace($this->prefix, '', $raw_token));
	}
1343486
protected function getToken()
    {
        if (!$this->isStateless()) {
            $temp = $this->request->getSession()->get('oauth.temp');

            return $this->server->getTokenCredentials(
                $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
            );
        }
        $temp = unserialize($this->request->session()->get('oauth_temp'));

        return $this->server->getTokenCredentials(
                $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
            );
    }
1091458
protected function generateCsrfToken()
    {
        $token = $this->app->getSecurity()->generateRandomString();
        if ($this->enableCsrfCookie) {
            $cookie = $this->createCsrfCookie($token);
            $this->app->getResponse()->getCookies()->add($cookie);
        } else {
            $this->app->getSession()->set($this->csrfParam, $token);
        }

        return $token;
    }
471790
public function getDecodedToken(string $jwt)
    {
        try {
            /** @noinspection PhpUnusedLocalVariableInspection */
            [$headb64, $bodyb64, $cryptob64] = \explode('.', $jwt);
            $decodedToken = \json_decode(JWT::urlsafeB64Decode($bodyb64));

            /** @noinspection NullPointerExceptionInspection */
            JWT::decode($jwt, $this->findTenant($decodedToken->iss)->getSharedSecret(), ['HS256']);

            return $decodedToken;
        } catch (\Throwable $e) {
            throw new AuthenticationException($e->getMessage());
        }
    }
1273373
public function getAuthType()
    {

        if (isset($this->auth['username']) && isset($this->auth['password'])) {
            return self::HTTP_PASSWORD;
        }

        if (isset($this->auth['client_id']) && isset($this->auth['client_secret'])) {
            return self::URL_SECRET;
        }

        if (isset($this->auth['access_token'])) {
            return self::URL_TOKEN;
        }

        return -1;
    }
7619
public function getCSRFCookie()
	{
		$cookie = $this->_browserInterface->getCookie($this->_csrf_cookiename);
		if ( !$cookie )
			throw new SecureRequestHelper\CSRFException('CSRF cookie has not been initialized');
		
		return $cookie;
	}
1208976
public function getToken()
    {
        if (isset($_SESSION[$this->session_name])) {
            return $_SESSION[$this->session_name];
        } else {
            $token = uniqid($this->randomString());
            $_SESSION[$this->session_name] = $token;
            return $token;
        }
    }
121482
public function getCookie()
    {
        $request = Request::current();
        $settings = CsrfSettings::singleton();

        if ($request instanceof WebRequest){
            $existingCookie = $request->cookie(self::TOKEN_COOKIE_NAME, false);

            if ($existingCookie){
                $this->currentCookie = $existingCookie;
            }
        }

        if (!$this->currentCookie) {
            $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345689.;,!$%^&*()-=+";
            $cookie = "";
            for ($x = 0; $x < self::TOKEN_COOKIE_LENGTH; $x++) {
                $rand = rand(0, strlen($chars) - 1);
                $char = $chars[$rand];

                if (rand(0, 1) == 1) {
                    $char = strtolower($char);
                }

                $cookie .= $char;
            }

            $this->currentCookie = $cookie;

            HttpResponse::setCookie(self::TOKEN_COOKIE_NAME, $cookie, 0, '/', parse_url($settings->domain, PHP_URL_HOST), false, true);
        }

        return $this->currentCookie;
    }
843731
public static function generateToken()
    {
        $raw = self::getOpenSSLRandom();
        if (false === $raw) {
            $raw = self::getComplexRandom();
        }
        return md5($raw);
    }
337914
public function getAuthenticate()
    {
        if ($this->authenticate === null) {
            $this->authenticate = new Authenticate($this->getSecretKey(), $this->getAccessKey());
        }
        return $this->authenticate;
    }