diff options
author | realmfoo <konstantin.leboev@gmail.com> | 2011-08-10 10:59:19 +0400 |
---|---|---|
committer | realmfoo <konstantin.leboev@gmail.com> | 2011-08-10 10:59:19 +0400 |
commit | b33e8d2376f20761911faa654d85790d61a29019 (patch) | |
tree | 91ef528a24e416523bb25859a702d8d859a0e2af /Core | |
parent | 111f1e758a0919556c2c2fdd8fd8779303113f30 (diff) | |
parent | 77b520411cafe3f32f1f52d27dd806ee6110504d (diff) | |
download | symfony-security-b33e8d2376f20761911faa654d85790d61a29019.zip symfony-security-b33e8d2376f20761911faa654d85790d61a29019.tar.gz symfony-security-b33e8d2376f20761911faa654d85790d61a29019.tar.bz2 |
merge from master
Diffstat (limited to 'Core')
18 files changed, 101 insertions, 107 deletions
diff --git a/Core/Authentication/Provider/AnonymousAuthenticationProvider.php b/Core/Authentication/Provider/AnonymousAuthenticationProvider.php index c48a27e..ea91075 100644 --- a/Core/Authentication/Provider/AnonymousAuthenticationProvider.php +++ b/Core/Authentication/Provider/AnonymousAuthenticationProvider.php @@ -43,7 +43,7 @@ class AnonymousAuthenticationProvider implements AuthenticationProviderInterface return null; } - if ($this->key != $token->getKey()) { + if ($this->key !== $token->getKey()) { throw new BadCredentialsException('The Token does not contain the expected key.'); } diff --git a/Core/Authentication/Provider/RememberMeAuthenticationProvider.php b/Core/Authentication/Provider/RememberMeAuthenticationProvider.php index 940288b..fb687b2 100644 --- a/Core/Authentication/Provider/RememberMeAuthenticationProvider.php +++ b/Core/Authentication/Provider/RememberMeAuthenticationProvider.php @@ -1,4 +1,14 @@ <?php + +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Symfony\Component\Security\Core\Authentication\Provider; use Symfony\Component\Security\Core\User\UserCheckerInterface; @@ -43,4 +53,4 @@ class RememberMeAuthenticationProvider implements AuthenticationProviderInterfac { return $token instanceof RememberMeToken && $token->getProviderKey() === $this->providerKey; } -}
\ No newline at end of file +} diff --git a/Core/Authentication/RememberMe/InMemoryTokenProvider.php b/Core/Authentication/RememberMe/InMemoryTokenProvider.php index c432b0e..4653900 100644 --- a/Core/Authentication/RememberMe/InMemoryTokenProvider.php +++ b/Core/Authentication/RememberMe/InMemoryTokenProvider.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Symfony\Component\Security\Core\Authentication\RememberMe; use Symfony\Component\Security\Core\Exception\TokenNotFoundException; @@ -47,4 +56,4 @@ class InMemoryTokenProvider implements TokenProviderInterface { $this->tokens[$token->getSeries()] = $token; } -}
\ No newline at end of file +} diff --git a/Core/Authentication/RememberMe/PersistentToken.php b/Core/Authentication/RememberMe/PersistentToken.php index 55e6b89..d9029f5 100644 --- a/Core/Authentication/RememberMe/PersistentToken.php +++ b/Core/Authentication/RememberMe/PersistentToken.php @@ -104,4 +104,4 @@ final class PersistentToken implements PersistentTokenInterface { return $this->lastUsed; } -}
\ No newline at end of file +} diff --git a/Core/Authentication/RememberMe/PersistentTokenInterface.php b/Core/Authentication/RememberMe/PersistentTokenInterface.php index fe1db51..004a9b7 100644 --- a/Core/Authentication/RememberMe/PersistentTokenInterface.php +++ b/Core/Authentication/RememberMe/PersistentTokenInterface.php @@ -20,6 +20,12 @@ namespace Symfony\Component\Security\Core\Authentication\RememberMe; interface PersistentTokenInterface { /** + * Returns the class of the user + * @return string + */ + function getClass(); + + /** * Returns the username * @return string */ @@ -42,4 +48,4 @@ interface PersistentTokenInterface * @return \DateTime */ function getLastUsed(); -}
\ No newline at end of file +} diff --git a/Core/Authentication/RememberMe/TokenProviderInterface.php b/Core/Authentication/RememberMe/TokenProviderInterface.php index 1ec9c80..b48bd4d 100644 --- a/Core/Authentication/RememberMe/TokenProviderInterface.php +++ b/Core/Authentication/RememberMe/TokenProviderInterface.php @@ -48,4 +48,4 @@ interface TokenProviderInterface * @param PersistentTokenInterface $token */ function createNewToken(PersistentTokenInterface $token); -}
\ No newline at end of file +} diff --git a/Core/Authentication/Token/RememberMeToken.php b/Core/Authentication/Token/RememberMeToken.php index 7978427..81ab1c2 100644 --- a/Core/Authentication/Token/RememberMeToken.php +++ b/Core/Authentication/Token/RememberMeToken.php @@ -27,8 +27,8 @@ class RememberMeToken extends AbstractToken * Constructor. * * @param UserInterface $user - * @param string $providerKey - * @param string $key + * @param string $providerKey + * @param string $key */ public function __construct(UserInterface $user, $providerKey, $key) { parent::__construct($user->getRoles()); @@ -92,4 +92,4 @@ class RememberMeToken extends AbstractToken list($this->key, $this->providerKey, $parentStr) = unserialize($serialized); parent::unserialize($parentStr); } -}
\ No newline at end of file +} diff --git a/Core/Encoder/EncoderFactory.php b/Core/Encoder/EncoderFactory.php index d6441d9..d7ae32d 100644 --- a/Core/Encoder/EncoderFactory.php +++ b/Core/Encoder/EncoderFactory.php @@ -66,4 +66,4 @@ class EncoderFactory implements EncoderFactoryInterface return $reflection->newInstanceArgs($config['arguments']); } -}
\ No newline at end of file +} diff --git a/Core/Encoder/EncoderFactoryInterface.php b/Core/Encoder/EncoderFactoryInterface.php index 62cc9aa..811c262 100644 --- a/Core/Encoder/EncoderFactoryInterface.php +++ b/Core/Encoder/EncoderFactoryInterface.php @@ -27,4 +27,4 @@ interface EncoderFactoryInterface * @return PasswordEncoderInterface never null */ function getEncoder(UserInterface $user); -}
\ No newline at end of file +} diff --git a/Core/Exception/CookieTheftException.php b/Core/Exception/CookieTheftException.php index 83e61d7..09ec79e 100644 --- a/Core/Exception/CookieTheftException.php +++ b/Core/Exception/CookieTheftException.php @@ -19,4 +19,4 @@ namespace Symfony\Component\Security\Core\Exception; */ class CookieTheftException extends AuthenticationException { -}
\ No newline at end of file +} diff --git a/Core/Exception/InvalidCsrfTokenException.php b/Core/Exception/InvalidCsrfTokenException.php index f19bcbf..51adb69 100644 --- a/Core/Exception/InvalidCsrfTokenException.php +++ b/Core/Exception/InvalidCsrfTokenException.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Symfony\Component\Security\Core\Exception; /** @@ -9,4 +18,4 @@ namespace Symfony\Component\Security\Core\Exception; */ class InvalidCsrfTokenException extends AuthenticationException { -}
\ No newline at end of file +} diff --git a/Core/Exception/SessionUnavailableException.php b/Core/Exception/SessionUnavailableException.php new file mode 100644 index 0000000..a00a503 --- /dev/null +++ b/Core/Exception/SessionUnavailableException.php @@ -0,0 +1,27 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Exception; + +/** + * This exception is thrown when no session is available. + * + * Possible reasons for this are: + * + * a) The session timed-out because the user waited too long. + * b) The user has disabled cookies, and a new session is started on each + * request. + * + * @author Johannes M. Schmitt <schmittjoh@gmail.com> + */ +class SessionUnavailableException extends AuthenticationException +{ +} diff --git a/Core/Exception/UnsupportedUserException.php b/Core/Exception/UnsupportedUserException.php index 5be9bc4..6529fa9 100644 --- a/Core/Exception/UnsupportedUserException.php +++ b/Core/Exception/UnsupportedUserException.php @@ -19,4 +19,4 @@ namespace Symfony\Component\Security\Core\Exception; */ class UnsupportedUserException extends AuthenticationServiceException { -}
\ No newline at end of file +} diff --git a/Core/SecurityContextInterface.php b/Core/SecurityContextInterface.php index 41815fb..d57c409 100644 --- a/Core/SecurityContextInterface.php +++ b/Core/SecurityContextInterface.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Symfony\Component\Security\Core; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; @@ -38,4 +47,4 @@ interface SecurityContextInterface * @return Boolean */ function isGranted($attributes, $object = null); -}
\ No newline at end of file +} diff --git a/Core/User/ChainUserProvider.php b/Core/User/ChainUserProvider.php index 6417f99..e6aca32 100644 --- a/Core/User/ChainUserProvider.php +++ b/Core/User/ChainUserProvider.php @@ -1,5 +1,14 @@ <?php +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + namespace Symfony\Component\Security\Core\User; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; @@ -41,11 +50,11 @@ class ChainUserProvider implements UserProviderInterface /** * {@inheritDoc} */ - public function loadUser(UserInterface $user) + public function refreshUser(UserInterface $user) { foreach ($this->providers as $provider) { try { - return $provider->loadUser($user); + return $provider->refreshUser($user); } catch (UnsupportedUserException $unsupported) { // try next one } @@ -67,4 +76,4 @@ class ChainUserProvider implements UserProviderInterface return false; } -}
\ No newline at end of file +} diff --git a/Core/User/EntityUserProvider.php b/Core/User/EntityUserProvider.php deleted file mode 100644 index 61dd708..0000000 --- a/Core/User/EntityUserProvider.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\User; - -use Doctrine\ORM\EntityManager; -use Symfony\Component\Security\Core\Exception\UnsupportedUserException; -use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; - -/** - * Wrapper around a Doctrine EntityManager. - * - * Provides easy to use provisioning for Doctrine entity users. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Johannes M. Schmitt <schmittjoh@gmail.com> - */ -class EntityUserProvider implements UserProviderInterface -{ - private $class; - private $repository; - private $property; - - public function __construct(EntityManager $em, $class, $property = null) - { - $this->class = $class; - - if (false !== strpos($this->class, ':')) { - $this->class = $em->getClassMetadata($class)->name; - } - - $this->repository = $em->getRepository($class); - $this->property = $property; - } - - /** - * {@inheritdoc} - */ - public function loadUserByUsername($username) - { - if (null !== $this->property) { - $user = $this->repository->findOneBy(array($this->property => $username)); - } else { - if (!$this->repository instanceof UserProviderInterface) { - throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement UserProviderInterface.', get_class($this->repository))); - } - - $user = $this->repository->loadUserByUsername($username); - } - - if (null === $user) { - throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username)); - } - - return $user; - } - - /** - * {@inheritDoc} - */ - public function loadUser(UserInterface $user) - { - if (!$user instanceof $this->class) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); - } - - return $this->loadUserByUsername($user->getUsername()); - } - - /** - * {@inheritDoc} - */ - public function supportsClass($class) - { - return $class === $this->class; - } -} diff --git a/Core/User/InMemoryUserProvider.php b/Core/User/InMemoryUserProvider.php index e73eb95..eae2083 100644 --- a/Core/User/InMemoryUserProvider.php +++ b/Core/User/InMemoryUserProvider.php @@ -78,7 +78,7 @@ class InMemoryUserProvider implements UserProviderInterface /** * {@inheritDoc} */ - public function loadUser(UserInterface $user) + public function refreshUser(UserInterface $user) { if (!$user instanceof User) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); diff --git a/Core/User/UserProviderInterface.php b/Core/User/UserProviderInterface.php index 79be191..11fd62c 100644 --- a/Core/User/UserProviderInterface.php +++ b/Core/User/UserProviderInterface.php @@ -33,7 +33,7 @@ interface UserProviderInterface function loadUserByUsername($username); /** - * Loads the user for the account interface. + * Refreshes 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 @@ -44,7 +44,7 @@ interface UserProviderInterface * * @return UserInterface */ - function loadUser(UserInterface $user); + function refreshUser(UserInterface $user); /** * Whether this provider supports the given user class @@ -54,4 +54,4 @@ interface UserProviderInterface * @return Boolean */ function supportsClass($class); -}
\ No newline at end of file +} |