|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @copyright 2018 Christoph Wurst <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @author 2018 Christoph Wurst <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license GNU AGPL version 3 or any later version |
|
11
|
|
|
* |
|
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
15
|
|
|
* License, or (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace OC\Authentication\TwoFactorAuth; |
|
27
|
|
|
|
|
28
|
|
|
use JsonSerializable; |
|
29
|
|
|
|
|
30
|
|
|
class EnforcementState implements JsonSerializable { |
|
31
|
|
|
|
|
32
|
|
|
/** @var bool */ |
|
33
|
|
|
private $enforced; |
|
34
|
|
|
|
|
35
|
|
|
/** @var array */ |
|
36
|
|
|
private $enforcedGroups; |
|
37
|
|
|
|
|
38
|
|
|
/** @var array */ |
|
39
|
|
|
private $excludedGroups; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* EnforcementState constructor. |
|
43
|
|
|
* |
|
44
|
|
|
* @param bool $enforced |
|
45
|
|
|
* @param string[] $enforcedGroups |
|
46
|
|
|
* @param string[] $excludedGroups |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct(bool $enforced, |
|
49
|
|
|
array $enforcedGroups = [], |
|
50
|
|
|
array $excludedGroups = []) { |
|
51
|
|
|
$this->enforced = $enforced; |
|
52
|
|
|
$this->enforcedGroups = $enforcedGroups; |
|
53
|
|
|
$this->excludedGroups = $excludedGroups; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return string[] |
|
58
|
|
|
*/ |
|
59
|
|
|
public function isEnforced(): bool { |
|
60
|
|
|
return $this->enforced; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return string[] |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getEnforcedGroups(): array { |
|
67
|
|
|
return $this->enforcedGroups; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return string[] |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getExcludedGroups(): array { |
|
74
|
|
|
return $this->excludedGroups; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function jsonSerialize(): array { |
|
78
|
|
|
return [ |
|
79
|
|
|
'enforced' => $this->enforced, |
|
80
|
|
|
'enforcedGroups' => $this->enforcedGroups, |
|
81
|
|
|
'excludedGroups' => $this->excludedGroups, |
|
82
|
|
|
]; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|