1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TMV\OpenIdClient\Client; |
6
|
|
|
|
7
|
|
|
use Jose\Component\Core\JWKSet; |
8
|
|
|
use TMV\OpenIdClient\AuthMethod\AuthMethodFactory; |
9
|
|
|
use TMV\OpenIdClient\AuthMethod\AuthMethodFactoryInterface; |
10
|
|
|
use TMV\OpenIdClient\AuthMethod\ClientSecretBasic; |
11
|
|
|
use TMV\OpenIdClient\AuthMethod\ClientSecretJwt; |
12
|
|
|
use TMV\OpenIdClient\AuthMethod\ClientSecretPost; |
13
|
|
|
use TMV\OpenIdClient\AuthMethod\None; |
14
|
|
|
use TMV\OpenIdClient\AuthMethod\PrivateKeyJwt; |
15
|
|
|
use TMV\OpenIdClient\AuthMethod\SelfSignedTLSClientAuth; |
16
|
|
|
use TMV\OpenIdClient\AuthMethod\TLSClientAuth; |
17
|
|
|
use TMV\OpenIdClient\Client\Metadata\ClientMetadataInterface; |
18
|
|
|
use TMV\OpenIdClient\Issuer\IssuerInterface; |
19
|
|
|
|
20
|
|
|
final class Client implements ClientInterface |
21
|
|
|
{ |
22
|
|
|
/** @var IssuerInterface */ |
23
|
|
|
private $issuer; |
24
|
|
|
|
25
|
|
|
/** @var ClientMetadataInterface */ |
26
|
|
|
private $metadata; |
27
|
|
|
|
28
|
|
|
/** @var JWKSet */ |
29
|
|
|
private $jwks; |
30
|
|
|
|
31
|
|
|
/** @var AuthMethodFactoryInterface */ |
32
|
|
|
private $authMethodFactory; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Client constructor. |
36
|
|
|
* |
37
|
|
|
* @param IssuerInterface $issuer |
38
|
|
|
* @param ClientMetadataInterface $metadata |
39
|
|
|
* @param null|JWKSet $jwks |
40
|
|
|
* @param null|AuthMethodFactoryInterface $authMethodFactory |
41
|
|
|
*/ |
42
|
2 |
|
public function __construct( |
43
|
|
|
IssuerInterface $issuer, |
44
|
|
|
ClientMetadataInterface $metadata, |
45
|
|
|
?JWKSet $jwks = null, |
46
|
|
|
?AuthMethodFactoryInterface $authMethodFactory = null |
47
|
|
|
) { |
48
|
2 |
|
$this->issuer = $issuer; |
49
|
2 |
|
$this->metadata = $metadata; |
50
|
2 |
|
$this->jwks = $jwks ?: new JWKSet([]); |
51
|
2 |
|
$this->authMethodFactory = $authMethodFactory ?: new AuthMethodFactory([ |
52
|
1 |
|
new ClientSecretBasic(), |
53
|
1 |
|
new ClientSecretJwt(), |
54
|
1 |
|
new ClientSecretPost(), |
55
|
1 |
|
new None(), |
56
|
1 |
|
new PrivateKeyJwt(), |
57
|
1 |
|
new TLSClientAuth(), |
58
|
1 |
|
new SelfSignedTLSClientAuth(), |
59
|
|
|
]); |
60
|
2 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return IssuerInterface |
64
|
|
|
*/ |
65
|
2 |
|
public function getIssuer(): IssuerInterface |
66
|
|
|
{ |
67
|
2 |
|
return $this->issuer; |
68
|
|
|
} |
69
|
|
|
|
70
|
2 |
|
public function getMetadata(): ClientMetadataInterface |
71
|
|
|
{ |
72
|
2 |
|
return $this->metadata; |
73
|
|
|
} |
74
|
|
|
|
75
|
2 |
|
public function getJwks(): JWKSet |
76
|
|
|
{ |
77
|
2 |
|
return $this->jwks; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return AuthMethodFactoryInterface |
82
|
|
|
*/ |
83
|
2 |
|
public function getAuthMethodFactory(): AuthMethodFactoryInterface |
84
|
|
|
{ |
85
|
2 |
|
return $this->authMethodFactory; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|