Completed
Branch newinternal (6027bd)
by Simon
06:03
created

SecurityConfiguration   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 199
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 17
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 199
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A setCheckuser() 0 6 1
A requiresIdentifiedUser() 0 4 1
A getAdmin() 0 4 1
A setAdmin() 0 6 1
A getUser() 0 4 1
A setUser() 0 6 1
A getCheckuser() 0 4 1
A getCommunity() 0 4 1
A setCommunity() 0 6 1
A getSuspended() 0 4 1
A setSuspended() 0 6 1
A getDeclined() 0 4 1
A setDeclined() 0 6 1
A getNew() 0 4 1
A setNew() 0 6 1
A setRequireIdentified() 0 4 1
1
<?php
2
3
namespace Waca\Security;
4
5
/**
6
 * Class SecurityConfiguration
7
 * @package  Waca
8
 * @category Security-Critical
9
 */
10
final class SecurityConfiguration
11
{
12
	const ALLOW = "allow";
13
	const DENY = "deny";
14
	private $admin = "default";
15
	private $user = "default";
16
	private $checkuser = "default";
17
	private $community = "default";
18
	private $suspended = "default";
19
	private $declined = "default";
20
	private $new = "default";
21
	private $requireIdentified;
22
23
	/**
24
	 * SecurityConfiguration constructor.
25
	 */
26
	public function __construct()
27
	{
28
		global $forceIdentification;
29
30
		// Initialise require identified to the boolean value of $forceIdentification. Test for truthiness not true
31
		// because I think we set this to 1/0 instead of true/false.
32
		$this->requireIdentified = ($forceIdentification == 1);
33
	}
34
35
	/**
36
	 * Sets whether a checkuser is able to gain access.
37
	 *
38
	 * This is private because it's DANGEROUS. Checkusers are not mutually-exclusive with other rights. As such, a
39
	 * suspended checkuser who tries to access a page which allows checkusers will be granted access to the page, UNLESS
40
	 * that page is also set to DENY (note, not default) New/Declined/Suspended users. I have no problem with this
41
	 * method being used, but please ONLY use it in this class in static methods of Security. Nowhere else.
42
	 *
43
	 * @param string $checkuser
44
	 *
45
	 * @return SecurityConfiguration
46
	 * @category Security-Critical
47
	 */
48
	public function setCheckuser($checkuser)
49
	{
50
		$this->checkuser = $checkuser;
51
52
		return $this;
53
	}
54
55
56
57
	/**
58
	 * Returns if a user is required to be identified.
59
	 *
60
	 * @return boolean
61
	 */
62
	public function requiresIdentifiedUser()
63
	{
64
		return $this->requireIdentified;
65
	}
66
67
	/**
68
	 * @return string
69
	 */
70
	public function getAdmin()
71
	{
72
		return $this->admin;
73
	}
74
75
	/**
76
	 * @param string $admin
77
	 *
78
	 * @return SecurityConfiguration
79
	 * @category Security-Critical
80
	 */
81
	public function setAdmin($admin)
82
	{
83
		$this->admin = $admin;
84
85
		return $this;
86
	}
87
88
	/**
89
	 * @return string
90
	 */
91
	public function getUser()
92
	{
93
		return $this->user;
94
	}
95
96
	/**
97
	 * @param string $user
98
	 *
99
	 * @return SecurityConfiguration
100
	 * @category Security-Critical
101
	 */
102
	public function setUser($user)
103
	{
104
		$this->user = $user;
105
106
		return $this;
107
	}
108
109
	/**
110
	 * @return string
111
	 */
112
	public function getCheckuser()
113
	{
114
		return $this->checkuser;
115
	}
116
117
	/**
118
	 * @return string
119
	 */
120
	public function getCommunity()
121
	{
122
		return $this->community;
123
	}
124
125
	/**
126
	 * @param string $community
127
	 *
128
	 * @return SecurityConfiguration
129
	 * @category Security-Critical
130
	 */
131
	public function setCommunity($community)
132
	{
133
		$this->community = $community;
134
135
		return $this;
136
	}
137
138
	/**
139
	 * @return string
140
	 */
141
	public function getSuspended()
142
	{
143
		return $this->suspended;
144
	}
145
146
	/**
147
	 * @param string $suspended
148
	 *
149
	 * @return SecurityConfiguration
150
	 * @category Security-Critical
151
	 */
152
	public function setSuspended($suspended)
153
	{
154
		$this->suspended = $suspended;
155
156
		return $this;
157
	}
158
159
	/**
160
	 * @return string
161
	 */
162
	public function getDeclined()
163
	{
164
		return $this->declined;
165
	}
166
167
	/**
168
	 * @param string $declined
169
	 *
170
	 * @return SecurityConfiguration
171
	 * @category Security-Critical
172
	 */
173
	public function setDeclined($declined)
174
	{
175
		$this->declined = $declined;
176
177
		return $this;
178
	}
179
180
	/**
181
	 * @return string
182
	 */
183
	public function getNew()
184
	{
185
		return $this->new;
186
	}
187
188
	/**
189
	 * @param string $new
190
	 *
191
	 * @return SecurityConfiguration
192
	 * @category Security-Critical
193
	 */
194
	public function setNew($new)
195
	{
196
		$this->new = $new;
197
198
		return $this;
199
	}
200
201
	/**
202
	 * @param boolean $requireIdentified
203
	 */
204
	public function setRequireIdentified($requireIdentified)
205
	{
206
		$this->requireIdentified = $requireIdentified;
207
	}
208
}