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: /**
15: * User is the user implementation used by the in-memory user provider.
16: *
17: * This should not be used for anything else.
18: *
19: * @author Fabien Potencier <fabien@symfony.com>
20: */
21: final class User implements AdvancedUserInterface
22: {
23: private $username;
24: private $password;
25: private $enabled;
26: private $accountNonExpired;
27: private $credentialsNonExpired;
28: private $accountNonLocked;
29: private $roles;
30:
31: public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
32: {
33: if (empty($username)) {
34: throw new \InvalidArgumentException('The username cannot be empty.');
35: }
36:
37: $this->username = $username;
38: $this->password = $password;
39: $this->enabled = $enabled;
40: $this->accountNonExpired = $userNonExpired;
41: $this->credentialsNonExpired = $credentialsNonExpired;
42: $this->accountNonLocked = $userNonLocked;
43: $this->roles = $roles;
44: }
45:
46: /**
47: * {@inheritdoc}
48: */
49: public function getRoles()
50: {
51: return $this->roles;
52: }
53:
54: /**
55: * {@inheritdoc}
56: */
57: public function getPassword()
58: {
59: return $this->password;
60: }
61:
62: /**
63: * {@inheritdoc}
64: */
65: public function getSalt()
66: {
67: }
68:
69: /**
70: * {@inheritdoc}
71: */
72: public function getUsername()
73: {
74: return $this->username;
75: }
76:
77: /**
78: * {@inheritdoc}
79: */
80: public function isAccountNonExpired()
81: {
82: return $this->accountNonExpired;
83: }
84:
85: /**
86: * {@inheritdoc}
87: */
88: public function isAccountNonLocked()
89: {
90: return $this->accountNonLocked;
91: }
92:
93: /**
94: * {@inheritdoc}
95: */
96: public function isCredentialsNonExpired()
97: {
98: return $this->credentialsNonExpired;
99: }
100:
101: /**
102: * {@inheritdoc}
103: */
104: public function isEnabled()
105: {
106: return $this->enabled;
107: }
108:
109: /**
110: * {@inheritdoc}
111: */
112: public function eraseCredentials()
113: {
114: }
115: }
116: