1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OAuth; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use League\OAuth2\Server\Entities\ClientEntityInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @ORM\Entity(repositoryClass="OAuth\Repository\ClientRepository") |
11
|
|
|
* @ORM\Table(name="Client",uniqueConstraints={@ORM\UniqueConstraint(name="indentifier_idx", columns={"identifier"})}) |
12
|
|
|
*/ |
13
|
|
|
class Client implements ClientEntityInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @ORM\Id |
17
|
|
|
* @var string |
18
|
|
|
* @ORM\Column(type="integer", length=11) |
19
|
|
|
* @ORM\GeneratedValue |
20
|
|
|
*/ |
21
|
|
|
private $id; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
* @ORM\Column(type="string", length=40) |
26
|
|
|
*/ |
27
|
|
|
private $name; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
* @ORM\Column(type="string", length=255) |
32
|
|
|
*/ |
33
|
|
|
private $description; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
* @ORM\Column(type="string", length=100) |
38
|
|
|
*/ |
39
|
|
|
private $icon; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
* @ORM\Column(type="string", length=20) |
44
|
|
|
*/ |
45
|
|
|
private $grantType; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string|string[] |
49
|
|
|
* @ORM\Column(type="string", length=255) |
50
|
|
|
*/ |
51
|
|
|
private $redirectUri; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
* @ORM\Column(type="string", length=40) |
56
|
|
|
*/ |
57
|
|
|
private $identifier; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var string |
61
|
|
|
* @ORM\Column(type="string", length=40, nullable=true) |
62
|
|
|
*/ |
63
|
|
|
private $secret; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var bool $confidential |
67
|
|
|
* @ORM\Column(type="boolean") |
68
|
|
|
*/ |
69
|
|
|
private $confidential; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var OAuthUser $user |
73
|
|
|
*/ |
74
|
|
|
private $user; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var ArrayCollection $scopes |
78
|
|
|
* @ORM\ManyToMany(targetEntity="Scope") |
79
|
|
|
* @ORM\JoinTable(name="Client_Scope", |
80
|
|
|
* joinColumns={@ORM\JoinColumn(name="client_id", referencedColumnName="id")}, |
81
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="identifier")} |
82
|
|
|
* ) |
83
|
|
|
*/ |
84
|
|
|
private $scopes; |
85
|
|
|
|
86
|
5 |
|
public function __construct() |
87
|
|
|
{ |
88
|
5 |
|
$this->scopes = new ArrayCollection(); |
89
|
5 |
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
1 |
|
public function getIdentifier() |
95
|
|
|
{ |
96
|
1 |
|
return $this->identifier; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param string $identifier |
101
|
|
|
*/ |
102
|
1 |
|
public function setIdentifier($identifier) |
103
|
|
|
{ |
104
|
1 |
|
$this->identifier = $identifier; |
105
|
1 |
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Get the client's name. |
109
|
|
|
* |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
3 |
|
public function getName() |
113
|
|
|
{ |
114
|
3 |
|
return $this->name; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Returns the registered redirect URI (as a string). |
119
|
|
|
* |
120
|
|
|
* Alternatively return an indexed array of redirect URIs. |
121
|
|
|
* |
122
|
|
|
* @return string|string[] |
123
|
|
|
*/ |
124
|
1 |
|
public function getRedirectUri() |
125
|
|
|
{ |
126
|
1 |
|
return $this->redirectUri; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param string $name |
131
|
|
|
* @return Client |
132
|
|
|
*/ |
133
|
3 |
|
public function setName($name) |
134
|
|
|
{ |
135
|
3 |
|
$this->name = $name; |
136
|
3 |
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param string|\string[] $redirectUri |
141
|
|
|
* @return Client |
142
|
|
|
*/ |
143
|
1 |
|
public function setRedirectUri($redirectUri) |
144
|
|
|
{ |
145
|
1 |
|
$this->redirectUri = $redirectUri; |
146
|
1 |
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return string |
151
|
|
|
*/ |
152
|
|
|
public function getSecret(): string |
153
|
|
|
{ |
154
|
|
|
return $this->secret; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param string $secret |
159
|
|
|
* @return Client |
160
|
|
|
*/ |
161
|
|
|
public function setSecret(string $secret): Client |
162
|
|
|
{ |
163
|
|
|
$this->secret = $secret; |
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return bool |
169
|
|
|
*/ |
170
|
|
|
public function isConfidential(): bool |
171
|
|
|
{ |
172
|
|
|
return $this->confidential; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param bool $confidential |
177
|
|
|
* @return Client |
178
|
|
|
*/ |
179
|
|
|
public function setConfidential(bool $confidential): Client |
180
|
|
|
{ |
181
|
|
|
$this->confidential = $confidential; |
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return string |
187
|
|
|
*/ |
188
|
|
|
public function getId(): string |
189
|
|
|
{ |
190
|
|
|
return $this->id; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @param string $id |
195
|
|
|
* @return Client |
196
|
|
|
*/ |
197
|
|
|
public function setId(string $id): Client |
198
|
|
|
{ |
199
|
|
|
$this->id = $id; |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return string |
205
|
|
|
*/ |
206
|
|
|
public function getDescription(): string |
207
|
|
|
{ |
208
|
|
|
return $this->description; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param string $description |
213
|
|
|
*/ |
214
|
|
|
public function setDescription(string $description): void |
215
|
|
|
{ |
216
|
|
|
$this->description = $description; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return string |
221
|
|
|
*/ |
222
|
|
|
public function getIcon(): string |
223
|
|
|
{ |
224
|
|
|
return $this->icon; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @param string $icon |
229
|
|
|
*/ |
230
|
|
|
public function setIcon(string $icon): void |
231
|
|
|
{ |
232
|
|
|
$this->icon = $icon; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return string |
237
|
|
|
*/ |
238
|
|
|
public function getGrantType(): string |
239
|
|
|
{ |
240
|
|
|
return $this->grantType; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param string $grantType |
245
|
|
|
*/ |
246
|
|
|
public function setGrantType(string $grantType): void |
247
|
|
|
{ |
248
|
|
|
$this->grantType = $grantType; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @return OAuthUser |
253
|
|
|
*/ |
254
|
|
|
public function getUser(): OAuthUser |
255
|
|
|
{ |
256
|
|
|
return $this->user; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @param OAuthUser $user |
261
|
|
|
*/ |
262
|
|
|
public function setUser(OAuthUser $user): void |
263
|
|
|
{ |
264
|
|
|
$this->user = $user; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @return ArrayCollection |
269
|
|
|
*/ |
270
|
|
|
public function getScopes(): ArrayCollection |
271
|
|
|
{ |
272
|
|
|
return $this->scopes; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param ArrayCollection $scopes |
277
|
|
|
* @return Client |
278
|
|
|
*/ |
279
|
|
|
public function setScopes(ArrayCollection $scopes): Client |
280
|
|
|
{ |
281
|
|
|
$this->scopes = $scopes; |
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
} |