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\TokenEndpoint; |
15
|
|
|
|
16
|
|
|
use Assert\Assertion; |
17
|
|
|
use OAuth2Framework\Component\Core\Client\Client; |
18
|
|
|
use OAuth2Framework\Component\Core\DataBag\DataBag; |
19
|
|
|
use OAuth2Framework\Component\Core\ResourceOwner\ResourceOwnerId; |
20
|
|
|
|
21
|
|
|
class GrantTypeData |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var DataBag |
25
|
|
|
*/ |
26
|
|
|
private $metadata; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var DataBag |
30
|
|
|
*/ |
31
|
|
|
private $parameter; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var ResourceOwnerId|null |
35
|
|
|
*/ |
36
|
|
|
private $resourceOwnerId; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var Client|null |
40
|
|
|
*/ |
41
|
|
|
private $client; |
42
|
|
|
|
43
|
|
|
public function __construct(?Client $client) |
44
|
|
|
{ |
45
|
|
|
$this->parameter = new DataBag([]); |
46
|
|
|
$this->metadata = new DataBag([]); |
47
|
|
|
$this->client = $client; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getMetadata(): DataBag |
51
|
|
|
{ |
52
|
|
|
return $this->metadata; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getParameter(): DataBag |
56
|
|
|
{ |
57
|
|
|
return $this->parameter; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setClient(Client $client): void |
61
|
|
|
{ |
62
|
|
|
$this->client = $client; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function hasClient(): bool |
66
|
|
|
{ |
67
|
|
|
return null !== $this->client; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getClient(): Client |
71
|
|
|
{ |
72
|
|
|
Assertion::notNull($this->client, 'internal_server_error'); |
73
|
|
|
|
74
|
|
|
return $this->client; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function setResourceOwnerId(ResourceOwnerId $resourceOwnerId): void |
78
|
|
|
{ |
79
|
|
|
$this->resourceOwnerId = $resourceOwnerId; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function hasResourceOwnerId(): bool |
83
|
|
|
{ |
84
|
|
|
return null !== $this->resourceOwnerId; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getResourceOwnerId(): ResourceOwnerId |
88
|
|
|
{ |
89
|
|
|
Assertion::notNull($this->resourceOwnerId, 'internal_server_error'); |
90
|
|
|
|
91
|
|
|
return $this->resourceOwnerId; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|