1 2/** 3 * This file is part of the Phalcon Framework. 4 * 5 * (c) Phalcon Team <team@phalcon.io> 6 * 7 * For the full copyright and license information, please view the LICENSE.txt 8 * file that was distributed with this source code. 9 */ 10 11namespace Phalcon\Security\JWT\Token; 12 13/** 14 * Class Token 15 * 16 * @property Item $claims 17 * @property Item $headers 18 * @property Signature $signature 19 * 20 * @link https://tools.ietf.org/html/rfc7519 21 */ 22class Token 23{ 24 /** 25 * @var Item 26 */ 27 private claims { get }; 28 29 /** 30 * @var Item 31 */ 32 private headers { get }; 33 34 /** 35 * @var Signature 36 */ 37 private signature { get }; 38 39 /** 40 * Token constructor. 41 * 42 * @param Item $headers 43 * @param Item $claims 44 * @param Signature $signature 45 */ 46 public function __construct( 47 <Item> headers, 48 <Item> claims, 49 <Signature> signature 50 ) { 51 let this->headers = headers, 52 this->claims = claims, 53 this->signature = signature; 54 } 55 56 /** 57 * @return string 58 */ 59 public function getPayload() -> string 60 { 61 return this->headers->getEncoded() . "." . this->claims->getEncoded(); 62 } 63 64 /** 65 * @return string 66 */ 67 public function getToken() -> string 68 { 69 return this->getPayload() . "." . this->getSignature()->getEncoded(); 70 } 71} 72