1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
4
|
|
|
* |
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace LoginCidadao\OpenIDBundle\Entity; |
12
|
|
|
|
13
|
|
|
use LoginCidadao\CoreBundle\Model\PersonInterface; |
14
|
|
|
use LoginCidadao\OAuthBundle\Model\ClientInterface; |
15
|
|
|
use LoginCidadao\OAuthBundle\Model\OrganizationInterface; |
16
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
17
|
|
|
use LoginCidadao\OpenIDBundle\Validator\Constraints\SectorIdentifierUri; |
18
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
19
|
|
|
use LoginCidadao\OAuthBundle\Entity\Client; |
20
|
|
|
use JMS\Serializer\Annotation as JMS; |
21
|
|
|
use Doctrine\ORM\Mapping as ORM; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @ORM\Entity(repositoryClass="LoginCidadao\OpenIDBundle\Entity\ClientMetadataRepository") |
25
|
|
|
* @UniqueEntity("client") |
26
|
|
|
* @UniqueEntity("client_name") |
27
|
|
|
* @ORM\HasLifecycleCallbacks |
28
|
|
|
* @ORM\Table(name="client_metadata") |
29
|
|
|
* @JMS\ExclusionPolicy("all") |
30
|
|
|
* @SectorIdentifierUri |
31
|
|
|
*/ |
32
|
|
|
class ClientMetadata |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @ORM\Id |
36
|
|
|
* @ORM\Column(type="integer") |
37
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
38
|
|
|
*/ |
39
|
|
|
private $id; |
40
|
|
|
private $client_id; |
41
|
|
|
private $client_secret; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var ClientInterface |
45
|
|
|
* @ORM\OneToOne(targetEntity="LoginCidadao\OAuthBundle\Entity\Client", inversedBy="metadata", cascade={"persist"}) |
46
|
|
|
* @ORM\JoinColumn(name="client_id", referencedColumnName="id") |
47
|
|
|
*/ |
48
|
|
|
private $client; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string[] |
52
|
|
|
* |
53
|
|
|
* @JMS\Expose |
54
|
|
|
* @JMS\Groups({"client_metadata"}) |
55
|
|
|
* @Assert\Type("array") |
56
|
|
|
* @Assert\All({ |
57
|
|
|
* @Assert\Type(type="string"), |
58
|
|
|
* @Assert\NotBlank, |
59
|
|
|
* @Assert\Url(checkDNS = false) |
60
|
|
|
* }) |
61
|
|
|
* @ORM\Column(name="redirect_uris", type="json_array", nullable=false) |
62
|
|
|
*/ |
63
|
|
|
private $redirect_uris; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var array |
67
|
|
|
* |
68
|
|
|
* @JMS\Expose |
69
|
|
|
* @JMS\Groups({"client_metadata"}) |
70
|
|
|
* @Assert\Type("array") |
71
|
|
|
* @Assert\All({ |
72
|
|
|
* @Assert\Type("string") |
73
|
|
|
* }) |
74
|
|
|
* @ORM\Column(name="response_types", type="simple_array", nullable=false) |
75
|
|
|
*/ |
76
|
|
|
private $response_types = ['code']; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var array |
80
|
|
|
* |
81
|
|
|
* @JMS\Expose |
82
|
|
|
* @JMS\Groups({"client_metadata"}) |
83
|
|
|
* @Assert\Type("array") |
84
|
|
|
* @Assert\All({ |
85
|
|
|
* @Assert\Type("string") |
86
|
|
|
* }) |
87
|
|
|
* @ORM\Column(type="simple_array", nullable=false) |
88
|
|
|
*/ |
89
|
|
|
private $grant_types = ['authorization_code']; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @JMS\Expose |
93
|
|
|
* @JMS\Groups({"client_metadata"}) |
94
|
|
|
* @Assert\Type(type="string") |
95
|
|
|
* @ORM\Column(name="application_type", type="string", length=100, nullable=false) |
96
|
|
|
*/ |
97
|
|
|
private $application_type = 'web'; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @JMS\Expose |
101
|
|
|
* @JMS\Groups({"client_metadata"}) |
102
|
|
|
* @Assert\Type("array") |
103
|
|
|
* @Assert\All({ |
104
|
|
|
* @Assert\Type("string") |
105
|
|
|
* }) |
106
|
|
|
* @ORM\Column(type="simple_array", nullable=true) |
107
|
|
|
*/ |
108
|
|
|
private $contacts; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @JMS\Expose |
112
|
|
|
* @JMS\Groups({"client_metadata"}) |
113
|
|
|
* @Assert\Type(type="string") |
114
|
|
|
* @ORM\Column(type="string", nullable=true) |
115
|
|
|
*/ |
116
|
|
|
private $client_name; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @JMS\Expose |
120
|
|
|
* @JMS\Groups({"client_metadata"}) |
121
|
|
|
* @Assert\Type(type="string") |
122
|
|
|
* @Assert\Url(checkDNS = false) |
123
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
124
|
|
|
*/ |
125
|
|
|
private $logo_uri; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @JMS\Expose |
129
|
|
|
* @JMS\Groups({"client_metadata"}) |
130
|
|
|
* @Assert\Type(type="string") |
131
|
|
|
* @Assert\Url(checkDNS = false) |
132
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
133
|
|
|
*/ |
134
|
|
|
private $client_uri; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @JMS\Expose |
138
|
|
|
* @JMS\Groups({"client_metadata"}) |
139
|
|
|
* @Assert\Type(type="string") |
140
|
|
|
* @Assert\Url(checkDNS = false) |
141
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
142
|
|
|
*/ |
143
|
|
|
private $policy_uri; |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @JMS\Expose |
147
|
|
|
* @JMS\Groups({"client_metadata"}) |
148
|
|
|
* @Assert\Url(checkDNS = false) |
149
|
|
|
* @Assert\Type(type="string") |
150
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
151
|
|
|
*/ |
152
|
|
|
private $tos_uri; |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @JMS\Expose |
156
|
|
|
* @JMS\Groups({"client_metadata"}) |
157
|
|
|
* @Assert\Url(checkDNS = false) |
158
|
|
|
* @Assert\Type(type="string") |
159
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
160
|
|
|
*/ |
161
|
|
|
private $jwks_uri; |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @JMS\Expose |
165
|
|
|
* @JMS\Groups({"client_metadata"}) |
166
|
|
|
* @Assert\Type(type="string") |
167
|
|
|
* @ORM\Column(type="text", nullable=true) |
168
|
|
|
*/ |
169
|
|
|
private $jwks; |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @JMS\Expose |
173
|
|
|
* @JMS\Groups({"client_metadata"}) |
174
|
|
|
* @Assert\Url(checkDNS = false, protocols = {"http", "https"}) |
175
|
|
|
* @Assert\Type(type="string") |
176
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
177
|
|
|
*/ |
178
|
|
|
private $sector_identifier_uri; |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @JMS\Expose |
182
|
|
|
* @JMS\Groups({"client_metadata"}) |
183
|
|
|
* @Assert\Type(type="string") |
184
|
|
|
* @ORM\Column(type="string", length=20, nullable=false, options={"default" : "pairwise"}) |
185
|
|
|
*/ |
186
|
|
|
private $subject_type = 'pairwise'; |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @JMS\Expose |
190
|
|
|
* @JMS\Groups({"client_metadata"}) |
191
|
|
|
* @Assert\Type(type="string") |
192
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
193
|
|
|
*/ |
194
|
|
|
private $id_token_signed_response_alg; |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @JMS\Expose |
198
|
|
|
* @JMS\Groups({"client_metadata"}) |
199
|
|
|
* @Assert\Type(type="string") |
200
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
201
|
|
|
*/ |
202
|
|
|
private $id_token_encrypted_response_alg; |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @JMS\Expose |
206
|
|
|
* @JMS\Groups({"client_metadata"}) |
207
|
|
|
* @Assert\Type(type="string") |
208
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
209
|
|
|
*/ |
210
|
|
|
private $id_token_encrypted_response_enc; |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @JMS\Expose |
214
|
|
|
* @JMS\Groups({"client_metadata"}) |
215
|
|
|
* @Assert\Type(type="string") |
216
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
217
|
|
|
*/ |
218
|
|
|
private $userinfo_signed_response_alg; |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @JMS\Expose |
222
|
|
|
* @JMS\Groups({"client_metadata"}) |
223
|
|
|
* @Assert\Type(type="string") |
224
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
225
|
|
|
*/ |
226
|
|
|
private $userinfo_encrypted_response_alg; |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @JMS\Expose |
230
|
|
|
* @JMS\Groups({"client_metadata"}) |
231
|
|
|
* @Assert\Type(type="string") |
232
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
233
|
|
|
*/ |
234
|
|
|
private $userinfo_encrypted_response_enc; |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @JMS\Expose |
238
|
|
|
* @JMS\Groups({"client_metadata"}) |
239
|
|
|
* @Assert\Type(type="string") |
240
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
241
|
|
|
*/ |
242
|
|
|
private $request_object_signing_alg; |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @JMS\Expose |
246
|
|
|
* @JMS\Groups({"client_metadata"}) |
247
|
|
|
* @Assert\Type(type="string") |
248
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
249
|
|
|
*/ |
250
|
|
|
private $request_object_encryption_alg; |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @JMS\Expose |
254
|
|
|
* @JMS\Groups({"client_metadata"}) |
255
|
|
|
* @Assert\Type(type="string") |
256
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
257
|
|
|
*/ |
258
|
|
|
private $request_object_encryption_enc; |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @JMS\Expose |
262
|
|
|
* @JMS\Groups({"client_metadata"}) |
263
|
|
|
* @Assert\Type(type="string") |
264
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
265
|
|
|
*/ |
266
|
|
|
private $token_endpoint_auth_method; |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @JMS\Expose |
270
|
|
|
* @JMS\Groups({"client_metadata"}) |
271
|
|
|
* @Assert\Type(type="string") |
272
|
|
|
* @ORM\Column(type="string", length=50, nullable=true) |
273
|
|
|
*/ |
274
|
|
|
private $token_endpoint_auth_signing_alg; |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @JMS\Expose |
278
|
|
|
* @JMS\Groups({"client_metadata"}) |
279
|
|
|
* @Assert\Type(type="integer") |
280
|
|
|
* @ORM\Column(type="integer", nullable=true) |
281
|
|
|
*/ |
282
|
|
|
private $default_max_age; |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @JMS\Expose |
286
|
|
|
* @JMS\Groups({"client_metadata"}) |
287
|
|
|
* @Assert\Type(type="boolean") |
288
|
|
|
*/ |
289
|
|
|
private $require_auth_time = false; |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* @JMS\Expose |
293
|
|
|
* @JMS\Groups({"client_metadata"}) |
294
|
|
|
* @Assert\Type(type="array") |
295
|
|
|
* @ORM\Column(type="simple_array", nullable=true) |
296
|
|
|
*/ |
297
|
|
|
private $default_acr_values; |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* @JMS\Expose |
301
|
|
|
* @JMS\Groups({"client_metadata"}) |
302
|
|
|
* @Assert\Url(checkDNS = false) |
303
|
|
|
* @Assert\Type(type="string") |
304
|
|
|
* @ORM\Column(type="string", length=2000, nullable=true) |
305
|
|
|
*/ |
306
|
|
|
private $initiate_login_uri; |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* @JMS\Expose |
310
|
|
|
* @JMS\Groups({"client_metadata"}) |
311
|
|
|
* @Assert\Type("array") |
312
|
|
|
* @Assert\All({ |
313
|
|
|
* @Assert\Type("string"), |
314
|
|
|
* @Assert\Url(checkDNS = false) |
315
|
|
|
* }) |
316
|
|
|
* @ORM\Column(type="simple_array", nullable=true) |
317
|
|
|
*/ |
318
|
|
|
private $request_uris; |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* @JMS\Expose |
322
|
|
|
* @JMS\Groups({"client_metadata"}) |
323
|
|
|
* @Assert\Type(type="string") |
324
|
|
|
* @ORM\Column(type="string", nullable=true) |
325
|
|
|
*/ |
326
|
|
|
private $registration_access_token; |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @var OrganizationInterface |
330
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\OAuthBundle\Model\OrganizationInterface", inversedBy="clients") |
331
|
|
|
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
332
|
|
|
*/ |
333
|
|
|
private $organization; |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @JMS\Expose |
337
|
|
|
* @JMS\Groups({"client_metadata"}) |
338
|
|
|
* @Assert\Type("array") |
339
|
|
|
* @Assert\All({ |
340
|
|
|
* @Assert\Type("string"), |
341
|
|
|
* @Assert\Url(checkDNS = false) |
342
|
|
|
* }) |
343
|
|
|
* @ORM\Column(type="simple_array", nullable=true) |
344
|
|
|
*/ |
345
|
|
|
private $post_logout_redirect_uris; |
346
|
|
|
|
347
|
22 |
|
public function __construct() |
348
|
|
|
{ |
349
|
22 |
|
$this->response_types = ['code']; |
350
|
22 |
|
$this->grant_types = ['authorization_code']; |
351
|
22 |
|
$this->application_type = 'web'; |
352
|
22 |
|
$this->require_auth_time = false; |
353
|
22 |
|
$this->subject_type = 'pairwise'; |
354
|
22 |
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* @param mixed $id |
358
|
|
|
* @return $this |
359
|
|
|
*/ |
360
|
4 |
|
public function setId($id) |
361
|
|
|
{ |
362
|
4 |
|
$this->id = $id; |
363
|
|
|
|
364
|
4 |
|
return $this; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @return string[] |
369
|
|
|
*/ |
370
|
8 |
|
public function getRedirectUris() |
371
|
|
|
{ |
372
|
8 |
|
return $this->redirect_uris; |
373
|
|
|
} |
374
|
|
|
|
375
|
5 |
|
public function setRedirectUris($redirect_uris) |
376
|
|
|
{ |
377
|
5 |
|
$this->redirect_uris = $redirect_uris; |
378
|
|
|
|
379
|
5 |
|
return $this; |
380
|
|
|
} |
381
|
|
|
|
382
|
2 |
|
public function getResponseTypes() |
383
|
|
|
{ |
384
|
2 |
|
return $this->response_types; |
385
|
|
|
} |
386
|
|
|
|
387
|
1 |
|
public function setResponseTypes($response_types) |
388
|
|
|
{ |
389
|
1 |
|
$this->response_types = $response_types; |
390
|
|
|
|
391
|
1 |
|
return $this; |
392
|
|
|
} |
393
|
|
|
|
394
|
6 |
|
public function getGrantTypes() |
395
|
|
|
{ |
396
|
6 |
|
return $this->grant_types; |
397
|
|
|
} |
398
|
|
|
|
399
|
3 |
|
public function setGrantTypes($grant_types) |
400
|
|
|
{ |
401
|
3 |
|
$this->grant_types = $grant_types; |
402
|
|
|
|
403
|
3 |
|
return $this; |
404
|
|
|
} |
405
|
|
|
|
406
|
2 |
|
public function getApplicationType() |
407
|
|
|
{ |
408
|
2 |
|
return $this->application_type; |
409
|
|
|
} |
410
|
|
|
|
411
|
1 |
|
public function setApplicationType($application_type) |
412
|
|
|
{ |
413
|
1 |
|
$this->application_type = $application_type; |
414
|
|
|
|
415
|
1 |
|
return $this; |
416
|
|
|
} |
417
|
|
|
|
418
|
5 |
|
public function getContacts() |
419
|
|
|
{ |
420
|
5 |
|
$owners = []; |
421
|
5 |
|
if ($this->getClient()) { |
422
|
2 |
|
$owners = array_map( |
423
|
|
|
function (PersonInterface $owner) { |
424
|
1 |
|
return $owner->getEmail(); |
425
|
2 |
|
}, |
426
|
2 |
|
$this->getClient()->getOwners()->toArray() |
427
|
|
|
); |
428
|
|
|
} |
429
|
5 |
|
$contacts = $this->contacts ?? []; |
430
|
|
|
|
431
|
5 |
|
return array_unique(array_merge($contacts, $owners)); |
|
|
|
|
432
|
|
|
} |
433
|
|
|
|
434
|
3 |
|
public function setContacts($contacts) |
435
|
|
|
{ |
436
|
3 |
|
$this->contacts = $contacts; |
437
|
|
|
|
438
|
3 |
|
return $this; |
439
|
|
|
} |
440
|
|
|
|
441
|
7 |
|
public function getClientName() |
442
|
|
|
{ |
443
|
7 |
|
return $this->client_name; |
444
|
|
|
} |
445
|
|
|
|
446
|
7 |
|
public function setClientName($client_name) |
447
|
|
|
{ |
448
|
7 |
|
$this->client_name = $client_name; |
449
|
|
|
|
450
|
7 |
|
return $this; |
451
|
|
|
} |
452
|
|
|
|
453
|
1 |
|
public function getLogoUri() |
454
|
|
|
{ |
455
|
1 |
|
return $this->logo_uri; |
456
|
|
|
} |
457
|
|
|
|
458
|
1 |
|
public function setLogoUri($logo_uri) |
459
|
|
|
{ |
460
|
1 |
|
$this->logo_uri = $logo_uri; |
461
|
|
|
|
462
|
1 |
|
return $this; |
463
|
|
|
} |
464
|
|
|
|
465
|
7 |
|
public function getClientUri() |
466
|
|
|
{ |
467
|
7 |
|
return $this->client_uri; |
468
|
|
|
} |
469
|
|
|
|
470
|
5 |
|
public function setClientUri($client_uri) |
471
|
|
|
{ |
472
|
5 |
|
$this->client_uri = $client_uri; |
473
|
|
|
|
474
|
5 |
|
return $this; |
475
|
|
|
} |
476
|
|
|
|
477
|
1 |
|
public function getPolicyUri() |
478
|
|
|
{ |
479
|
1 |
|
return $this->policy_uri; |
480
|
|
|
} |
481
|
|
|
|
482
|
1 |
|
public function setPolicyUri($policy_uri) |
483
|
|
|
{ |
484
|
1 |
|
$this->policy_uri = $policy_uri; |
485
|
|
|
|
486
|
1 |
|
return $this; |
487
|
|
|
} |
488
|
|
|
|
489
|
6 |
|
public function getTosUri() |
490
|
|
|
{ |
491
|
6 |
|
return $this->tos_uri; |
492
|
|
|
} |
493
|
|
|
|
494
|
4 |
|
public function setTosUri($tos_uri) |
495
|
|
|
{ |
496
|
4 |
|
$this->tos_uri = $tos_uri; |
497
|
|
|
|
498
|
4 |
|
return $this; |
499
|
|
|
} |
500
|
|
|
|
501
|
1 |
|
public function getJwksUri() |
502
|
|
|
{ |
503
|
1 |
|
return $this->jwks_uri; |
504
|
|
|
} |
505
|
|
|
|
506
|
1 |
|
public function setJwksUri($jwks_uri) |
507
|
|
|
{ |
508
|
1 |
|
$this->jwks_uri = $jwks_uri; |
509
|
|
|
|
510
|
1 |
|
return $this; |
511
|
|
|
} |
512
|
|
|
|
513
|
1 |
|
public function getJwks() |
514
|
|
|
{ |
515
|
1 |
|
return $this->jwks; |
516
|
|
|
} |
517
|
|
|
|
518
|
1 |
|
public function setJwks($jwks) |
519
|
|
|
{ |
520
|
1 |
|
$this->jwks = $jwks; |
521
|
|
|
|
522
|
1 |
|
return $this; |
523
|
|
|
} |
524
|
|
|
|
525
|
6 |
|
public function getSectorIdentifierUri() |
526
|
|
|
{ |
527
|
6 |
|
return $this->sector_identifier_uri; |
528
|
|
|
} |
529
|
|
|
|
530
|
3 |
|
public function setSectorIdentifierUri($sector_identifier_uri) |
531
|
|
|
{ |
532
|
3 |
|
$this->sector_identifier_uri = $sector_identifier_uri; |
533
|
|
|
|
534
|
3 |
|
return $this; |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* @return string|null |
539
|
|
|
*/ |
540
|
3 |
|
public function getSubjectType() |
541
|
|
|
{ |
542
|
3 |
|
return $this->subject_type; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/** |
546
|
|
|
* @param string $subject_type |
547
|
|
|
* @return ClientMetadata |
548
|
|
|
*/ |
549
|
1 |
|
public function setSubjectType($subject_type) |
550
|
|
|
{ |
551
|
1 |
|
$this->subject_type = $subject_type; |
552
|
|
|
|
553
|
1 |
|
return $this; |
554
|
|
|
} |
555
|
|
|
|
556
|
2 |
|
public function getIdTokenSignedResponseAlg() |
557
|
|
|
{ |
558
|
2 |
|
return $this->id_token_signed_response_alg; |
559
|
|
|
} |
560
|
|
|
|
561
|
2 |
|
public function setIdTokenSignedResponseAlg($id_token_signed_response_alg) |
562
|
|
|
{ |
563
|
2 |
|
$this->id_token_signed_response_alg = $id_token_signed_response_alg; |
564
|
|
|
|
565
|
2 |
|
return $this; |
566
|
|
|
} |
567
|
|
|
|
568
|
1 |
|
public function getIdTokenEncryptedResponseAlg() |
569
|
|
|
{ |
570
|
1 |
|
return $this->id_token_encrypted_response_alg; |
571
|
|
|
} |
572
|
|
|
|
573
|
1 |
|
public function setIdTokenEncryptedResponseAlg($id_token_encrypted_response_alg) |
574
|
|
|
{ |
575
|
1 |
|
$this->id_token_encrypted_response_alg = $id_token_encrypted_response_alg; |
576
|
|
|
|
577
|
1 |
|
return $this; |
578
|
|
|
} |
579
|
|
|
|
580
|
1 |
|
public function getIdTokenEncryptedResponseEnc() |
581
|
|
|
{ |
582
|
1 |
|
return $this->id_token_encrypted_response_enc; |
583
|
|
|
} |
584
|
|
|
|
585
|
1 |
|
public function setIdTokenEncryptedResponseEnc($id_token_encrypted_response_enc) |
586
|
|
|
{ |
587
|
1 |
|
$this->id_token_encrypted_response_enc = $id_token_encrypted_response_enc; |
588
|
|
|
|
589
|
1 |
|
return $this; |
590
|
|
|
} |
591
|
|
|
|
592
|
1 |
|
public function getUserinfoSignedResponseAlg() |
593
|
|
|
{ |
594
|
1 |
|
return $this->userinfo_signed_response_alg; |
595
|
|
|
} |
596
|
|
|
|
597
|
1 |
|
public function setUserinfoSignedResponseAlg($userinfo_signed_response_alg) |
598
|
|
|
{ |
599
|
1 |
|
$this->userinfo_signed_response_alg = $userinfo_signed_response_alg; |
600
|
|
|
|
601
|
1 |
|
return $this; |
602
|
|
|
} |
603
|
|
|
|
604
|
1 |
|
public function getUserinfoEncryptedResponseAlg() |
605
|
|
|
{ |
606
|
1 |
|
return $this->userinfo_encrypted_response_alg; |
607
|
|
|
} |
608
|
|
|
|
609
|
1 |
|
public function setUserinfoEncryptedResponseAlg($userinfo_encrypted_response_alg) |
610
|
|
|
{ |
611
|
1 |
|
$this->userinfo_encrypted_response_alg = $userinfo_encrypted_response_alg; |
612
|
|
|
|
613
|
1 |
|
return $this; |
614
|
|
|
} |
615
|
|
|
|
616
|
1 |
|
public function getUserinfoEncryptedResponseEnc() |
617
|
|
|
{ |
618
|
1 |
|
return $this->userinfo_encrypted_response_enc; |
619
|
|
|
} |
620
|
|
|
|
621
|
1 |
|
public function setUserinfoEncryptedResponseEnc($userinfo_encrypted_response_enc) |
622
|
|
|
{ |
623
|
1 |
|
$this->userinfo_encrypted_response_enc = $userinfo_encrypted_response_enc; |
624
|
|
|
|
625
|
1 |
|
return $this; |
626
|
|
|
} |
627
|
|
|
|
628
|
1 |
|
public function getRequestObjectSigningAlg() |
629
|
|
|
{ |
630
|
1 |
|
return $this->request_object_signing_alg; |
631
|
|
|
} |
632
|
|
|
|
633
|
1 |
|
public function setRequestObjectSigningAlg($request_object_signing_alg) |
634
|
|
|
{ |
635
|
1 |
|
$this->request_object_signing_alg = $request_object_signing_alg; |
636
|
|
|
|
637
|
1 |
|
return $this; |
638
|
|
|
} |
639
|
|
|
|
640
|
1 |
|
public function getRequestObjectEncryptionAlg() |
641
|
|
|
{ |
642
|
1 |
|
return $this->request_object_encryption_alg; |
643
|
|
|
} |
644
|
|
|
|
645
|
1 |
|
public function setRequestObjectEncryptionAlg($request_object_encryption_alg) |
646
|
|
|
{ |
647
|
1 |
|
$this->request_object_encryption_alg = $request_object_encryption_alg; |
648
|
|
|
|
649
|
1 |
|
return $this; |
650
|
|
|
} |
651
|
|
|
|
652
|
1 |
|
public function getRequestObjectEncryptionEnc() |
653
|
|
|
{ |
654
|
1 |
|
return $this->request_object_encryption_enc; |
655
|
|
|
} |
656
|
|
|
|
657
|
1 |
|
public function setRequestObjectEncryptionEnc($request_object_encryption_enc) |
658
|
|
|
{ |
659
|
1 |
|
$this->request_object_encryption_enc = $request_object_encryption_enc; |
660
|
|
|
|
661
|
1 |
|
return $this; |
662
|
|
|
} |
663
|
|
|
|
664
|
2 |
|
public function getTokenEndpointAuthMethod() |
665
|
|
|
{ |
666
|
2 |
|
return $this->token_endpoint_auth_method; |
667
|
|
|
} |
668
|
|
|
|
669
|
2 |
|
public function setTokenEndpointAuthMethod($token_endpoint_auth_method) |
670
|
|
|
{ |
671
|
2 |
|
$this->token_endpoint_auth_method = $token_endpoint_auth_method; |
672
|
|
|
|
673
|
2 |
|
return $this; |
674
|
|
|
} |
675
|
|
|
|
676
|
1 |
|
public function getTokenEndpointAuthSigningAlg() |
677
|
|
|
{ |
678
|
1 |
|
return $this->token_endpoint_auth_signing_alg; |
679
|
|
|
} |
680
|
|
|
|
681
|
1 |
|
public function setTokenEndpointAuthSigningAlg($token_endpoint_auth_signing_alg) |
682
|
|
|
{ |
683
|
1 |
|
$this->token_endpoint_auth_signing_alg = $token_endpoint_auth_signing_alg; |
684
|
|
|
|
685
|
1 |
|
return $this; |
686
|
|
|
} |
687
|
|
|
|
688
|
1 |
|
public function getDefaultMaxAge() |
689
|
|
|
{ |
690
|
1 |
|
return $this->default_max_age; |
691
|
|
|
} |
692
|
|
|
|
693
|
1 |
|
public function setDefaultMaxAge($default_max_age) |
694
|
|
|
{ |
695
|
1 |
|
$this->default_max_age = $default_max_age; |
696
|
|
|
|
697
|
1 |
|
return $this; |
698
|
|
|
} |
699
|
|
|
|
700
|
2 |
|
public function getRequireAuthTime() |
701
|
|
|
{ |
702
|
2 |
|
return $this->require_auth_time; |
703
|
|
|
} |
704
|
|
|
|
705
|
2 |
|
public function setRequireAuthTime($require_auth_time) |
706
|
|
|
{ |
707
|
2 |
|
$this->require_auth_time = $require_auth_time; |
708
|
|
|
|
709
|
2 |
|
return $this; |
710
|
|
|
} |
711
|
|
|
|
712
|
1 |
|
public function getDefaultAcrValues() |
713
|
|
|
{ |
714
|
1 |
|
return $this->default_acr_values; |
715
|
|
|
} |
716
|
|
|
|
717
|
|
|
/** |
718
|
|
|
* @param $default_acr_values |
719
|
|
|
* @return ClientMetadata |
720
|
|
|
*/ |
721
|
1 |
|
public function setDefaultAcrValues($default_acr_values) |
722
|
|
|
{ |
723
|
1 |
|
$this->default_acr_values = $default_acr_values; |
724
|
|
|
|
725
|
1 |
|
return $this; |
726
|
|
|
} |
727
|
|
|
|
728
|
2 |
|
public function getInitiateLoginUri() |
729
|
|
|
{ |
730
|
2 |
|
return $this->initiate_login_uri; |
731
|
|
|
} |
732
|
|
|
|
733
|
|
|
/** |
734
|
|
|
* @param $initiate_login_uri |
735
|
|
|
* @return ClientMetadata |
736
|
|
|
*/ |
737
|
2 |
|
public function setInitiateLoginUri($initiate_login_uri) |
738
|
|
|
{ |
739
|
2 |
|
$this->initiate_login_uri = $initiate_login_uri; |
740
|
|
|
|
741
|
2 |
|
return $this; |
742
|
|
|
} |
743
|
|
|
|
744
|
1 |
|
public function getRequestUris() |
745
|
|
|
{ |
746
|
1 |
|
return $this->request_uris; |
747
|
|
|
} |
748
|
|
|
|
749
|
1 |
|
public function setRequestUris($request_uris) |
750
|
|
|
{ |
751
|
1 |
|
$this->request_uris = $request_uris; |
752
|
|
|
|
753
|
1 |
|
return $this; |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* @JMS\Groups({"client_metadata"}) |
758
|
|
|
* @JMS\VirtualProperty |
759
|
|
|
* @JMS\SerializedName("client_id") |
760
|
|
|
*/ |
761
|
3 |
|
public function getClientId() |
762
|
|
|
{ |
763
|
3 |
|
if ($this->client_id === null && $this->client) { |
764
|
1 |
|
return $this->client->getClientId(); |
765
|
|
|
} |
766
|
|
|
|
767
|
2 |
|
return $this->client_id; |
768
|
|
|
} |
769
|
|
|
|
770
|
2 |
|
public function setClientId($client_id) |
771
|
|
|
{ |
772
|
2 |
|
$this->client_id = $client_id; |
773
|
|
|
|
774
|
2 |
|
return $this; |
775
|
|
|
} |
776
|
|
|
|
777
|
|
|
/** |
778
|
|
|
* @JMS\Groups({"client_metadata"}) |
779
|
|
|
* @JMS\VirtualProperty |
780
|
|
|
* @JMS\SerializedName("client_secret") |
781
|
|
|
*/ |
782
|
3 |
|
public function getClientSecret() |
783
|
|
|
{ |
784
|
3 |
|
if ($this->client_id === null && $this->client) { |
785
|
1 |
|
return $this->client->getClientSecret(); |
786
|
|
|
} |
787
|
|
|
|
788
|
2 |
|
return $this->client_secret; |
789
|
|
|
} |
790
|
|
|
|
791
|
2 |
|
public function setClientSecret($client_secret) |
792
|
|
|
{ |
793
|
2 |
|
$this->client_secret = $client_secret; |
794
|
|
|
|
795
|
2 |
|
return $this; |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
/** |
799
|
|
|
* @param Client $client |
800
|
|
|
* @return ClientMetadata |
801
|
|
|
*/ |
802
|
1 |
|
public function fromClient(Client $client) |
803
|
|
|
{ |
804
|
1 |
|
$this->setGrantTypes($client->getAllowedGrantTypes()) |
805
|
1 |
|
->setClientUri($client->getSiteUrl()) |
806
|
1 |
|
->setTosUri($client->getTermsOfUseUrl()) |
807
|
1 |
|
->setClientName($client->getName()) |
808
|
1 |
|
->setRedirectUris($client->getRedirectUris()); |
809
|
|
|
|
810
|
1 |
|
$this->setClientId($client->getPublicId()) |
811
|
1 |
|
->setClientSecret($client->getSecret()); |
812
|
|
|
|
813
|
1 |
|
return $this; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
/** |
817
|
|
|
* @return Client |
818
|
|
|
*/ |
819
|
3 |
|
public function toClient() |
820
|
|
|
{ |
821
|
3 |
|
$grantTypes = $this->getGrantTypes(); |
822
|
3 |
|
$clientUri = $this->getClientUri(); |
823
|
3 |
|
$tosUri = $this->getTosUri(); |
824
|
3 |
|
$clientName = $this->getClientName(); |
825
|
3 |
|
$redirectUris = $this->getRedirectUris(); |
826
|
|
|
|
827
|
3 |
|
$client = new Client(); |
828
|
|
|
|
829
|
3 |
|
if ($grantTypes) { |
|
|
|
|
830
|
3 |
|
$client->setAllowedGrantTypes($grantTypes); |
831
|
|
|
} |
832
|
|
|
|
833
|
3 |
|
if ($clientUri) { |
834
|
1 |
|
$client->setLandingPageUrl($clientUri) |
835
|
1 |
|
->setSiteUrl($clientUri); |
836
|
|
|
} |
837
|
|
|
|
838
|
3 |
|
if ($tosUri) { |
839
|
1 |
|
$client->setTermsOfUseUrl($tosUri); |
840
|
|
|
} |
841
|
|
|
|
842
|
3 |
|
if ($clientName) { |
843
|
1 |
|
$client->setName($clientName); |
844
|
|
|
} |
845
|
|
|
|
846
|
3 |
|
if (is_array($redirectUris) && count($redirectUris) > 0) { |
847
|
1 |
|
$client->setRedirectUris($redirectUris); |
848
|
|
|
} |
849
|
|
|
|
850
|
3 |
|
$client->setVisible(false) |
851
|
3 |
|
->setPublished(false); |
852
|
|
|
|
853
|
3 |
|
return $client; |
854
|
|
|
} |
855
|
|
|
|
856
|
7 |
|
public function getClient() |
857
|
|
|
{ |
858
|
7 |
|
return $this->client; |
859
|
|
|
} |
860
|
|
|
|
861
|
10 |
|
public function setClient(ClientInterface $client) |
862
|
|
|
{ |
863
|
10 |
|
$this->client = $client; |
864
|
|
|
|
865
|
10 |
|
return $this; |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
/** |
869
|
|
|
* @ORM\PrePersist() |
870
|
|
|
*/ |
871
|
2 |
|
public function checkDefaults() |
872
|
|
|
{ |
873
|
2 |
|
$this->enforceDefaultGrantTypes(); |
874
|
2 |
|
$this->enforceDefaultResponseTypes(); |
875
|
2 |
|
$this->enforceDefaultApplicationType(); |
876
|
2 |
|
$this->enforceDefaultRequireAuthTime(); |
877
|
2 |
|
$this->enforceDefaultIdTokenSignedResponseAlg(); |
878
|
2 |
|
$this->enforceDefaultTokenEndpointAuthMethod(); |
879
|
2 |
|
$this->enforceValidSubjectType(); |
880
|
2 |
|
} |
881
|
|
|
|
882
|
2 |
|
private function enforceDefaultGrantTypes() |
883
|
|
|
{ |
884
|
2 |
|
if (!$this->getGrantTypes()) { |
885
|
1 |
|
$this->setGrantTypes(['authorization_code']); |
886
|
|
|
} |
887
|
2 |
|
} |
888
|
|
|
|
889
|
2 |
|
private function enforceDefaultResponseTypes() |
890
|
|
|
{ |
891
|
2 |
|
if (!$this->getResponseTypes()) { |
892
|
1 |
|
$this->setResponseTypes(['code']); |
893
|
|
|
} |
894
|
2 |
|
} |
895
|
|
|
|
896
|
2 |
|
private function enforceDefaultApplicationType() |
897
|
|
|
{ |
898
|
2 |
|
if (!$this->getApplicationType()) { |
899
|
1 |
|
$this->setApplicationType('web'); |
900
|
|
|
} |
901
|
2 |
|
} |
902
|
|
|
|
903
|
2 |
|
private function enforceDefaultRequireAuthTime() |
904
|
|
|
{ |
905
|
2 |
|
if (!$this->getRequireAuthTime()) { |
906
|
2 |
|
$this->setRequireAuthTime(false); |
907
|
|
|
} |
908
|
2 |
|
} |
909
|
|
|
|
910
|
2 |
|
private function enforceDefaultIdTokenSignedResponseAlg() |
911
|
|
|
{ |
912
|
2 |
|
if (!$this->getIdTokenSignedResponseAlg()) { |
913
|
2 |
|
$this->setIdTokenSignedResponseAlg('RS256'); |
914
|
|
|
} |
915
|
2 |
|
} |
916
|
|
|
|
917
|
2 |
|
private function enforceDefaultTokenEndpointAuthMethod() |
918
|
|
|
{ |
919
|
2 |
|
if (!$this->getTokenEndpointAuthMethod()) { |
920
|
2 |
|
$this->setTokenEndpointAuthMethod('client_secret_basic'); |
921
|
|
|
} |
922
|
2 |
|
} |
923
|
|
|
|
924
|
2 |
|
private function enforceValidSubjectType() |
925
|
|
|
{ |
926
|
2 |
|
if (false === array_search($this->getSubjectType(), ['public', 'pairwise'])) { |
927
|
1 |
|
$this->setSubjectType('pairwise'); |
928
|
|
|
} |
929
|
2 |
|
} |
930
|
|
|
|
931
|
3 |
|
public function getSectorIdentifier() |
932
|
|
|
{ |
933
|
3 |
|
$siUri = $this->getSectorIdentifierUri(); |
934
|
3 |
|
if ($siUri) { |
935
|
1 |
|
$uri = $siUri; |
936
|
|
|
} else { |
937
|
2 |
|
$uris = $this->getRedirectUris(); |
938
|
2 |
|
$uri = reset($uris); |
939
|
|
|
} |
940
|
|
|
|
941
|
3 |
|
return parse_url($uri, PHP_URL_HOST); |
942
|
|
|
} |
943
|
|
|
|
944
|
4 |
|
public function getRegistrationAccessToken() |
945
|
|
|
{ |
946
|
4 |
|
return $this->registration_access_token; |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
/** |
950
|
|
|
* @param string $registration_access_token |
951
|
|
|
* @return ClientMetadata |
952
|
|
|
*/ |
953
|
4 |
|
public function setRegistrationAccessToken($registration_access_token) |
954
|
|
|
{ |
955
|
4 |
|
$this->registration_access_token = $registration_access_token; |
956
|
|
|
|
957
|
4 |
|
return $this; |
958
|
|
|
} |
959
|
|
|
|
960
|
|
|
/** |
961
|
|
|
* @return OrganizationInterface |
962
|
|
|
*/ |
963
|
3 |
|
public function getOrganization() |
964
|
|
|
{ |
965
|
3 |
|
return $this->organization; |
966
|
|
|
} |
967
|
|
|
|
968
|
|
|
/** |
969
|
|
|
* @param OrganizationInterface $organization |
970
|
|
|
*/ |
971
|
2 |
|
public function setOrganization($organization = null) |
972
|
|
|
{ |
973
|
2 |
|
$this->organization = $organization; |
974
|
2 |
|
} |
975
|
|
|
|
976
|
|
|
/** |
977
|
|
|
* @return array |
978
|
|
|
*/ |
979
|
1 |
|
public function getPostLogoutRedirectUris() |
980
|
|
|
{ |
981
|
1 |
|
return array_map( |
982
|
|
|
function ($value) { |
983
|
1 |
|
return self::canonicalizeUri($value); |
984
|
1 |
|
}, |
985
|
1 |
|
$this->post_logout_redirect_uris ?? [] |
|
|
|
|
986
|
|
|
); |
987
|
|
|
} |
988
|
|
|
|
989
|
|
|
/** |
990
|
|
|
* @param array |
991
|
|
|
* @return ClientMetadata |
992
|
|
|
*/ |
993
|
1 |
|
public function setPostLogoutRedirectUris($post_logout_redirect_uris) |
994
|
|
|
{ |
995
|
1 |
|
$this->post_logout_redirect_uris = $post_logout_redirect_uris; |
996
|
|
|
|
997
|
1 |
|
return $this; |
998
|
|
|
} |
999
|
|
|
|
1000
|
|
|
/** |
1001
|
|
|
* Add trailing slashes |
1002
|
|
|
* @param $uri |
1003
|
|
|
* @return string |
1004
|
|
|
*/ |
1005
|
2 |
|
public static function canonicalizeUri($uri) |
1006
|
|
|
{ |
1007
|
2 |
|
$parsed = parse_url($uri); |
1008
|
2 |
|
if (array_key_exists('path', $parsed) === false) { |
1009
|
1 |
|
$parsed['path'] = '/'; |
1010
|
|
|
} |
1011
|
|
|
|
1012
|
2 |
|
return self::unparseUrl($parsed); |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
2 |
|
private static function unparseUrl($parsed_url) |
1016
|
|
|
{ |
1017
|
2 |
|
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
1018
|
2 |
|
$host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
1019
|
2 |
|
$port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
1020
|
2 |
|
$user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; |
1021
|
2 |
|
$pass = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : ''; |
1022
|
2 |
|
$pass = ($user || $pass) ? "$pass@" : ''; |
1023
|
2 |
|
$path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; |
1024
|
2 |
|
$query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
1025
|
2 |
|
$fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
1026
|
|
|
|
1027
|
2 |
|
return "$scheme$user$pass$host$port$path$query$fragment"; |
1028
|
|
|
} |
1029
|
|
|
} |
1030
|
|
|
|