1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Component\OpenIdConnect; |
15
|
|
|
|
16
|
|
|
use Jose\Component\KeyManagement\JKUFactory; |
17
|
|
|
use OAuth2Framework\Component\AuthorizationCodeGrant\AuthorizationCodeRepository; |
18
|
|
|
use OAuth2Framework\Component\Core\Client\Client; |
19
|
|
|
use OAuth2Framework\Component\Core\UserAccount\UserAccount; |
20
|
|
|
use OAuth2Framework\Component\OpenIdConnect\UserInfo\UserInfo; |
21
|
|
|
|
22
|
|
|
class IdTokenBuilderFactory |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $issuer; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var UserInfo |
31
|
|
|
*/ |
32
|
|
|
private $userinfo; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var int |
36
|
|
|
*/ |
37
|
|
|
private $lifetime; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var null|JKUFactory |
41
|
|
|
*/ |
42
|
|
|
private $jkuFactory = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var null|AuthorizationCodeRepository |
46
|
|
|
*/ |
47
|
|
|
private $authorizationCodeRepository = null; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* IdTokenBuilder constructor. |
51
|
|
|
* |
52
|
|
|
* @param string $issuer |
53
|
|
|
* @param UserInfo $userinfo |
54
|
|
|
* @param int $lifetime |
55
|
|
|
*/ |
56
|
|
|
public function __construct(string $issuer, UserInfo $userinfo, int $lifetime) |
57
|
|
|
{ |
58
|
|
|
$this->issuer = $issuer; |
59
|
|
|
$this->userinfo = $userinfo; |
60
|
|
|
$this->lifetime = $lifetime; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param Client $client |
65
|
|
|
* @param UserAccount $userAccount |
66
|
|
|
* @param string $redirectUri |
67
|
|
|
* |
68
|
|
|
* @return IdTokenBuilder |
|
|
|
|
69
|
|
|
*/ |
70
|
|
|
public function createBuilder(Client $client, UserAccount $userAccount, string $redirectUri) |
71
|
|
|
{ |
72
|
|
|
return IdTokenBuilder::create($this->issuer, $this->userinfo, $this->lifetime, $client, $userAccount, $redirectUri, $this->jkuFactory, $this->authorizationCodeRepository); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function enableJkuSupport(JKUFactory $jkuFactory): void |
76
|
|
|
{ |
77
|
|
|
$this->jkuFactory = $jkuFactory; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function enableAuthorizationCodeSupport(AuthorizationCodeRepository $authorizationCodeRepository): void |
81
|
|
|
{ |
82
|
|
|
$this->authorizationCodeRepository = $authorizationCodeRepository; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.