1 | <?php |
||
16 | class User implements ReferenceUserInterface, EquatableInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var \eZ\Publish\API\Repository\Values\User\User |
||
20 | */ |
||
21 | private $user; |
||
22 | |||
23 | /** |
||
24 | * @var \eZ\Publish\API\Repository\Values\User\UserReference |
||
25 | */ |
||
26 | private $reference; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | private $roles; |
||
32 | |||
33 | public function __construct(APIUser $user = null, array $roles = array()) |
||
39 | |||
40 | /** |
||
41 | * Returns the roles granted to the user. |
||
42 | * |
||
43 | * <code> |
||
44 | * public function getRoles() |
||
45 | * { |
||
46 | * return array( 'ROLE_USER' ); |
||
47 | * } |
||
48 | * </code> |
||
49 | * |
||
50 | * Alternatively, the roles might be stored on a ``roles`` property, |
||
51 | * and populated in any number of different ways when the user object |
||
52 | * is created. |
||
53 | * |
||
54 | * @return Role[] The user roles |
||
55 | */ |
||
56 | public function getRoles() |
||
60 | |||
61 | /** |
||
62 | * Returns the password used to authenticate the user. |
||
63 | * |
||
64 | * This should be the encoded password. On authentication, a plain-text |
||
65 | * password will be salted, encoded, and then compared to this value. |
||
66 | * |
||
67 | * @return string The password |
||
68 | */ |
||
69 | public function getPassword() |
||
73 | |||
74 | /** |
||
75 | * Returns the salt that was originally used to encode the password. |
||
76 | * |
||
77 | * This can return null if the password was not encoded using a salt. |
||
78 | * |
||
79 | * @return string The salt |
||
80 | */ |
||
81 | public function getSalt() |
||
85 | |||
86 | /** |
||
87 | * Returns the username used to authenticate the user. |
||
88 | * |
||
89 | * @return string The username |
||
90 | */ |
||
91 | public function getUsername() |
||
95 | |||
96 | /** |
||
97 | * Removes sensitive data from the user. |
||
98 | * |
||
99 | * This is important if, at any given point, sensitive information like |
||
100 | * the plain-text password is stored on this object. |
||
101 | */ |
||
102 | public function eraseCredentials() |
||
105 | |||
106 | /** |
||
107 | * @return \eZ\Publish\API\Repository\Values\User\UserReference |
||
108 | */ |
||
109 | public function getAPIUserReference() |
||
113 | |||
114 | /** |
||
115 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
116 | */ |
||
117 | public function getAPIUser() |
||
127 | |||
128 | /** |
||
129 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
130 | */ |
||
131 | public function setAPIUser(APIUser $user) |
||
136 | |||
137 | public function isEqualTo(BaseUserInterface $user) |
||
148 | |||
149 | public function __toString() |
||
153 | |||
154 | /** |
||
155 | * Checks whether the user's account has expired. |
||
156 | * |
||
157 | * Internally, if this method returns false, the authentication system |
||
158 | * will throw an AccountExpiredException and prevent login. |
||
159 | * |
||
160 | * @return bool true if the user's account is non expired, false otherwise |
||
161 | * |
||
162 | * @see AccountExpiredException |
||
163 | */ |
||
164 | public function isAccountNonExpired() |
||
168 | |||
169 | /** |
||
170 | * Checks whether the user is locked. |
||
171 | * |
||
172 | * Internally, if this method returns false, the authentication system |
||
173 | * will throw a LockedException and prevent login. |
||
174 | * |
||
175 | * @return bool true if the user is not locked, false otherwise |
||
176 | * |
||
177 | * @see LockedException |
||
178 | */ |
||
179 | public function isAccountNonLocked() |
||
183 | |||
184 | /** |
||
185 | * Checks whether the user's credentials (password) has expired. |
||
186 | * |
||
187 | * Internally, if this method returns false, the authentication system |
||
188 | * will throw a CredentialsExpiredException and prevent login. |
||
189 | * |
||
190 | * @return bool true if the user's credentials are non expired, false otherwise |
||
191 | * |
||
192 | * @see CredentialsExpiredException |
||
193 | */ |
||
194 | public function isCredentialsNonExpired() |
||
198 | |||
199 | /** |
||
200 | * Checks whether the user is enabled. |
||
201 | * |
||
202 | * Internally, if this method returns false, the authentication system |
||
203 | * will throw a DisabledException and prevent login. |
||
204 | * |
||
205 | * @return bool true if the user is enabled, false otherwise |
||
206 | * |
||
207 | * @see DisabledException |
||
208 | */ |
||
209 | public function isEnabled() |
||
213 | |||
214 | /** |
||
215 | * Make sure we don't serialize the whole API user object given it's a full fledged api content object. We set |
||
216 | * (& either way refresh) the user object in \eZ\Publish\Core\MVC\Symfony\Security\User\Provider->refreshUser() |
||
217 | * when object wakes back up from session. |
||
218 | * |
||
219 | * @return array |
||
220 | */ |
||
221 | public function __sleep() |
||
225 | } |
||
226 |