summaryrefslogtreecommitdiffstats
path: root/User
diff options
context:
space:
mode:
authorJohannes M. Schmitt <schmittjoh@gmail.com>2011-01-26 21:34:11 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2011-01-26 22:23:20 +0100
commitbebc09870cb0a7720e2c6a8c5c74585e69e8bb24 (patch)
tree0c399647cdbe504be405017e7cc04c70c53482f2 /User
parentc85f3d708d2c9b00d73ca1234ccfaf50336d94b1 (diff)
downloadsymfony-security-bebc09870cb0a7720e2c6a8c5c74585e69e8bb24.zip
symfony-security-bebc09870cb0a7720e2c6a8c5c74585e69e8bb24.tar.gz
symfony-security-bebc09870cb0a7720e2c6a8c5c74585e69e8bb24.tar.bz2
namespace changes
Symfony\Component\Security -> Symfony\Component\Security\Core Symfony\Component\Security\Acl remains unchanged Symfony\Component\HttpKernel\Security -> Symfony\Component\Security\Http
Diffstat (limited to 'User')
-rw-r--r--User/AccountChecker.php61
-rw-r--r--User/AccountCheckerInterface.php36
-rw-r--r--User/AccountInterface.php74
-rw-r--r--User/AdvancedAccountInterface.php48
-rw-r--r--User/InMemoryUserProvider.php98
-rw-r--r--User/User.php163
-rw-r--r--User/UserProviderInterface.php57
7 files changed, 0 insertions, 537 deletions
diff --git a/User/AccountChecker.php b/User/AccountChecker.php
deleted file mode 100644
index 9e4012c..0000000
--- a/User/AccountChecker.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-use Symfony\Component\Security\Exception\CredentialsExpiredException;
-use Symfony\Component\Security\Exception\LockedException;
-use Symfony\Component\Security\Exception\DisabledException;
-use Symfony\Component\Security\Exception\AccountExpiredException;
-
-/**
- * AccountChecker checks the user account flags.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class AccountChecker implements AccountCheckerInterface
-{
- /**
- * {@inheritdoc}
- */
- public function checkPreAuth(AccountInterface $account)
- {
- if (!$account instanceof AdvancedAccountInterface) {
- return;
- }
-
- if (!$account->isCredentialsNonExpired()) {
- throw new CredentialsExpiredException('User credentials have expired.', $account);
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function checkPostAuth(AccountInterface $account)
- {
- if (!$account instanceof AdvancedAccountInterface) {
- return;
- }
-
- if (!$account->isAccountNonLocked()) {
- throw new LockedException('User account is locked.', $account);
- }
-
- if (!$account->isEnabled()) {
- throw new DisabledException('User account is disabled.', $account);
- }
-
- if (!$account->isAccountNonExpired()) {
- throw new AccountExpiredException('User account has expired.', $account);
- }
- }
-}
diff --git a/User/AccountCheckerInterface.php b/User/AccountCheckerInterface.php
deleted file mode 100644
index 776a99d..0000000
--- a/User/AccountCheckerInterface.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-/**
- * AccountCheckerInterface checks user account when authentication occurs.
- *
- * This should not be used to make authentication decisions.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-interface AccountCheckerInterface
-{
- /**
- * Checks the user account before authentication.
- *
- * @param AccountInterface $account An AccountInterface instance
- */
- function checkPreAuth(AccountInterface $account);
-
- /**
- * Checks the user account after authentication.
- *
- * @param AccountInterface $account An AccountInterface instance
- */
- function checkPostAuth(AccountInterface $account);
-}
diff --git a/User/AccountInterface.php b/User/AccountInterface.php
deleted file mode 100644
index 0bc488f..0000000
--- a/User/AccountInterface.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-/**
- * AccountInterface is the interface that user classes must implement.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-interface AccountInterface
-{
- /**
- * Returns a string representation of the User.
- *
- * @return string A string return of the User
- */
- function __toString();
-
- /**
- * Returns the roles granted to the user.
- *
- * @return Role[] The user roles
- */
- function getRoles();
-
- /**
- * Returns the password used to authenticate the user.
- *
- * @return string The password
- */
- function getPassword();
-
- /**
- * Returns the salt.
- *
- * @return string The salt
- */
- function getSalt();
-
- /**
- * Returns the username used to authenticate the user.
- *
- * @return string The username
- */
- function getUsername();
-
- /**
- * Removes sensitive data from the user.
- *
- * @return void
- */
- function eraseCredentials();
-
- /**
- * The equality comparison should neither be done by referential equality
- * nor by comparing identities (i.e. getId() === getId()).
- *
- * 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
- * @return Boolean
- */
- function equals(AccountInterface $account);
-}
diff --git a/User/AdvancedAccountInterface.php b/User/AdvancedAccountInterface.php
deleted file mode 100644
index d5b6ae3..0000000
--- a/User/AdvancedAccountInterface.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-/**
- * AdvancedAccountInterface adds status flags to a regular account.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-interface AdvancedAccountInterface extends AccountInterface
-{
- /**
- * Checks whether the user's account has expired.
- *
- * @return Boolean true if the user's account is non expired, false otherwise
- */
- function isAccountNonExpired();
-
- /**
- * Checks whether the user is locked.
- *
- * @return Boolean true if the user is not locked, false otherwise
- */
- function isAccountNonLocked();
-
- /**
- * Checks whether the user's credentials (password) has expired.
- *
- * @return Boolean true if the user's credentials are non expired, false otherwise
- */
- function isCredentialsNonExpired();
-
- /**
- * Checks whether the user is enabled.
- *
- * @return Boolean true if the user is enabled, false otherwise
- */
- function isEnabled();
-}
diff --git a/User/InMemoryUserProvider.php b/User/InMemoryUserProvider.php
deleted file mode 100644
index 082e9c9..0000000
--- a/User/InMemoryUserProvider.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-use Symfony\Component\Security\Exception\UsernameNotFoundException;
-use Symfony\Component\Security\Exception\UnsupportedAccountException;
-
-/**
- * InMemoryUserProvider is a simple non persistent user provider.
- *
- * Useful for testing, demonstration, prototyping, and for simple needs
- * (a backend with a unique admin for instance)
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class InMemoryUserProvider implements UserProviderInterface
-{
- protected $users;
-
- /**
- * Constructor.
- *
- * The user array is a hash where the keys are usernames and the values are
- * an array of attributes: 'password', 'enabled', and 'roles'.
- *
- * @param array $users An array of users
- * @param string $name
- */
- public function __construct(array $users = array())
- {
- foreach ($users as $username => $attributes) {
- $password = isset($attributes['password']) ? $attributes['password'] : null;
- $enabled = isset($attributes['enabled']) ? $attributes['enabled'] : true;
- $roles = isset($attributes['roles']) ? $attributes['roles'] : array();
- $user = new User($username, $password, $roles, $enabled, true, true, true);
-
- $this->createUser($user);
- }
- }
-
- /**
- * Adds a new User to the provider.
- *
- * @param AccountInterface $user A AccountInterface instance
- */
- public function createUser(AccountInterface $user)
- {
- if (isset($this->users[strtolower($user->getUsername())])) {
- throw new \LogicException('Another user with the same username already exist.');
- }
-
- $this->users[strtolower($user->getUsername())] = $user;
- }
-
- /**
- * {@inheritdoc}
- */
- public function loadUserByUsername($username)
- {
- if (!isset($this->users[strtolower($username)])) {
- throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
- }
-
- $user = $this->users[strtolower($username)];
-
- return new User($user->getUsername(), $user->getPassword(), $user->getRoles(), $user->isEnabled(), $user->isAccountNonExpired(),
- $user->isCredentialsNonExpired(), $user->isAccountNonLocked());
- }
-
- /**
- * {@inheritDoc}
- */
- public function loadUserByAccount(AccountInterface $account)
- {
- if (!$account instanceof User) {
- throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account)));
- }
-
- return $this->loadUserByUsername((string) $account);
- }
-
- /**
- * {@inheritDoc}
- */
- public function supportsClass($class)
- {
- return $class === 'Symfony\Component\Security\User\User';
- }
-}
diff --git a/User/User.php b/User/User.php
deleted file mode 100644
index 338d43c..0000000
--- a/User/User.php
+++ /dev/null
@@ -1,163 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-/**
- * User is the user implementation used by the in-memory user provider.
- *
- * This should not be used for anything else.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class User implements AdvancedAccountInterface
-{
- 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)
- {
- if (empty($username)) {
- throw new \InvalidArgumentException('The username cannot be empty.');
- }
-
- $this->username = $username;
- $this->password = $password;
- $this->enabled = $enabled;
- $this->accountNonExpired = $accountNonExpired;
- $this->credentialsNonExpired = $credentialsNonExpired;
- $this->accountNonLocked = $accountNonLocked;
- $this->roles = $roles;
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString()
- {
- return $this->username;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getRoles()
- {
- return $this->roles;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getPassword()
- {
- return $this->password;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getSalt()
- {
- return null;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getUsername()
- {
- return $this->username;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isAccountNonExpired()
- {
- return $this->accountNonExpired;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isAccountNonLocked()
- {
- return $this->accountNonLocked;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isCredentialsNonExpired()
- {
- return $this->credentialsNonExpired;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isEnabled()
- {
- return $this->enabled;
- }
-
- /**
- * {@inheritdoc}
- */
- public function eraseCredentials()
- {
- }
-
- /**
- * {@inheritDoc}
- */
- public function equals(AccountInterface $account)
- {
- if (!$account instanceof User) {
- return false;
- }
-
- if ($this->password !== $account->getPassword()) {
- return false;
- }
-
- if ($this->getSalt() !== $account->getSalt()) {
- return false;
- }
-
- if ($this->username !== $account->getUsername()) {
- return false;
- }
-
- if ($this->accountNonExpired !== $account->isAccountNonExpired()) {
- return false;
- }
-
- if ($this->accountNonLocked !== $account->isAccountNonLocked()) {
- return false;
- }
-
- if ($this->credentialsNonExpired !== $account->isCredentialsNonExpired()) {
- return false;
- }
-
- if ($this->enabled !== $account->isEnabled()) {
- return false;
- }
-
- return true;
- }
-}
diff --git a/User/UserProviderInterface.php b/User/UserProviderInterface.php
deleted file mode 100644
index 926f575..0000000
--- a/User/UserProviderInterface.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\User;
-
-/**
- * UserProviderInterface is the implementation that all user provider must
- * implement.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-interface UserProviderInterface
-{
- /**
- * Loads the user for the given username.
- *
- * This method must throw UsernameNotFoundException if the user is not
- * found.
- *
- * @throws UsernameNotFoundException if the user is not found
- * @param string $username The username
- *
- * @return AccountInterface
- */
- function loadUserByUsername($username);
-
- /**
- * Loads the user for the account interface.
- *
- * It is up to the implementation if it decides to reload the user data
- * 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
- *
- * @return AccountInterface
- */
- function loadUserByAccount(AccountInterface $account);
-
- /**
- * Whether this provider supports the given user class
- *
- * @param string $class
- *
- * @return Boolean
- */
- function supportsClass($class);
-} \ No newline at end of file