summaryrefslogtreecommitdiffstats
path: root/Core/User
diff options
context:
space:
mode:
Diffstat (limited to 'Core/User')
-rw-r--r--Core/User/AdvancedUserInterface.php (renamed from Core/User/AdvancedAccountInterface.php)4
-rw-r--r--Core/User/ChainUserProvider.php12
-rw-r--r--Core/User/EntityUserProvider.php16
-rw-r--r--Core/User/InMemoryUserProvider.php16
-rw-r--r--Core/User/User.php48
-rw-r--r--Core/User/UserChecker.php (renamed from Core/User/AccountChecker.php)28
-rw-r--r--Core/User/UserCheckerInterface.php (renamed from Core/User/AccountCheckerInterface.php)12
-rw-r--r--Core/User/UserInterface.php (renamed from Core/User/AccountInterface.php)8
-rw-r--r--Core/User/UserProviderInterface.php10
9 files changed, 73 insertions, 81 deletions
diff --git a/Core/User/AdvancedAccountInterface.php b/Core/User/AdvancedUserInterface.php
index 2c615b2..ba528a1 100644
--- a/Core/User/AdvancedAccountInterface.php
+++ b/Core/User/AdvancedUserInterface.php
@@ -12,11 +12,11 @@
namespace Symfony\Component\Security\Core\User;
/**
- * AdvancedAccountInterface adds status flags to a regular account.
+ * AdvancedUserInterface adds status flags to a regular account.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-interface AdvancedAccountInterface extends AccountInterface
+interface AdvancedUserInterface extends UserInterface
{
/**
* Checks whether the user's account has expired.
diff --git a/Core/User/ChainUserProvider.php b/Core/User/ChainUserProvider.php
index 296d099..6417f99 100644
--- a/Core/User/ChainUserProvider.php
+++ b/Core/User/ChainUserProvider.php
@@ -2,7 +2,7 @@
namespace Symfony\Component\Security\Core\User;
-use Symfony\Component\Security\Core\Exception\UnsupportedAccountException;
+use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
/**
@@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
*/
class ChainUserProvider implements UserProviderInterface
{
- protected $providers;
+ private $providers;
public function __construct(array $providers)
{
@@ -41,17 +41,17 @@ class ChainUserProvider implements UserProviderInterface
/**
* {@inheritDoc}
*/
- public function loadUserByAccount(AccountInterface $account)
+ public function loadUser(UserInterface $user)
{
foreach ($this->providers as $provider) {
try {
- return $provider->loadUserByAccount($account);
- } catch (UnsupportedAccountException $unsupported) {
+ return $provider->loadUser($user);
+ } catch (UnsupportedUserException $unsupported) {
// try next one
}
}
- throw new UnsupportedAccountException(sprintf('The account "%s" is not supported.', get_class($account)));
+ throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
}
/**
diff --git a/Core/User/EntityUserProvider.php b/Core/User/EntityUserProvider.php
index 58bcc45..61dd708 100644
--- a/Core/User/EntityUserProvider.php
+++ b/Core/User/EntityUserProvider.php
@@ -12,7 +12,7 @@
namespace Symfony\Component\Security\Core\User;
use Doctrine\ORM\EntityManager;
-use Symfony\Component\Security\Core\Exception\UnsupportedAccountException;
+use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
/**
@@ -25,9 +25,9 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
*/
class EntityUserProvider implements UserProviderInterface
{
- protected $class;
- protected $repository;
- protected $property;
+ private $class;
+ private $repository;
+ private $property;
public function __construct(EntityManager $em, $class, $property = null)
{
@@ -66,13 +66,13 @@ class EntityUserProvider implements UserProviderInterface
/**
* {@inheritDoc}
*/
- public function loadUserByAccount(AccountInterface $account)
+ public function loadUser(UserInterface $user)
{
- if (!$account instanceof $this->class) {
- throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account)));
+ if (!$user instanceof $this->class) {
+ throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
}
- return $this->loadUserByUsername($account->getUsername());
+ return $this->loadUserByUsername($user->getUsername());
}
/**
diff --git a/Core/User/InMemoryUserProvider.php b/Core/User/InMemoryUserProvider.php
index 7d4d1cc..26b4080 100644
--- a/Core/User/InMemoryUserProvider.php
+++ b/Core/User/InMemoryUserProvider.php
@@ -12,7 +12,7 @@
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
-use Symfony\Component\Security\Core\Exception\UnsupportedAccountException;
+use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
/**
* InMemoryUserProvider is a simple non persistent user provider.
@@ -24,7 +24,7 @@ use Symfony\Component\Security\Core\Exception\UnsupportedAccountException;
*/
class InMemoryUserProvider implements UserProviderInterface
{
- protected $users;
+ private $users;
/**
* Constructor.
@@ -50,9 +50,9 @@ class InMemoryUserProvider implements UserProviderInterface
/**
* Adds a new User to the provider.
*
- * @param AccountInterface $user A AccountInterface instance
+ * @param UserInterface $user A UserInterface instance
*/
- public function createUser(AccountInterface $user)
+ public function createUser(UserInterface $user)
{
if (isset($this->users[strtolower($user->getUsername())])) {
throw new \LogicException('Another user with the same username already exist.');
@@ -79,13 +79,13 @@ class InMemoryUserProvider implements UserProviderInterface
/**
* {@inheritDoc}
*/
- public function loadUserByAccount(AccountInterface $account)
+ public function loadUser(UserInterface $user)
{
- if (!$account instanceof User) {
- throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account)));
+ if (!$user instanceof User) {
+ throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
}
- return $this->loadUserByUsername((string) $account);
+ return $this->loadUserByUsername($user->getUsername());
}
/**
diff --git a/Core/User/User.php b/Core/User/User.php
index 02a2c06..7dcdee3 100644
--- a/Core/User/User.php
+++ b/Core/User/User.php
@@ -18,16 +18,16 @@ namespace Symfony\Component\Security\Core\User;
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class User implements AdvancedAccountInterface
+final class User implements AdvancedUserInterface
{
- protected $username;
- protected $password;
- protected $accountNonExpired;
- protected $credentialsNonExpired;
- protected $accountNonLocked;
- protected $roles;
-
- public function __construct($username, $password, array $roles = array(), $enabled = true, $accountNonExpired = true, $credentialsNonExpired = true, $accountNonLocked = true)
+ private $username;
+ private $password;
+ private $userNonExpired;
+ private $credentialsNonExpired;
+ private $userNonLocked;
+ private $roles;
+
+ public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
{
if (empty($username)) {
throw new \InvalidArgumentException('The username cannot be empty.');
@@ -36,23 +36,15 @@ class User implements AdvancedAccountInterface
$this->username = $username;
$this->password = $password;
$this->enabled = $enabled;
- $this->accountNonExpired = $accountNonExpired;
+ $this->accountNonExpired = $userNonExpired;
$this->credentialsNonExpired = $credentialsNonExpired;
- $this->accountNonLocked = $accountNonLocked;
+ $this->accountNonLocked = $userNonLocked;
$this->roles = $roles;
}
/**
* {@inheritdoc}
*/
- public function __toString()
- {
- return $this->username;
- }
-
- /**
- * {@inheritdoc}
- */
public function getRoles()
{
return $this->roles;
@@ -124,37 +116,37 @@ class User implements AdvancedAccountInterface
/**
* {@inheritDoc}
*/
- public function equals(AccountInterface $account)
+ public function equals(UserInterface $user)
{
- if (!$account instanceof User) {
+ if (!$user instanceof User) {
return false;
}
- if ($this->password !== $account->getPassword()) {
+ if ($this->password !== $user->getPassword()) {
return false;
}
- if ($this->getSalt() !== $account->getSalt()) {
+ if ($this->getSalt() !== $user->getSalt()) {
return false;
}
- if ($this->username !== $account->getUsername()) {
+ if ($this->username !== $user->getUsername()) {
return false;
}
- if ($this->accountNonExpired !== $account->isAccountNonExpired()) {
+ if ($this->accountNonExpired !== $user->isAccountNonExpired()) {
return false;
}
- if ($this->accountNonLocked !== $account->isAccountNonLocked()) {
+ if ($this->accountNonLocked !== $user->isAccountNonLocked()) {
return false;
}
- if ($this->credentialsNonExpired !== $account->isCredentialsNonExpired()) {
+ if ($this->credentialsNonExpired !== $user->isCredentialsNonExpired()) {
return false;
}
- if ($this->enabled !== $account->isEnabled()) {
+ if ($this->enabled !== $user->isEnabled()) {
return false;
}
diff --git a/Core/User/AccountChecker.php b/Core/User/UserChecker.php
index cf66f93..93897a1 100644
--- a/Core/User/AccountChecker.php
+++ b/Core/User/UserChecker.php
@@ -17,45 +17,45 @@ use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
/**
- * AccountChecker checks the user account flags.
+ * UserChecker checks the user account flags.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class AccountChecker implements AccountCheckerInterface
+class UserChecker implements UserCheckerInterface
{
/**
* {@inheritdoc}
*/
- public function checkPreAuth(AccountInterface $account)
+ public function checkPreAuth(UserInterface $user)
{
- if (!$account instanceof AdvancedAccountInterface) {
+ if (!$user instanceof AdvancedUserInterface) {
return;
}
- if (!$account->isCredentialsNonExpired()) {
- throw new CredentialsExpiredException('User credentials have expired.', $account);
+ if (!$user->isCredentialsNonExpired()) {
+ throw new CredentialsExpiredException('User credentials have expired.', $user);
}
}
/**
* {@inheritdoc}
*/
- public function checkPostAuth(AccountInterface $account)
+ public function checkPostAuth(UserInterface $user)
{
- if (!$account instanceof AdvancedAccountInterface) {
+ if (!$user instanceof AdvancedUserInterface) {
return;
}
- if (!$account->isAccountNonLocked()) {
- throw new LockedException('User account is locked.', $account);
+ if (!$user->isAccountNonLocked()) {
+ throw new LockedException('User account is locked.', $user);
}
- if (!$account->isEnabled()) {
- throw new DisabledException('User account is disabled.', $account);
+ if (!$user->isEnabled()) {
+ throw new DisabledException('User account is disabled.', $user);
}
- if (!$account->isAccountNonExpired()) {
- throw new AccountExpiredException('User account has expired.', $account);
+ if (!$user->isAccountNonExpired()) {
+ throw new AccountExpiredException('User account has expired.', $user);
}
}
}
diff --git a/Core/User/AccountCheckerInterface.php b/Core/User/UserCheckerInterface.php
index 1e9abaa..25de94a 100644
--- a/Core/User/AccountCheckerInterface.php
+++ b/Core/User/UserCheckerInterface.php
@@ -12,25 +12,25 @@
namespace Symfony\Component\Security\Core\User;
/**
- * AccountCheckerInterface checks user account when authentication occurs.
+ * UserCheckerInterface checks user account when authentication occurs.
*
* This should not be used to make authentication decisions.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-interface AccountCheckerInterface
+interface UserCheckerInterface
{
/**
* Checks the user account before authentication.
*
- * @param AccountInterface $account An AccountInterface instance
+ * @param UserInterface $user An UserInterface instance
*/
- function checkPreAuth(AccountInterface $account);
+ function checkPreAuth(UserInterface $user);
/**
* Checks the user account after authentication.
*
- * @param AccountInterface $account An AccountInterface instance
+ * @param UserInterface $user An UserInterface instance
*/
- function checkPostAuth(AccountInterface $account);
+ function checkPostAuth(UserInterface $user);
}
diff --git a/Core/User/AccountInterface.php b/Core/User/UserInterface.php
index 46ea6ae..9091bfc 100644
--- a/Core/User/AccountInterface.php
+++ b/Core/User/UserInterface.php
@@ -12,11 +12,11 @@
namespace Symfony\Component\Security\Core\User;
/**
- * AccountInterface is the interface that user classes must implement.
+ * UserInterface is the interface that user classes must implement.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-interface AccountInterface
+interface UserInterface
{
/**
* Returns the roles granted to the user.
@@ -60,8 +60,8 @@ interface AccountInterface
* However, you do not need to compare every attribute, but only those that
* are relevant for assessing whether re-authentication is required.
*
- * @param AccountInterface $account
+ * @param UserInterface $user
* @return Boolean
*/
- function equals(AccountInterface $account);
+ function equals(UserInterface $user);
}
diff --git a/Core/User/UserProviderInterface.php b/Core/User/UserProviderInterface.php
index 6c5666f..79be191 100644
--- a/Core/User/UserProviderInterface.php
+++ b/Core/User/UserProviderInterface.php
@@ -28,7 +28,7 @@ interface UserProviderInterface
* @throws UsernameNotFoundException if the user is not found
* @param string $username The username
*
- * @return AccountInterface
+ * @return UserInterface
*/
function loadUserByUsername($username);
@@ -39,12 +39,12 @@ interface UserProviderInterface
* from the database, or if it simply merges the passed User into the
* identity map of an entity manager.
*
- * @throws UnsupportedAccountException if the account is not supported
- * @param AccountInterface $account
+ * @throws UnsupportedUserException if the account is not supported
+ * @param UserInterface $user
*
- * @return AccountInterface
+ * @return UserInterface
*/
- function loadUserByAccount(AccountInterface $account);
+ function loadUser(UserInterface $user);
/**
* Whether this provider supports the given user class