@param Payload $payload
@param string  $token

@return bool
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);
    }
347039
public function performApiRequest($endpoint, $payload)
    {
        $this->setupRequest($payload);
        $this->apiEndpoint = $endpoint;

        return $this->doDropboxApiRequest();
    }
481823
public function encode(array $payload)
    {
        try {
            $this->jws->setPayload($payload)->sign($this->getSigningKey(), $this->getPassphrase());

            return (string) $this->jws->getTokenString();
        } catch (Exception $e) {
            throw new JwTException('Could not create token: '.$e->getMessage(), $e->getCode(), $e);
        }
    }
785510
public static function generateToken($payload = null)
    {
        if (empty($payload)) {
            return false;
        }

        $token = JWT::encode($payload, Configure::read('ApiRequest.jwtAuth.cypherKey'), Configure::read('ApiRequest.jwtAuth.tokenAlgorithm'));

        return $token;
    }
1369772
public function sendPayload($deviceToken, Payload $payload)
    {
        return $this->socketClient->write(
            $this->createApnMessage($deviceToken, $payload)->getBinaryMessage()
        );
    }
161792
protected function verifyGroup(&$payload){
        
        // 消息格式如果错误不继续.
        if(!$this->verifyMessage($payload)){
            // 错误信息应有verifyMessage中生成.
            
            return false;
        }
            
        // 没有type,认为是push/tags的简单调用方式, 需要将type置为1
        $payload['type'] = array_key_exists('type', $payload) ? $payload['type'] : 1;
        
        if($payload['type']  === 1){
            // 必须要求有tag.
            if(!array_key_exists('tag', $payload)){
                $this->onError(null,3,'SDK params invalid, [tag] is required,  when the [type] not 2 ~ 6');
                return false;
            }
        }
        // type不等于1, 必须有selector
        else if(array_key_exists('selector', $payload)){             

            if(is_array($payload['selector'])){
                $payload['selector'] = json_encode($payload['selector']);
            }
            
        }
        // 其它情况,直接认为错误.
        else{
            $this->onError(null,3,'SDK params invalid, [selector] is required,  when the [type] between 2 and 6');
            return false;
        }
        
        return true;
    }
763582
function parseRequest( $payload )
    {
        $request = new ggRESTRequest();
        if ( $request->decodeStream( $payload ) )
        {
            $this->ResponseType = $request->responseType();
            $this->JsonpCallback = $request->jsonpCallback();
            return $request;
        }
        else
        {
            $this->ResponseType = '';
            return false;
        }
    }
569765
protected function _decode($token)
    {
        $config = $this->_config;
        try {
            $payload = JWT::decode(
                $token,
                $config['key'] ?: Security::getSalt(),
                $config['allowedAlgs']
            );

            return $payload;
        } catch (Exception $e) {
            if (Configure::read('debug')) {
                throw $e;
            }
            $this->_error = $e;
        }
    }
30507
public function body($payload)
    {
        if (!empty($payload) || is_array($payload)) {
            $this->payload = $payload;
        }

        return $this;
    }
158833
public function withPayload(string $payload, bool $isPayloadDetached = false): self
    {
        if (false === \mb_detect_encoding($payload, 'UTF-8', true)) {
            throw new \InvalidArgumentException('The payload must be encoded in UTF-8');
        }
        $clone = clone $this;
        $clone->payload = $payload;
        $clone->isPayloadDetached = $isPayloadDetached;

        return $clone;
    }
453546
public function addForever(Payload $payload)
    {
        $this->storage->forever($this->getKey($payload), 'forever');

        return true;
    }
89042
public function deserializeToken($payload)
  {
    try {
      $payload = str_replace(array('-', '_'), array('+', '/'), $payload);
      $data = $this->encrypter->decrypt($payload);
    } catch (DecryptException $e) {
      return null;
    }

    if(empty($data['id']) || empty($data['key'])) {
      return null;
    }

    $token = $this->generateAuthToken($data['key']);
    $token->setAuthIdentifier($data['id']);

    return $token;
  }
