1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: Alexandre |
5
|
|
|
* Date: 20/05/2018 |
6
|
|
|
* Time: 19:49 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace OAuth2\Endpoints; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
use OAuth2\AuthorizationEndpointResponseTypes\ResponseTypeInterface; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
use OAuth2\ResponseModes\ResponseModeInterface; |
16
|
|
|
use OAuth2\Roles\ClientTypes\RegisteredClient; |
17
|
|
|
use OAuth2\Roles\ResourceOwnerInterface; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
use Psr\Http\Message\UriInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class AuthorizationRequest |
24
|
|
|
* @package OAuth2\Endpoints |
25
|
|
|
*/ |
26
|
|
|
class AuthorizationRequest |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
protected $data; |
32
|
|
|
/** |
33
|
|
|
* @var RegisteredClient |
34
|
|
|
*/ |
35
|
|
|
protected $client; |
36
|
|
|
/** |
37
|
|
|
* @var UriInterface |
38
|
|
|
*/ |
39
|
|
|
private $redirectUri; |
40
|
|
|
/** |
41
|
|
|
* @var ResponseTypeInterface |
42
|
|
|
*/ |
43
|
|
|
private $responseType; |
44
|
|
|
/** |
45
|
|
|
* @var ResponseModeInterface |
46
|
|
|
*/ |
47
|
|
|
private $responseMode; |
48
|
|
|
/** |
49
|
|
|
* @var array |
50
|
|
|
*/ |
51
|
|
|
private $scopes; |
52
|
|
|
/** |
53
|
|
|
* @var null|string |
54
|
|
|
*/ |
55
|
|
|
private $state; |
56
|
|
|
/** |
57
|
|
|
* @var ResourceOwnerInterface |
58
|
|
|
*/ |
59
|
|
|
private $resourceOwner; |
60
|
|
|
/** |
61
|
|
|
* @var array|null |
62
|
|
|
*/ |
63
|
|
|
private $requestedScopes; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* AuthorizationRequest constructor. |
67
|
|
|
* @param array $data |
68
|
|
|
* @param ResourceOwnerInterface $resourceOwner |
69
|
|
|
* @param RegisteredClient $client |
70
|
|
|
* @param UriInterface $redirectUri |
71
|
|
|
* @param ResponseTypeInterface $responseType |
72
|
|
|
* @param ResponseModeInterface $responseMode |
73
|
|
|
* @param array $scopes |
74
|
|
|
* @param array|null $requestedScopes |
75
|
|
|
* @param null|string $state |
76
|
|
|
*/ |
77
|
|
|
public function __construct(array $data, ResourceOwnerInterface $resourceOwner, |
78
|
|
|
RegisteredClient $client, UriInterface $redirectUri, |
79
|
|
|
ResponseTypeInterface $responseType, ResponseModeInterface $responseMode, |
80
|
|
|
array $scopes, ?array $requestedScopes, ?string $state) |
81
|
|
|
{ |
82
|
|
|
$this->data = $data; |
83
|
|
|
$this->resourceOwner = $resourceOwner; |
84
|
|
|
$this->client = $client; |
85
|
|
|
$this->redirectUri = $redirectUri; |
86
|
|
|
$this->responseType = $responseType; |
87
|
|
|
$this->responseMode = $responseMode; |
88
|
|
|
$this->scopes = $scopes; |
89
|
|
|
$this->state = $state; |
90
|
|
|
$this->requestedScopes = $requestedScopes; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getData(): array |
94
|
|
|
{ |
95
|
|
|
return $this->data; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return ResourceOwnerInterface |
100
|
|
|
*/ |
101
|
|
|
public function getResourceOwner(): ResourceOwnerInterface |
102
|
|
|
{ |
103
|
|
|
return $this->resourceOwner; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return RegisteredClient |
109
|
|
|
*/ |
110
|
|
|
public function getClient(): RegisteredClient |
111
|
|
|
{ |
112
|
|
|
return $this->client; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return UriInterface |
117
|
|
|
*/ |
118
|
|
|
public function getRedirectUri(): UriInterface |
119
|
|
|
{ |
120
|
|
|
return $this->redirectUri; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return ResponseTypeInterface |
125
|
|
|
*/ |
126
|
|
|
public function getResponseType(): ResponseTypeInterface |
127
|
|
|
{ |
128
|
|
|
return $this->responseType; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return ResponseModeInterface |
133
|
|
|
*/ |
134
|
|
|
public function getResponseMode(): ResponseModeInterface |
135
|
|
|
{ |
136
|
|
|
return $this->responseMode; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return array |
141
|
|
|
*/ |
142
|
|
|
public function getScopes(): array |
143
|
|
|
{ |
144
|
|
|
return $this->scopes; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return array|null |
149
|
|
|
*/ |
150
|
|
|
public function getRequestedScopes(): ?array |
151
|
|
|
{ |
152
|
|
|
return $this->requestedScopes; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return null|string |
157
|
|
|
*/ |
158
|
|
|
public function getState(): ?string |
159
|
|
|
{ |
160
|
|
|
return $this->state; |
161
|
|
|
} |
162
|
|
|
} |