1 | <?php |
||
28 | class JsonWebToken |
||
29 | { |
||
30 | /** |
||
31 | * @var KeyAbstract |
||
32 | */ |
||
33 | protected $key; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $algorithm = 'HS256'; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $claims = array(); |
||
44 | |||
45 | /** |
||
46 | * JsonWebToken constructor. |
||
47 | * |
||
48 | * @param KeyAbstract $key key for signing/validating |
||
49 | * @param string $algorithm algorithm to use for signing/validating |
||
50 | */ |
||
51 | 1 | public function __construct(KeyAbstract $key, $algorithm = 'HS256') |
|
56 | |||
57 | /** |
||
58 | * @param string $algorithm algorithm to use for signing/validating |
||
59 | * |
||
60 | * @return JsonWebToken |
||
61 | * |
||
62 | * @throws \DomainException |
||
63 | */ |
||
64 | 1 | public function setAlgorithm($algorithm) |
|
72 | |||
73 | /** |
||
74 | * Decode a JWT string, validating signature and well defined registered claims, |
||
75 | * and optionally validate against a list of supplied claims |
||
76 | * |
||
77 | * @param string $jwtString string containing the JWT to decode |
||
78 | * @param array|\Traversable $assertClaims associative array, claim => value, of claims to assert |
||
79 | * |
||
80 | * @return object|false |
||
81 | */ |
||
82 | 1 | public function decode($jwtString, $assertClaims = array()) |
|
100 | |||
101 | /** |
||
102 | * Create a signed token string for a payload |
||
103 | * |
||
104 | * @param array|\ArrayObject $payload traversable set of claims, claim => value |
||
105 | * @param int $expirationOffset seconds from now that token will expire. If not specified, |
||
106 | * an "exp" claim will not be added or updated |
||
107 | * |
||
108 | * @return string encoded and signed jwt string |
||
109 | * |
||
110 | * @throws \DomainException; |
||
111 | * @throws \InvalidArgumentException; |
||
112 | * @throws \UnexpectedValueException; |
||
113 | */ |
||
114 | 1 | public function create($payload, $expirationOffset = 0) |
|
122 | } |
||
123 |