169303
public function process(Payload $payload) {
		$directory = $this->getDirectorySettingOrFail();
		$branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch());
		$url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl());
		$git = $this->resolveGitCommand();
		$command = array(
			'cd', escapeshellarg($directory), '&&',
			$git, self::COMMAND, escapeshellarg($url), escapeshellarg($branch)
		);
		if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REBASE, FALSE)) {
			$command[] = self::COMMAND_REBASE;
		}
		$output = $this->executeGitCommand($command);
		$payload->getResponse()->addOutputFromPlugin($this, $output);
	}
394839
public function canHandle($payload)
    {
        if (is_object($payload) && is_a($payload, $this->payloadClassName)) {
            return true;
        } elseif (is_string($payload) && is_subclass_of($payload, $this->payloadClassName)) {
            return true;
        } else {
            return false;
        }
    }
845635
public function process(Payload $payload) {
		$output = array();
		$command = $this->getCommand();
		// run composer update
		$this->invokeShellCommand($command, $output);
		$payload->getResponse()->addOutputFromPlugin($this, $output);
	}
1187334
public function process(Payload $payload) {
		$sha1 = $payload->getHead()->getId();
		$tag = substr($payload->getRef(), strlen(self::PATTERN_TAG_HEAD));
		$this->validateVersionNumber($tag);

		// additional settings not requiring validation.
		$url = $this->getSettingValue(self::OPTION_URL, $payload->getRepository()->resolveApiUrl(Repository::API_URL_CLONE));
		// look for an upload comment in settings; if not found there, use Payload HEAD's message body
		$comment = $this->getSettingValue(self::OPTION_COMMENT, $payload->getHead()->getMessage());

		// validation: credentials file and local directory path.
		$directory = $this->getSettingValue(self::OPTION_DIRECTORY);
		$directory = rtrim($directory, '/') . '/';
		$directory .= $sha1 . '/' . $this->getWorkingDirectoryName($payload);
		$credentialsFile = $this->getSettingValue(self::OPTION_CREDENTIALSFILE, GIZZLE_HOME . self::CREDENTIALS_FILE);
		$this->validateCredentialsFile($credentialsFile);
		list ($username, $password) = $this->readUploadCredentials($credentialsFile);

		// initializing build directory and cloning source
		$clone = $this->getGitClonePlugin();
		$clonePluginSettings = $this->getSubPluginSettings('\NamelessCoder\GizzleGitPlugins\GizzlePlugins\ClonePlugin', array(
			ClonePlugin::OPTION_GITCOMMAND => $this->getSettingValue(self::OPTION_GITCOMMAND, ClonePlugin::DEFAULT_GITCOMMAND),
			ClonePlugin::OPTION_DIRECTORY => $directory,
			ClonePlugin::OPTION_SINGLE => TRUE,
			ClonePlugin::OPTION_BRANCH => $tag,
			ClonePlugin::OPTION_DEPTH => 1
		));
		$clone->initialize($clonePluginSettings);
		$this->createWorkingDirectory($directory);
		$this->validateDirectory($directory);
		$clone->process($payload);

		// a large, properly formatted data file.
		$comment = sprintf($comment, $url);
		try {
			$output = $this->getUploader()->upload($directory, $username, $password, $comment);
		} catch (\SoapFault $error) {
			throw new \RuntimeException($error->getMessage(), $error->getCode());
		}

		// cleanup and messages
		if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REMOVEBUILD, FALSE)) {
			$this->removeWorkingDirectory($this->getSettingValue(self::OPTION_DIRECTORY), $sha1);
		}
		$payload->getResponse()->addOutputFromPlugin($this, $output);
	}
416137
public function add(Payload $payload)
    {
        $exp = Utils::timestamp($payload['exp']);
        $refreshExp = Utils::timestamp($payload['iat'])->addMinutes($this->refreshTTL);

        // there is no need to add the token to the blacklist
        // if the token has already expired AND the refresh_ttl
        // has gone by
        if ($exp->isPast() && $refreshExp->isPast()) {
            return false;
        }

        // Set the cache entry's lifetime to be equal to the amount
        // of refreshable time it has remaining (which is the larger
        // of `exp` and `iat+refresh_ttl`), rounded up a minute
        $cacheLifetime = $exp->max($refreshExp)->addMinute()->diffInMinutes();

        $this->storage->add($payload['jti'], [], $cacheLifetime);

        return true;
    }