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\Core\User;
13:
14: use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
15: use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
16:
17: /**
18: * Represents a class that loads UserInterface objects from some source for the authentication system.
19: *
20: * In a typical authentication configuration, a username (i.e. some unique
21: * user identifier) credential enters the system (via form login, or any
22: * method). The user provider that is configured with that authentication
23: * method is asked to load the UserInterface object for the given username
24: * (via loadUserByUsername) so that the rest of the process can continue.
25: *
26: * Internally, a user provider can load users from any source (databases,
27: * configuration, web service). This is totally independent of how the authentication
28: * information is submitted or what the UserInterface object looks like.
29: *
30: * @see UserInterface
31: *
32: * @author Fabien Potencier <fabien@symfony.com>
33: */
34: interface UserProviderInterface
35: {
36: /**
37: * Loads the user for the given username.
38: *
39: * This method must throw UsernameNotFoundException if the user is not
40: * found.
41: *
42: * @param string $username The username
43: *
44: * @return UserInterface
45: *
46: * @see UsernameNotFoundException
47: *
48: * @throws UsernameNotFoundException if the user is not found
49: *
50: */
51: public function loadUserByUsername($username);
52:
53: /**
54: * Refreshes the user for the account interface.
55: *
56: * It is up to the implementation to decide if the user data should be
57: * totally reloaded (e.g. from the database), or if the UserInterface
58: * object can just be merged into some internal array of users / identity
59: * map.
60: * @param UserInterface $user
61: *
62: * @return UserInterface
63: *
64: * @throws UnsupportedUserException if the account is not supported
65: */
66: public function refreshUser(UserInterface $user);
67:
68: /**
69: * Whether this provider supports the given user class
70: *
71: * @param string $class
72: *
73: * @return bool
74: */
75: public function supportsClass($class);
76: }
77: