1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2016 Peter Deltchev |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Poniverse\Lib; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class AccessToken |
23
|
|
|
* |
24
|
|
|
* A container for the fields in the draft OAuth Token Introspection proposal. |
25
|
|
|
* |
26
|
|
|
* @link https://tools.ietf.org/html/draft-richer-oauth-introspection-06 |
27
|
|
|
* @package Poniverse |
28
|
|
|
*/ |
29
|
|
|
class AccessToken { |
30
|
|
|
protected $token; |
31
|
|
|
|
32
|
|
|
protected $isActive; |
33
|
|
|
protected $expiresAt; |
34
|
|
|
protected $issuedAt; |
35
|
|
|
protected $scopes; |
36
|
|
|
protected $clientId; |
37
|
|
|
protected $sub; |
38
|
|
|
protected $userId; |
39
|
|
|
protected $intendedAudience; |
40
|
|
|
protected $issuer; |
41
|
|
|
protected $tokenType; |
42
|
|
|
|
43
|
|
|
public function __construct($accessToken) { |
44
|
|
|
$this->token = $accessToken; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return mixed |
49
|
|
|
*/ |
50
|
|
|
public function getToken() { |
51
|
|
|
return $this->token; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return bool |
56
|
|
|
*/ |
57
|
|
|
public function getIsActive() { |
58
|
|
|
return $this->isActive; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param bool $isActive |
63
|
|
|
* @return AccessToken |
64
|
|
|
*/ |
65
|
|
|
public function setIsActive($isActive) { |
66
|
|
|
$this->isActive = $isActive; |
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
|
|
public function getExpiresAt() { |
74
|
|
|
return $this->expiresAt; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param mixed $expiresAt |
79
|
|
|
* @return AccessToken |
80
|
|
|
*/ |
81
|
|
|
public function setExpiresAt($expiresAt) { |
82
|
|
|
$this->expiresAt = $expiresAt; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return mixed |
88
|
|
|
*/ |
89
|
|
|
public function getIssuedAt() { |
90
|
|
|
return $this->issuedAt; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param mixed $issuedAt |
95
|
|
|
* @return AccessToken |
96
|
|
|
*/ |
97
|
|
|
public function setIssuedAt($issuedAt) { |
98
|
|
|
$this->issuedAt = $issuedAt; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return array |
104
|
|
|
*/ |
105
|
|
|
public function getScopes() { |
106
|
|
|
return $this->scopes; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param array|string $scopes |
111
|
|
|
* @return AccessToken |
112
|
|
|
*/ |
113
|
|
|
public function setScopes($scopes) { |
114
|
|
|
if (is_array($scopes)) { |
115
|
|
|
$this->scopes = $scopes; |
116
|
|
|
} else { |
117
|
|
|
$this->scopes = mb_split(' ', $scopes); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return mixed |
125
|
|
|
*/ |
126
|
|
|
public function getClientId() { |
127
|
|
|
return $this->clientId; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param mixed $clientId |
132
|
|
|
* @return AccessToken |
133
|
|
|
*/ |
134
|
|
|
public function setClientId($clientId) { |
135
|
|
|
$this->clientId = $clientId; |
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return mixed |
141
|
|
|
*/ |
142
|
|
|
public function getSub() { |
143
|
|
|
return $this->sub; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @param mixed $sub |
148
|
|
|
* @return AccessToken |
149
|
|
|
*/ |
150
|
|
|
public function setSub($sub) { |
151
|
|
|
$this->sub = $sub; |
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return mixed |
157
|
|
|
*/ |
158
|
|
|
public function getUserId() { |
159
|
|
|
return $this->userId; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param mixed $userId |
164
|
|
|
* @return AccessToken |
165
|
|
|
*/ |
166
|
|
|
public function setUserId($userId) { |
167
|
|
|
$this->userId = $userId; |
168
|
|
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return mixed |
173
|
|
|
*/ |
174
|
|
|
public function getIntendedAudience() { |
175
|
|
|
return $this->intendedAudience; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @param mixed $intendedAudience |
180
|
|
|
* @return AccessToken |
181
|
|
|
*/ |
182
|
|
|
public function setIntendedAudience($intendedAudience) { |
183
|
|
|
$this->intendedAudience = $intendedAudience; |
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return mixed |
189
|
|
|
*/ |
190
|
|
|
public function getIssuer() { |
191
|
|
|
return $this->issuer; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param mixed $issuer |
196
|
|
|
* @return AccessToken |
197
|
|
|
*/ |
198
|
|
|
public function setIssuer($issuer) { |
199
|
|
|
$this->issuer = $issuer; |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return mixed |
205
|
|
|
*/ |
206
|
|
|
public function getTokenType() { |
207
|
|
|
return $this->tokenType; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param mixed $tokenType |
212
|
|
|
* @return AccessToken |
213
|
|
|
*/ |
214
|
|
|
public function setTokenType($tokenType) { |
215
|
|
|
$this->tokenType = $tokenType; |
216
|
|
|
return $this; |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|