serialize() public method

public serialize ( Token $token, Emarref\Jwt\Encryption\EncryptionInterface $encryption ) : string
$token Token
$encryption Emarref\Jwt\Encryption\EncryptionInterface
return string
Beispiel #1
0
 protected static function authorization()
 {
     $token = new Emarref\Jwt\Token();
     $parameter = new Emarref\Jwt\HeaderParameter\Custom('typ', 'JWT');
     $token->addHeader($parameter, true);
     $token->addClaim(new Emarref\Jwt\Claim\Expiration(new \DateTime(self::$duration)));
     $jwt = new Emarref\Jwt\Jwt();
     $algorithm = new Emarref\Jwt\Algorithm\Hs256(self::$appSecret);
     $encryption = Emarref\Jwt\Encryption\Factory::create($algorithm);
     $serializedToken = $jwt->serialize($token, $encryption);
     return $serializedToken;
 }
 /**
  * @test
  */
 public function givenNoneAlgorithm_returnFalse()
 {
     $auth = new JwtTokenAuthenticator($jwt = new Jwt(), new None(), $this->appIds);
     $this->assertFalse($auth->isAuthorised(new MockTokenRequest($jwt->serialize(new Token(), EncryptionFactory::create(new None())))));
 }