1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the cilogon/oauth2-cilogon library. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* @author Terry Fleury <[email protected]> |
10
|
|
|
* @copyright 2020 University of Illinois |
11
|
|
|
* @license https://opensource.org/licenses/NCSA NCSA |
12
|
|
|
* @link https://github.com/cilogon/oauth2-cilogon GitHub |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace CILogon\OAuth2\Client\Provider; |
16
|
|
|
|
17
|
|
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface; |
18
|
|
|
|
19
|
|
|
class CILogonResourceOwner implements ResourceOwnerInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Raw response |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
protected $response; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Creates new resource owner. |
30
|
|
|
* |
31
|
|
|
* @param array $response |
32
|
|
|
*/ |
33
|
|
|
public function __construct(array $response = array()) |
34
|
|
|
{ |
35
|
|
|
$this->response = $response; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get resource owner id. |
40
|
|
|
* |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
|
|
public function getId() |
44
|
|
|
{ |
45
|
|
|
return @$this->response['sub'] ?: null; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* An alias for getId(). |
50
|
|
|
* |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function getSub() |
54
|
|
|
{ |
55
|
|
|
return $this->getId(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get resource owner display name. |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getName() |
64
|
|
|
{ |
65
|
|
|
return @$this->response['name'] ?: null; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get resource owner given (first) name. |
70
|
|
|
* |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getGivenName() |
74
|
|
|
{ |
75
|
|
|
return @$this->response['given_name'] ?: null; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get resource owner given (first) name. |
80
|
|
|
* Alias for getGivenName(). |
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
public function getFirstName() |
85
|
|
|
{ |
86
|
|
|
return $this->getGivenName(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get resource owner family (last) name. |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getFamilyName() |
95
|
|
|
{ |
96
|
|
|
return @$this->response['family_name'] ?: null; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Get resource owner family (last) name. |
101
|
|
|
* Alias for getFamilyName(); |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getLastName() |
106
|
|
|
{ |
107
|
|
|
return $this->getFamilyName(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Get resource owner eduPersonPrincipalName. |
112
|
|
|
* |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
|
|
public function getEPPN() |
116
|
|
|
{ |
117
|
|
|
return @$this->response['eppn'] ?: null; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get resource owner eduPersonTargetedID. |
122
|
|
|
* |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
|
|
public function getEPTID() |
126
|
|
|
{ |
127
|
|
|
return @$this->response['eptid'] ?: null; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Get resource owner email address. |
132
|
|
|
* |
133
|
|
|
* @return string |
134
|
|
|
*/ |
135
|
|
|
public function getEmail() |
136
|
|
|
{ |
137
|
|
|
return @$this->response['email'] ?: null; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Get the Identity Provider entityId the resource owner used for |
142
|
|
|
* authentication. |
143
|
|
|
* |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getIdP() |
147
|
|
|
{ |
148
|
|
|
return @$this->response['idp'] ?: null; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Get the Identity Provider display name the resource owner used |
153
|
|
|
* for authentication. |
154
|
|
|
* |
155
|
|
|
* @return string |
156
|
|
|
*/ |
157
|
|
|
public function getIdPName() |
158
|
|
|
{ |
159
|
|
|
return @$this->response['idp_name'] ?: null; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Get resource owner organizational unit. |
164
|
|
|
* |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public function getOU() |
168
|
|
|
{ |
169
|
|
|
return @$this->response['ou'] ?: null; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Get resource owner (scoped) affiliation. |
174
|
|
|
* |
175
|
|
|
* @return string |
176
|
|
|
*/ |
177
|
|
|
public function getAffiliation() |
178
|
|
|
{ |
179
|
|
|
return @$this->response['affiliation'] ?: null; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Get the Authentication Context Class Reference (ACR) value |
184
|
|
|
* for the transaction. Typically used for MFA. |
185
|
|
|
* |
186
|
|
|
* @return string |
187
|
|
|
*/ |
188
|
|
|
public function getAcr() |
189
|
|
|
{ |
190
|
|
|
return @$this->response['acr'] ?: null; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Get the resource owner Subject Id. |
195
|
|
|
* |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
|
|
public function getSubjectId() |
199
|
|
|
{ |
200
|
|
|
return @$this->response['subject_id'] ?: null; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Get the resource owner Pairwise Id. |
205
|
|
|
* |
206
|
|
|
* @return string |
207
|
|
|
*/ |
208
|
|
|
public function getPairwiseId() |
209
|
|
|
{ |
210
|
|
|
return @$this->response['pairwise_id'] ?: null; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get the resource ownder voPersonExternalId. |
215
|
|
|
* Part of the voPerson schema. |
216
|
|
|
* https://github.com/voperson/voperson |
217
|
|
|
* |
218
|
|
|
* @return string |
219
|
|
|
*/ |
220
|
|
|
public function getVoPersonExternalId() |
221
|
|
|
{ |
222
|
|
|
return @$this->response['voPersonExternalID'] ?: null; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Get the resource owner (Unix) UID name. |
227
|
|
|
* |
228
|
|
|
* @return string |
229
|
|
|
*/ |
230
|
|
|
public function getUID() |
231
|
|
|
{ |
232
|
|
|
return @$this->response['uid'] ?: null; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get the resource owner (Unix) UID number. |
237
|
|
|
* |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
public function getUIDNumber() |
241
|
|
|
{ |
242
|
|
|
return @$this->response['uidNumber'] ?: null; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Get the resource owner group membership. |
247
|
|
|
* |
248
|
|
|
* @return string |
249
|
|
|
*/ |
250
|
|
|
public function getIsMemberOf() |
251
|
|
|
{ |
252
|
|
|
return @$this->response['isMemberOf'] ?: null; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Get the resource owner X509 certificate subject |
257
|
|
|
* Distinguished Name (DN) |
258
|
|
|
* |
259
|
|
|
* @return string |
260
|
|
|
*/ |
261
|
|
|
public function getCertSubjectDN() |
262
|
|
|
{ |
263
|
|
|
return @$this->response['cert_subject_dn'] ?: null; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* Get the resource owner OpenID Connect sub as |
268
|
|
|
* returned by the OIDC Provider (i.e., Google, |
269
|
|
|
* GitHub, and ORCID). |
270
|
|
|
* |
271
|
|
|
* @return string |
272
|
|
|
*/ |
273
|
|
|
public function getOIDC() |
274
|
|
|
{ |
275
|
|
|
return @$this->response['oidc'] ?: null; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* Get the access token ID for the transaction. |
280
|
|
|
* |
281
|
|
|
* @return string |
282
|
|
|
*/ |
283
|
|
|
public function getTokenId() |
284
|
|
|
{ |
285
|
|
|
return @$this->response['token_id'] ?: null; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Return all of the owner details available as an array. |
290
|
|
|
* |
291
|
|
|
* @return array |
292
|
|
|
*/ |
293
|
|
|
public function toArray() |
294
|
|
|
{ |
295
|
|
|
return $this->response; |
296
|
|
|
} |
297
|
|
|
} |
298
|
|
|
|