1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AtlassianConnectBundle\Entity; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
|
9
|
|
|
trait TenantTrait |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var int |
13
|
|
|
* |
14
|
|
|
* @ORM\Column(name="id", type="integer") |
15
|
|
|
* @ORM\Id() |
16
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
17
|
|
|
*/ |
18
|
|
|
private $id; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
* |
23
|
|
|
* @ORM\Column(name="addon_key", type="string", length=255) |
24
|
|
|
*/ |
25
|
|
|
private $addonKey; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(name="client_key", type="string", length=255, unique=true) |
31
|
|
|
*/ |
32
|
|
|
private $clientKey; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string|null |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(name="oauth_client_id", type="string", length=255, nullable=true) |
38
|
|
|
*/ |
39
|
|
|
private $oauthClientId; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
private $username; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
* |
49
|
|
|
* @ORM\Column(name="public_key", type="string", length=255) |
50
|
|
|
*/ |
51
|
|
|
private $publicKey; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
* |
56
|
|
|
* @ORM\Column(name="shared_secret", type="string", length=255) |
57
|
|
|
*/ |
58
|
|
|
private $sharedSecret; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var string |
62
|
|
|
* |
63
|
|
|
* @ORM\Column(name="server_version", type="string", length=255) |
64
|
|
|
*/ |
65
|
|
|
private $serverVersion; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var string |
69
|
|
|
* |
70
|
|
|
* @ORM\Column(name="plugins_version", type="string", length=255) |
71
|
|
|
*/ |
72
|
|
|
private $pluginsVersion; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var string |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="base_url", type="string", length=255) |
78
|
|
|
*/ |
79
|
|
|
private $baseUrl; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var string |
83
|
|
|
* |
84
|
|
|
* @ORM\Column(name="product_type", type="string", length=255) |
85
|
|
|
*/ |
86
|
|
|
private $productType; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @var string |
90
|
|
|
* |
91
|
|
|
* @ORM\Column(name="description", type="string", length=255) |
92
|
|
|
*/ |
93
|
|
|
private $description; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @var string |
97
|
|
|
* |
98
|
|
|
* @ORM\Column(name="event_type", type="string", length=255) |
99
|
|
|
*/ |
100
|
|
|
private $eventType; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var \DateTime |
104
|
|
|
* |
105
|
|
|
* @ORM\Column(name="created_at", type="datetime", nullable=false) |
106
|
|
|
*/ |
107
|
|
|
private $createdAt; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var \DateTime |
111
|
|
|
* |
112
|
|
|
* @ORM\Column(name="updated_at", type="datetime", nullable=false) |
113
|
|
|
*/ |
114
|
|
|
private $updatedAt; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @var bool |
118
|
|
|
* |
119
|
|
|
* @ORM\Column(name="is_white_listed", type="boolean", options={"default":0}) |
120
|
|
|
*/ |
121
|
|
|
private $isWhiteListed = false; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @var \DateTime |
125
|
|
|
* |
126
|
|
|
* @ORM\Column(name="white_listed_until", type="datetime", nullable=true) |
127
|
|
|
*/ |
128
|
|
|
private $whiteListedUntil; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @ORM\PrePersist() |
132
|
|
|
*/ |
133
|
|
|
public function setCreatedAt(): void |
134
|
|
|
{ |
135
|
|
|
$this->createdAt = new \DateTime(); |
136
|
|
|
$this->updatedAt = new \DateTime(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function getCreatedAt(): \DateTime |
140
|
|
|
{ |
141
|
|
|
return $this->createdAt; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @ORM\PreUpdate() |
146
|
|
|
*/ |
147
|
|
|
public function setUpdatedAt(): void |
148
|
|
|
{ |
149
|
|
|
$this->updatedAt = new \DateTime(); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function getUpdatedAt(): \DateTime |
153
|
|
|
{ |
154
|
|
|
return $this->updatedAt; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getId(): ?int |
158
|
|
|
{ |
159
|
|
|
return $this->id; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function setAddonKey(string $addonKey): TenantInterface |
163
|
|
|
{ |
164
|
|
|
$this->addonKey = $addonKey; |
165
|
|
|
|
166
|
|
|
return $this; |
|
|
|
|
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function getAddonKey(): ?string |
170
|
|
|
{ |
171
|
|
|
return $this->addonKey; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
public function setClientKey(string $clientKey): TenantInterface |
175
|
|
|
{ |
176
|
|
|
$this->clientKey = $clientKey; |
177
|
|
|
|
178
|
|
|
return $this; |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function getClientKey(): ?string |
182
|
|
|
{ |
183
|
|
|
return $this->clientKey; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function setPublicKey(string $publicKey): TenantInterface |
187
|
|
|
{ |
188
|
|
|
$this->publicKey = $publicKey; |
189
|
|
|
|
190
|
|
|
return $this; |
|
|
|
|
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function getPublicKey(): ?string |
194
|
|
|
{ |
195
|
|
|
return $this->publicKey; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
public function setSharedSecret(string $sharedSecret): TenantInterface |
199
|
|
|
{ |
200
|
|
|
$this->sharedSecret = $sharedSecret; |
201
|
|
|
|
202
|
|
|
return $this; |
|
|
|
|
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
public function getSharedSecret(): ?string |
206
|
|
|
{ |
207
|
|
|
return $this->sharedSecret; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
public function setServerVersion(string $serverVersion): TenantInterface |
211
|
|
|
{ |
212
|
|
|
$this->serverVersion = $serverVersion; |
213
|
|
|
|
214
|
|
|
return $this; |
|
|
|
|
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function getServerVersion(): ?string |
218
|
|
|
{ |
219
|
|
|
return $this->serverVersion; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
public function setPluginsVersion(string $pluginsVersion): TenantInterface |
223
|
|
|
{ |
224
|
|
|
$this->pluginsVersion = $pluginsVersion; |
225
|
|
|
|
226
|
|
|
return $this; |
|
|
|
|
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
public function getPluginsVersion(): ?string |
230
|
|
|
{ |
231
|
|
|
return $this->pluginsVersion; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
public function setBaseUrl(string $baseUrl): TenantInterface |
235
|
|
|
{ |
236
|
|
|
$this->baseUrl = $baseUrl; |
237
|
|
|
|
238
|
|
|
return $this; |
|
|
|
|
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
public function getBaseUrl(): ?string |
242
|
|
|
{ |
243
|
|
|
return $this->baseUrl; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
public function setProductType(string $productType): TenantInterface |
247
|
|
|
{ |
248
|
|
|
$this->productType = $productType; |
249
|
|
|
|
250
|
|
|
return $this; |
|
|
|
|
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function getProductType(): ?string |
254
|
|
|
{ |
255
|
|
|
return $this->productType; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
public function setDescription(string $description): TenantInterface |
259
|
|
|
{ |
260
|
|
|
$this->description = $description; |
261
|
|
|
|
262
|
|
|
return $this; |
|
|
|
|
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
public function getDescription(): ?string |
266
|
|
|
{ |
267
|
|
|
return $this->description; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
public function setEventType(string $eventType): TenantInterface |
271
|
|
|
{ |
272
|
|
|
$this->eventType = $eventType; |
273
|
|
|
|
274
|
|
|
return $this; |
|
|
|
|
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function getEventType(): ?string |
278
|
|
|
{ |
279
|
|
|
return $this->eventType; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @return array<string> |
284
|
|
|
*/ |
285
|
|
|
public function getRoles(): array |
286
|
|
|
{ |
287
|
|
|
return ['ROLE_USER']; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
public function getPassword(): string |
291
|
|
|
{ |
292
|
|
|
return ''; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
public function getSalt(): string |
296
|
|
|
{ |
297
|
|
|
return ''; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
public function getUsername(): string |
301
|
|
|
{ |
302
|
|
|
return $this->getUserIdentifier(); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
public function getUserIdentifier(): string |
306
|
|
|
{ |
307
|
|
|
return $this->username; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
public function setUsername(string $name): TenantInterface |
311
|
|
|
{ |
312
|
|
|
$this->username = $name; |
313
|
|
|
|
314
|
|
|
return $this; |
|
|
|
|
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
public function eraseCredentials(): void |
318
|
|
|
{ |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
public function getIsWhiteListed(): bool |
322
|
|
|
{ |
323
|
|
|
return $this->isWhiteListed; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
public function setIsWhiteListed(bool $isWhiteListed): self |
327
|
|
|
{ |
328
|
|
|
$this->isWhiteListed = $isWhiteListed; |
329
|
|
|
|
330
|
|
|
return $this; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
public function getWhiteListedUntil(): ?\DateTime |
334
|
|
|
{ |
335
|
|
|
return $this->whiteListedUntil; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
public function setWhiteListedUntil(\DateTime $whiteListedUntil): self |
339
|
|
|
{ |
340
|
|
|
$this->whiteListedUntil = $whiteListedUntil; |
341
|
|
|
|
342
|
|
|
return $this; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
public function isWhiteListed(): bool |
346
|
|
|
{ |
347
|
|
|
$now = new \DateTime(); |
348
|
|
|
|
349
|
|
|
return $this->getIsWhiteListed() && (null === $this->getWhiteListedUntil() || ($now < $this->getWhiteListedUntil())); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
public function setOauthClientId(?string $oauthClientId): TenantInterface |
353
|
|
|
{ |
354
|
|
|
$this->oauthClientId = $oauthClientId; |
355
|
|
|
|
356
|
|
|
return $this; |
|
|
|
|
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
public function getOauthClientId(): ?string |
360
|
|
|
{ |
361
|
|
|
return $this->oauthClientId; |
362
|
|
|
} |
363
|
|
|
} |
364
|
|
|
|