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
12namespace Symfony\Component\Security\Core\User;
13
14use Symfony\Component\Security\Core\Role\Role;
15
16/**
17 * Represents the interface that all user classes must implement.
18 *
19 * This interface is useful because the authentication layer can deal with
20 * the object through its lifecycle, using the object to get the encoded
21 * password (for checking against a submitted password), assigning roles
22 * and so on.
23 *
24 * Regardless of how your user are loaded or where they come from (a database,
25 * configuration, web service, etc), you will have a class that implements
26 * this interface. Objects that implement this interface are created and
27 * loaded by different objects that implement UserProviderInterface
28 *
29 * @see UserProviderInterface
30 * @see AdvancedUserInterface
31 *
32 * @author Fabien Potencier <fabien@symfony.com>
33 */
34interface UserInterface
35{
36    /**
37     * Returns the roles granted to the user.
38     *
39     * <code>
40     * public function getRoles()
41     * {
42     *     return array('ROLE_USER');
43     * }
44     * </code>
45     *
46     * Alternatively, the roles might be stored on a ``roles`` property,
47     * and populated in any number of different ways when the user object
48     * is created.
49     *
50     * @return Role[] The user roles
51     */
52    public function getRoles();
53
54    /**
55     * Returns the password used to authenticate the user.
56     *
57     * This should be the encoded password. On authentication, a plain-text
58     * password will be salted, encoded, and then compared to this value.
59     *
60     * @return string The password
61     */
62    public function getPassword();
63
64    /**
65     * Returns the salt that was originally used to encode the password.
66     *
67     * This can return null if the password was not encoded using a salt.
68     *
69     * @return string|null The salt
70     */
71    public function getSalt();
72
73    /**
74     * Returns the username used to authenticate the user.
75     *
76     * @return string The username
77     */
78    public function getUsername();
79
80    /**
81     * Removes sensitive data from the user.
82     *
83     * This is important if, at any given point, sensitive information like
84     * the plain-text password is stored on this object.
85     */
86    public function eraseCredentials();
87}
88