|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\Security\Acl\Domain; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\Security\Acl\Model\AclInterface; |
|
|
15 |
use Symfony\Component\Security\Acl\Model\AuditableEntryInterface; |
|
|
16 |
use Symfony\Component\Security\Acl\Model\EntryInterface; |
|
|
17 |
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface; |
|
|
18 |
|
|
|
19 |
/** |
|
|
20 |
* Auditable ACE implementation |
|
|
21 |
* |
|
|
22 |
* @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
|
23 |
*/ |
|
|
24 |
class Entry implements AuditableEntryInterface |
|
|
25 |
{ |
|
|
26 |
private $acl; |
|
|
27 |
private $mask; |
|
|
28 |
private $id; |
|
|
29 |
private $securityIdentity; |
|
|
30 |
private $strategy; |
|
|
31 |
private $auditFailure; |
|
|
32 |
private $auditSuccess; |
|
|
33 |
private $granting; |
|
|
34 |
|
|
|
35 |
/** |
|
|
36 |
* Constructor |
|
|
37 |
* |
|
|
38 |
* @param integer $id |
|
|
39 |
* @param AclInterface $acl |
|
|
40 |
* @param SecurityIdentityInterface $sid |
|
|
41 |
* @param string $strategy |
|
|
42 |
* @param integer $mask |
|
|
43 |
* @param Boolean $granting |
|
|
44 |
* @param Boolean $auditFailure |
|
|
45 |
* @param Boolean $auditSuccess |
|
|
46 |
*/ |
|
|
47 |
public function __construct($id, AclInterface $acl, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess) |
|
|
48 |
{ |
|
|
49 |
$this->id = $id; |
|
|
50 |
$this->acl = $acl; |
|
|
51 |
$this->securityIdentity = $sid; |
|
|
52 |
$this->strategy = $strategy; |
|
|
53 |
$this->mask = $mask; |
|
|
54 |
$this->granting = $granting; |
|
|
55 |
$this->auditFailure = $auditFailure; |
|
|
56 |
$this->auditSuccess = $auditSuccess; |
|
|
57 |
} |
|
|
58 |
|
|
|
59 |
/** |
|
|
60 |
* {@inheritDoc} |
|
|
61 |
*/ |
|
|
62 |
public function getAcl() |
|
|
63 |
{ |
|
|
64 |
return $this->acl; |
|
|
65 |
} |
|
|
66 |
|
|
|
67 |
/** |
|
|
68 |
* {@inheritDoc} |
|
|
69 |
*/ |
|
|
70 |
public function getMask() |
|
|
71 |
{ |
|
|
72 |
return $this->mask; |
|
|
73 |
} |
|
|
74 |
|
|
|
75 |
/** |
|
|
76 |
* {@inheritDoc} |
|
|
77 |
*/ |
|
|
78 |
public function getId() |
|
|
79 |
{ |
|
|
80 |
return $this->id; |
|
|
81 |
} |
|
|
82 |
|
|
|
83 |
/** |
|
|
84 |
* {@inheritDoc} |
|
|
85 |
*/ |
|
|
86 |
public function getSecurityIdentity() |
|
|
87 |
{ |
|
|
88 |
return $this->securityIdentity; |
|
|
89 |
} |
|
|
90 |
|
|
|
91 |
/** |
|
|
92 |
* {@inheritDoc} |
|
|
93 |
*/ |
|
|
94 |
public function getStrategy() |
|
|
95 |
{ |
|
|
96 |
return $this->strategy; |
|
|
97 |
} |
|
|
98 |
|
|
|
99 |
/** |
|
|
100 |
* {@inheritDoc} |
|
|
101 |
*/ |
|
|
102 |
public function isAuditFailure() |
|
|
103 |
{ |
|
|
104 |
return $this->auditFailure; |
|
|
105 |
} |
|
|
106 |
|
|
|
107 |
/** |
|
|
108 |
* {@inheritDoc} |
|
|
109 |
*/ |
|
|
110 |
public function isAuditSuccess() |
|
|
111 |
{ |
|
|
112 |
return $this->auditSuccess; |
|
|
113 |
} |
|
|
114 |
|
|
|
115 |
/** |
|
|
116 |
* {@inheritDoc} |
|
|
117 |
*/ |
|
|
118 |
public function isGranting() |
|
|
119 |
{ |
|
|
120 |
return $this->granting; |
|
|
121 |
} |
|
|
122 |
|
|
|
123 |
/** |
|
|
124 |
* Turns on/off auditing on permissions denials. |
|
|
125 |
* |
|
|
126 |
* Do never call this method directly. Use the respective methods on the |
|
|
127 |
* AclInterface instead. |
|
|
128 |
* |
|
|
129 |
* @param Boolean $boolean |
|
|
130 |
* @return void |
|
|
131 |
*/ |
|
|
132 |
public function setAuditFailure($boolean) |
|
|
133 |
{ |
|
|
134 |
$this->auditFailure = $boolean; |
|
|
135 |
} |
|
|
136 |
|
|
|
137 |
/** |
|
|
138 |
* Turns on/off auditing on permission grants. |
|
|
139 |
* |
|
|
140 |
* Do never call this method directly. Use the respective methods on the |
|
|
141 |
* AclInterface instead. |
|
|
142 |
* |
|
|
143 |
* @param Boolean $boolean |
|
|
144 |
* @return void |
|
|
145 |
*/ |
|
|
146 |
public function setAuditSuccess($boolean) |
|
|
147 |
{ |
|
|
148 |
$this->auditSuccess = $boolean; |
|
|
149 |
} |
|
|
150 |
|
|
|
151 |
/** |
|
|
152 |
* Sets the permission mask |
|
|
153 |
* |
|
|
154 |
* Do never call this method directly. Use the respective methods on the |
|
|
155 |
* AclInterface instead. |
|
|
156 |
* |
|
|
157 |
* @param integer $mask |
|
|
158 |
* @return void |
|
|
159 |
*/ |
|
|
160 |
public function setMask($mask) |
|
|
161 |
{ |
|
|
162 |
$this->mask = $mask; |
|
|
163 |
} |
|
|
164 |
|
|
|
165 |
/** |
|
|
166 |
* Sets the mask comparison strategy |
|
|
167 |
* |
|
|
168 |
* Do never call this method directly. Use the respective methods on the |
|
|
169 |
* AclInterface instead. |
|
|
170 |
* |
|
|
171 |
* @param string $strategy |
|
|
172 |
* @return void |
|
|
173 |
*/ |
|
|
174 |
public function setStrategy($strategy) |
|
|
175 |
{ |
|
|
176 |
$this->strategy = $strategy; |
|
|
177 |
} |
|
|
178 |
|
|
|
179 |
/** |
|
|
180 |
* Implementation of \Serializable |
|
|
181 |
* |
|
|
182 |
* @return string |
|
|
183 |
*/ |
|
|
184 |
public function serialize() |
|
|
185 |
{ |
|
|
186 |
return serialize(array( |
|
|
187 |
$this->mask, |
|
|
188 |
$this->id, |
|
|
189 |
$this->securityIdentity, |
|
|
190 |
$this->strategy, |
|
|
191 |
$this->auditFailure, |
|
|
192 |
$this->auditSuccess, |
|
|
193 |
$this->granting, |
|
|
194 |
)); |
|
|
195 |
} |
|
|
196 |
|
|
|
197 |
/** |
|
|
198 |
* Implementation of \Serializable |
|
|
199 |
* |
|
|
200 |
* @param string $serialized |
|
|
201 |
* @return void |
|
|
202 |
*/ |
|
|
203 |
public function unserialize($serialized) |
|
|
204 |
{ |
|
|
205 |
list($this->mask, |
|
|
206 |
$this->id, |
|
|
207 |
$this->securityIdentity, |
|
|
208 |
$this->strategy, |
|
|
209 |
$this->auditFailure, |
|
|
210 |
$this->auditSuccess, |
|
|
211 |
$this->granting |
|
|
212 |
) = unserialize($serialized); |
|
|
213 |
} |
|
|
214 |
} |