1 | <?php |
||
73 | class Subject implements \Serializable |
||
74 | { |
||
75 | |||
76 | /** |
||
77 | * Whether this subject is read-only or not. |
||
78 | * |
||
79 | * @var boolean |
||
80 | */ |
||
81 | protected $readOnly = false; |
||
82 | |||
83 | /** |
||
84 | * A map that provides a view of all of this subject's principals. |
||
85 | * |
||
86 | * @var \AppserverIo\Collections\CollectionInterface |
||
87 | */ |
||
88 | protected $principals; |
||
89 | |||
90 | /** |
||
91 | * A map that provide a view of private credentials of this subject's credentials. |
||
92 | * |
||
93 | * @var \AppserverIo\Collections\CollectionInterface |
||
94 | */ |
||
95 | protected $privateCredentials; |
||
96 | |||
97 | /** |
||
98 | * A map that provide a view of public credentials of this subject's credentials. |
||
99 | * |
||
100 | * @var \AppserverIo\Collections\CollectionInterface |
||
101 | */ |
||
102 | protected $publicCredentials; |
||
103 | |||
104 | /** |
||
105 | * Initialize the subject with the passed data. |
||
106 | * |
||
107 | * @param \AppserverIo\Collections\CollectionInterface $principals A map with subject's principals |
||
108 | * @param \AppserverIo\Collections\CollectionInterface $publicCredentials A map with the public credentials |
||
109 | * @param \AppserverIo\Collections\CollectionInterface $privateCredentials A map with the private credentials |
||
110 | * @param boolean $readOnly Whether this subject is read-only or not |
||
111 | */ |
||
112 | 16 | public function __construct( |
|
143 | |||
144 | /** |
||
145 | * Set this subject to be read-only. |
||
146 | * |
||
147 | * Modifications (additions and removals) to this subject's |
||
148 | * principals and credentials will be disallowed. |
||
149 | * |
||
150 | * The destroy operation on this subject's credentials will |
||
151 | * still be permitted. |
||
152 | * |
||
153 | * Subsequent attempts to modify the subject's principals and |
||
154 | * credentials will result in an >IllegalStateException being |
||
155 | * thrown. Also, once a subject is read-only, it can not be |
||
156 | * reset to being writable again. |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | 1 | public function setReadOnly() |
|
164 | |||
165 | /** |
||
166 | * Query whether this subject is read-only. |
||
167 | * |
||
168 | * @return boolean TRUE if this subject is read-only, FALSE otherwise |
||
169 | */ |
||
170 | 4 | public function isReadOnly() |
|
174 | |||
175 | /** |
||
176 | * Return's the subject's principals. |
||
177 | * |
||
178 | * @return \AppserverIo\Collections\CollectionInterface The principals |
||
179 | */ |
||
180 | 3 | public function getPrincipals() |
|
184 | |||
185 | /** |
||
186 | * Return's the subject's public credentials. |
||
187 | * |
||
188 | * @return \AppserverIo\Collections\CollectionInterface The public credentials |
||
189 | */ |
||
190 | 3 | public function getPublicCredentials() |
|
194 | |||
195 | /** |
||
196 | * Return's the subject's private credentials. |
||
197 | * |
||
198 | * @return \AppserverIo\Collections\CollectionInterface The private credentials |
||
199 | */ |
||
200 | 3 | public function getPrivateCredentials() |
|
204 | |||
205 | /** |
||
206 | * Return's a string representation of the subject and the principals. |
||
207 | * |
||
208 | * @return string|null The subject as string representation |
||
209 | * @see \Serializable::serialize() |
||
210 | */ |
||
211 | 1 | public function serialize() |
|
222 | |||
223 | /** |
||
224 | * Called during unserialization of the object. |
||
225 | * |
||
226 | * @param string $data The subject as string representation |
||
227 | * |
||
228 | * @return void |
||
229 | * @see \Serializable::unserialize() |
||
230 | */ |
||
231 | 1 | public function unserialize($data) |
|
245 | } |
||
246 |