|
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 2016 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
|
|
|
* Get resource owner display name. |
|
50
|
|
|
* |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getName() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->response['name'] ?: null; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Get resource owner given (first) name. |
|
60
|
|
|
* |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getGivenName() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->response['given_name'] ?: null; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get resource owner given (first) name. |
|
70
|
|
|
* Alias for getGivenName(). |
|
71
|
|
|
* |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getFirstName() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->getGivenName(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Get resource owner family (last) name. |
|
81
|
|
|
* |
|
82
|
|
|
* @return string |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getFamilyName() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->response['family_name'] ?: null; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Get resource owner family (last) name. |
|
91
|
|
|
* Alias for getFamilyName(); |
|
92
|
|
|
* |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getLastName() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->getFamilyName(); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Get resource owner eduPersonPrincipalName. |
|
102
|
|
|
* |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getEPPN() |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->response['eppn'] ?: null; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Get resource owner eduPersonTargetedID. |
|
112
|
|
|
* |
|
113
|
|
|
* @return string |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getEPTID() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->response['eptid'] ?: null; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Get resource owner email address. |
|
122
|
|
|
* |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getEmail() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->response['email'] ?: null; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Get the Identity Provider entityId the resource owner used for |
|
132
|
|
|
* authentication. |
|
133
|
|
|
* |
|
134
|
|
|
* @return string |
|
135
|
|
|
*/ |
|
136
|
|
|
public function getIdP() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->response['idp'] ?: null; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Get the Identity Provider display name the resource owner used |
|
143
|
|
|
* for authentication. |
|
144
|
|
|
* |
|
145
|
|
|
* @return string |
|
146
|
|
|
*/ |
|
147
|
|
|
public function getIdPName() |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->response['idp_name'] ?: null; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Get resource owner organizational unit. |
|
154
|
|
|
* |
|
155
|
|
|
* @return string |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getOU() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->response['ou'] ?: null; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Get resource owner (scoped) affiliation. |
|
164
|
|
|
* |
|
165
|
|
|
* @return string |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getAffiliation() |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->response['affiliation'] ?: null; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Return all of the owner details available as an array. |
|
174
|
|
|
* |
|
175
|
|
|
* @return array |
|
176
|
|
|
*/ |
|
177
|
|
|
public function toArray() |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->response; |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
|