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
|
|
|
/** |
17
|
|
|
* @ORM\Id |
18
|
|
|
* @var string |
19
|
|
|
* @ORM\Column(type="integer", length=11) |
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|string[] |
31
|
|
|
* @ORM\Column(type="string", length=255) |
32
|
|
|
*/ |
33
|
|
|
private $redirectUri; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
* @ORM\Column(type="string", length=40) |
38
|
|
|
*/ |
39
|
|
|
private $identifier; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
* @ORM\Column(type="string", length=40, nullable=true) |
44
|
|
|
*/ |
45
|
|
|
private $secret; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var bool $confidential |
49
|
|
|
* @ORM\Column(type="boolean") |
50
|
|
|
*/ |
51
|
|
|
private $confidential; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var ArrayCollection $scopes |
55
|
|
|
* @ORM\ManyToMany(targetEntity="Scope") |
56
|
|
|
* @ORM\JoinTable(name="Client_Scope", |
57
|
|
|
* joinColumns={@ORM\JoinColumn(name="client_id", referencedColumnName="id")}, |
58
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="identifier")} |
59
|
|
|
* ) |
60
|
|
|
*/ |
61
|
|
|
private $scopes; |
62
|
|
|
|
63
|
5 |
|
public function __construct() |
64
|
|
|
{ |
65
|
5 |
|
$this->scopes = new ArrayCollection(); |
66
|
5 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
1 |
|
public function getIdentifier() |
72
|
|
|
{ |
73
|
1 |
|
return $this->identifier; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $identifier |
78
|
|
|
*/ |
79
|
1 |
|
public function setIdentifier($identifier) |
80
|
|
|
{ |
81
|
1 |
|
$this->identifier = $identifier; |
82
|
1 |
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get the client's name. |
86
|
|
|
* |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
3 |
|
public function getName() |
90
|
|
|
{ |
91
|
3 |
|
return $this->name; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns the registered redirect URI (as a string). |
96
|
|
|
* |
97
|
|
|
* Alternatively return an indexed array of redirect URIs. |
98
|
|
|
* |
99
|
|
|
* @return string|string[] |
100
|
|
|
*/ |
101
|
1 |
|
public function getRedirectUri() |
102
|
|
|
{ |
103
|
1 |
|
return $this->redirectUri; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param string $name |
108
|
|
|
* @return Client |
109
|
|
|
*/ |
110
|
3 |
|
public function setName($name) |
111
|
|
|
{ |
112
|
3 |
|
$this->name = $name; |
113
|
3 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string|\string[] $redirectUri |
118
|
|
|
* @return Client |
119
|
|
|
*/ |
120
|
1 |
|
public function setRedirectUri($redirectUri) |
121
|
|
|
{ |
122
|
1 |
|
$this->redirectUri = $redirectUri; |
123
|
1 |
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return string |
128
|
|
|
*/ |
129
|
|
|
public function getSecret(): string |
130
|
|
|
{ |
131
|
|
|
return $this->secret; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @param string $secret |
136
|
|
|
* @return Client |
137
|
|
|
*/ |
138
|
|
|
public function setSecret(string $secret): Client |
139
|
|
|
{ |
140
|
|
|
$this->secret = $secret; |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return bool |
146
|
|
|
*/ |
147
|
|
|
public function isConfidential(): bool |
148
|
|
|
{ |
149
|
|
|
return $this->confidential; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param bool $confidential |
154
|
|
|
* @return Client |
155
|
|
|
*/ |
156
|
|
|
public function setConfidential(bool $confidential): Client |
157
|
|
|
{ |
158
|
|
|
$this->confidential = $confidential; |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return string |
164
|
|
|
*/ |
165
|
|
|
public function getId(): string |
166
|
|
|
{ |
167
|
|
|
return $this->id; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param string $id |
172
|
|
|
* @return Client |
173
|
|
|
*/ |
174
|
|
|
public function setId(string $id): Client |
175
|
|
|
{ |
176
|
|
|
$this->id = $id; |
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return ArrayCollection |
182
|
|
|
*/ |
183
|
|
|
public function getScopes(): ArrayCollection |
184
|
|
|
{ |
185
|
|
|
return $this->scopes; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param ArrayCollection $scopes |
190
|
|
|
* @return Client |
191
|
|
|
*/ |
192
|
|
|
public function setScopes(ArrayCollection $scopes): Client |
193
|
|
|
{ |
194
|
|
|
$this->scopes = $scopes; |
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
} |