1 | <?php |
||
15 | class JwtService |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $key; |
||
22 | |||
23 | /** |
||
24 | * @var ClaimManagerContract |
||
25 | */ |
||
26 | protected $claimManager; |
||
27 | |||
28 | /** |
||
29 | * JwtService constructor |
||
30 | * |
||
31 | * @param ClaimManagerContract $claimManager |
||
32 | */ |
||
33 | public function __construct(ClaimManagerContract $claimManager) |
||
40 | |||
41 | /** |
||
42 | * getTokenForUser method |
||
43 | * |
||
44 | * @param Claim $claim |
||
45 | * @return string |
||
46 | */ |
||
47 | public function getTokenForClaim(Claim $claim) |
||
54 | |||
55 | /** |
||
56 | * getEntityFromToken method |
||
57 | * |
||
58 | * @param string $token |
||
59 | * @return Claim |
||
60 | * @throws InaccessibleException |
||
61 | * @throws MalformedException |
||
62 | * @throws TokenExpiredException |
||
63 | * @throws InvalidTokenException |
||
64 | */ |
||
65 | public function getClaimFromToken($token) |
||
73 | |||
74 | /** |
||
75 | * refreshToken method |
||
76 | * |
||
77 | * @param string $token |
||
78 | * @return string |
||
79 | * @throws MalformedException |
||
80 | * @throws TokenExpiredException |
||
81 | * @throws InvalidTokenException |
||
82 | * @throws UnRefreshableException |
||
83 | */ |
||
84 | public function refreshToken($token) |
||
102 | |||
103 | /** |
||
104 | * invalidateToken method |
||
105 | * |
||
106 | * @param string $token |
||
107 | * @throws MalformedException |
||
108 | * @throws TokenExpiredException |
||
109 | * @throws UnRefreshableException |
||
110 | */ |
||
111 | public function invalidateToken($token) |
||
117 | |||
118 | /** |
||
119 | * wipeUserTokens method |
||
120 | * |
||
121 | * @param Claim $claim |
||
122 | */ |
||
123 | public function wipeUserTokens(Claim $claim) |
||
127 | |||
128 | /** |
||
129 | * getValidClaimFromToken method |
||
130 | * |
||
131 | * @param $token |
||
132 | * @return Claim |
||
133 | * @throws MalformedException |
||
134 | * @throws TokenExpiredException |
||
135 | * @throws InvalidTokenException |
||
136 | */ |
||
137 | protected function getValidClaimFromToken($token) |
||
158 | |||
159 | } |