/
IpAccessControlCategory.php
398 lines (352 loc) · 9.57 KB
/
IpAccessControlCategory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
namespace Concrete\Core\Entity\Permission;
use Concrete\Core\Entity\Package;
use Concrete\Core\Logging\Channels;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Represent an IP Access Control Category.
*
* @ORM\Entity()
* @ORM\Table(
* name="IpAccessControlCategories",
* options={
* "comment": "List of IP Access Control Categories"
* }
* )
*/
class IpAccessControlCategory
{
/**
* The IP Access Control Category identifier.
*
* @ORM\Column(name="iaccID", type="integer", nullable=false, options={"unsigned":true , "comment": "The IP Access Control Category identifier"})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int|null NULL when the record has not been saved yet
*/
protected $ipAccessControlCategoryID;
/**
* The IP Access Control Category handle.
*
* @ORM\Column(name="iaccHandle", type="string", length=255, nullable=false, unique=true, options={"comment": "The IP Access Control handle"})
*
* @var string
*/
protected $handle;
/**
* The IP Access Control Category name.
*
* @ORM\Column(name="iaccName", type="string", length=255, nullable=false, options={"comment": "The IP Access Control name"})
*
* @var string
*/
protected $name;
/**
* The package that defines this IP Access Control Category.
*
* @ORM\ManyToOne(targetEntity="Concrete\Core\Entity\Package")
* @ORM\JoinColumn(name="iaccPackage", referencedColumnName="pkgID", nullable=true, onDelete="CASCADE")
*
* @var \Concrete\Core\Entity\Package|null
*/
protected $package;
/**
* Is this IP Access Control Category enabled?
*
* @ORM\Column(name="iaccEnabled", type="boolean", nullable=false, options={"comment": "Is this IP Access Control enabled?"})
*
* @var bool
*/
protected $enabled;
/**
* The maximum allowed events in the time window.
*
* @ORM\Column(name="iaccMaxEvents", type="integer", nullable=false, options={"unsigned": true, "comment": "The maximum allowed events in the time window"})
*
* @var int
*/
protected $maxEvents;
/**
* The time window (in seconds) where the events should be counted (NULL means no limits).
*
* @ORM\Column(name="iaccTimeWindow", type="integer", nullable=true, options={"unsigned": true, "comment": "The time window (in seconds) where the events should be counted (NULL means no limits)"})
*
* @var int|null
*/
protected $timeWindow;
/**
* The duration (in seconds) of the ban when the maximum number of events occur in the time window (NULL means forever).
*
* @ORM\Column(name="iaccBanDuration", type="integer", nullable=true, options={"unsigned": true, "comment": "The duration (in seconds) of the ban when the maximum number of events occur in the time window (NULL means forever)"})
*
* @var int|null
*/
protected $banDuration;
/**
* Is this IP Access Control Category site-specific?
*
* @ORM\Column(name="iaccSiteSpecific", type="boolean", nullable=false, options={"comment": "Is this IP Access Control Category site-specific?"})
*
* @var bool
*/
protected $siteSpecific;
/**
* The log channel handle.
*
* @ORM\Column(name="iaccLogChannel", type="string", length=255, nullable=false, options={"comment": "The log channel handle"})
*
* @var string
*/
protected $logChannelHandle = Channels::CHANNEL_SECURITY;
/**
* The list of recorded events associated to this category.
*
* @ORM\OneToMany(targetEntity="Concrete\Core\Entity\Permission\IpAccessControlEvent", mappedBy="category")
*
* @var \Doctrine\Common\Collections\ArrayCollection|\Concrete\Core\Entity\Permission\IpAccessControlEvent[]
*/
protected $events;
/**
* The list of defined ranges associated to this category.
*
* @ORM\OneToMany(targetEntity="Concrete\Core\Entity\Permission\IpAccessControlRange", mappedBy="category")
*
* @var \Doctrine\Common\Collections\ArrayCollection|\Concrete\Core\Entity\Permission\IpAccessControlRange[]
*/
protected $ranges;
/**
* Initialize the instance.
*/
public function __construct()
{
$this->events = new ArrayCollection();
$this->ranges = new ArrayCollection();
}
/**
* Get the IP Access Control Category identifier.
*
* @return int|null returns NULL when the record has not been saved yet
*/
public function getIpAccessControlCategoryID()
{
return $this->ipAccessControlCategoryID;
}
/**
* Get the IP Access Control handle.
*
* @return string
*/
public function getHandle()
{
return $this->handle;
}
/**
* Set the IP Access Control handle.
*
* @param string $value
*
* @return $this
*/
public function setHandle($value)
{
$this->handle = (string) $value;
return $this;
}
/**
* Get the IP Access Control name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get the IP Access Control display name.
*
* @return string
*/
public function getDisplayName()
{
return tc('IpAccessControlCategory', $this->name);
}
/**
* Set the IP Access Control name.
*
* @param string $value
*
* @return $this
*/
public function setName($value)
{
$this->name = (string) $value;
return $this;
}
/**
* Get the package that defines this IP Access Control Category.
*
* @return \Concrete\Core\Entity\Package|null
*/
public function getPackage()
{
return $this->package;
}
/**
* Set the package that defines this IP Access Control Category.
*
* @param \Concrete\Core\Entity\Package|null $value
*
* @return $this
*/
public function setPackage(Package $value = null)
{
$this->package = $value;
return $this;
}
/**
* Is this IP Access Control Category enabled?
*
* @return bool
*/
public function isEnabled()
{
return $this->enabled;
}
/**
* Is this IP Access Control Category enabled?
*
* @param bool $value
*
* @return $this
*/
public function setEnabled($value)
{
$this->enabled = (bool) $value;
return $this;
}
/**
* Get the maximum allowed events in the time window.
*
* @return int
*/
public function getMaxEvents()
{
return $this->maxEvents;
}
/**
* Set the maximum allowed events in the time window.
*
* @param int $value
*
* @return $this
*/
public function setMaxEvents($value)
{
$this->maxEvents = (int) $value;
return $this;
}
/**
* Get the time window (in seconds) where the events should be counted (NULL means no limits).
*
* @return int|null
*/
public function getTimeWindow()
{
return $this->timeWindow;
}
/**
* Get the time window (in seconds) where the events should be counted (NULL means no limits).
*
* @param int|null $value
*
* @return $this
*/
public function setTimeWindow($value)
{
$this->timeWindow = ((string) $value === '') ? null : (int) $value;
return $this;
}
/**
* Get the duration (in seconds) of the ban when the maximum number of events occur in the time window (NULL means forever).
*
* @return int|null
*/
public function getBanDuration()
{
return $this->banDuration;
}
/**
* Set the duration (in seconds) of the ban when the maximum number of events occur in the time window (NULL means forever).
*
* @param int|null $value
*
* @return $this
*/
public function setBanDuration($value)
{
$this->banDuration = ((string) $value === '') ? null : (int) $value;
return $this;
}
/**
* Is this IP Access Control Category site-specific?
*
* @return bool
*/
public function isSiteSpecific()
{
return $this->siteSpecific;
}
/**
* Is this IP Access Control Category site-specific?
*
* @param bool $value
*
* @return $this
*/
public function setSiteSpecific($value)
{
$this->siteSpecific = (bool) $value;
return $this;
}
/**
* Get the log channel handle (empty string if log is disabled).
*
* @return string
*/
public function getLogChannelHandle()
{
return $this->logChannelHandle;
}
/**
* Set the log channel handle (empty string if log is disabled).
*
* @param string $value
*
* @return $this
*/
public function setLogChannelHandle($value)
{
$this->logChannelHandle = (string) $value;
return $this;
}
/**
* Get the list of recorded events associated to this category.
*
* @return \Doctrine\Common\Collections\ArrayCollection|\Concrete\Core\Entity\Permission\IpAccessControlEvent[]
*/
public function getEvents()
{
return $this->events;
}
/**
* Get the list of defined ranges associated to this category.
*
* @return \Doctrine\Common\Collections\ArrayCollection|\Concrete\Core\Entity\Permission\IpAccessControlRange[]
*/
public function getRanges()
{
return $this->ranges;
}
}