diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 1ec5e9e2aebe1..92cc1cef08cd7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -527,6 +527,11 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $dirs[] = dirname($r->getFilename()).'/Resources/translations'; } + if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { + $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); + + $dirs[] = dirname($r->getFilename()).'/../../Resources/translations'; + } $overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations'; foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { $reflection = new \ReflectionClass($class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 3203f37bcaf8a..129ae0aa4d680 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -205,6 +205,11 @@ public function testTranslator() $files, '->registerTranslatorConfiguration() finds Form translation resources' ); + $this->assertContains( + 'Symfony/Component/Security/Resources/translations/security.en.xlf', + $files, + '->registerTranslatorConfiguration() finds Security translation resources' + ); $calls = $container->getDefinition('translator.default')->getMethodCalls(); $this->assertEquals('fr', $calls[0][1][0]); diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 3f2ad2f0c13be..12bc33d882443 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -29,7 +29,8 @@ "doctrine/common": ">=2.2,<2.4-dev" }, "require-dev": { - "symfony/finder": "2.2.*" + "symfony/finder": "2.2.*", + "symfony/security": "2.2.*" }, "suggest": { "symfony/console": "2.2.*", diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index 1305b28335316..83914b16bcfe6 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -34,3 +34,8 @@ CHANGELOG `AbstractAuthenticationListener` has changed. * [BC BREAK] moved the default logout success handling to a separate class. The order of arguments in the constructor of `LogoutListener` has changed. + * [BC BREAK] The constructor of `AuthenticationException` and all child + classes now matches the constructor of `\Exception`. The extra information + getters and setters are removed. There are now dedicated getters/setters for + token (`AuthenticationException'), user (`AccountStatusException`) and + username (`UsernameNotFoundException`). diff --git a/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php b/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php index b0414f0fffd66..8b7474bec4e24 100644 --- a/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php +++ b/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php @@ -77,7 +77,7 @@ public function authenticate(TokenInterface $token) break; } } catch (AccountStatusException $e) { - $e->setExtraInformation($token); + $e->setToken($token); throw $e; } catch (AuthenticationException $e) { @@ -105,7 +105,7 @@ public function authenticate(TokenInterface $token) $this->eventDispatcher->dispatch(AuthenticationEvents::AUTHENTICATION_FAILURE, new AuthenticationFailureEvent($token, $lastException)); } - $lastException->setExtraInformation($token); + $lastException->setToken($token); throw $lastException; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php index f22045f03dead..a9a22056d6e64 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php @@ -88,9 +88,12 @@ protected function retrieveUser($username, UsernamePasswordToken $token) return $user; } catch (UsernameNotFoundException $notFound) { + $notFound->setUsername($username); throw $notFound; } catch (\Exception $repositoryProblem) { - throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem); + $ex = new AuthenticationServiceException($repositoryProblem->getMessage(), 0, $repositoryProblem); + $ex->setToken($token); + throw $ex; } } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php index ed8f4995e1fff..626f50b8b59f9 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php @@ -71,6 +71,7 @@ public function authenticate(TokenInterface $token) if ($this->hideUserNotFoundExceptions) { throw new BadCredentialsException('Bad credentials', 0, $notFound); } + $notFound->setUsername($username); throw $notFound; } diff --git a/src/Symfony/Component/Security/Core/Exception/AccountExpiredException.php b/src/Symfony/Component/Security/Core/Exception/AccountExpiredException.php index f899b1b76baeb..a5618ce6219ba 100644 --- a/src/Symfony/Component/Security/Core/Exception/AccountExpiredException.php +++ b/src/Symfony/Component/Security/Core/Exception/AccountExpiredException.php @@ -15,7 +15,15 @@ * AccountExpiredException is thrown when the user account has expired. * * @author Fabien Potencier + * @author Alexander */ class AccountExpiredException extends AccountStatusException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Account has expired.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php index 958f584f4ead9..7819e4dd09f5a 100644 --- a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php +++ b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php @@ -11,12 +11,57 @@ namespace Symfony\Component\Security\Core\Exception; +use Symfony\Component\Security\Core\User\UserInterface; + /** * AccountStatusException is the base class for authentication exceptions * caused by the user account status. * * @author Fabien Potencier + * @author Alexander */ abstract class AccountStatusException extends AuthenticationException { + private $user; + + /** + * Get the user. + * + * @return UserInterface + */ + public function getUser() + { + return $this->user; + } + + /** + * Set the user. + * + * @param UserInterface $user + */ + public function setUser(UserInterface $user) + { + $this->user = $user; + } + + /** + * {@inheritDoc} + */ + public function serialize() + { + return serialize(array( + $this->user, + parent::serialize(), + )); + } + + /** + * {@inheritDoc} + */ + public function unserialize($str) + { + list($this->user, $parentData) = unserialize($str); + + parent::unserialize($parentData); + } } diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php index 16686ade1096f..633b2bee9269c 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php @@ -16,7 +16,15 @@ * because no Token is available. * * @author Fabien Potencier + * @author Alexander */ class AuthenticationCredentialsNotFoundException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Authentication credentials could not be found.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php index 074dad094b74e..2b897c251302c 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php @@ -11,36 +11,42 @@ namespace Symfony\Component\Security\Core\Exception; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + /** * AuthenticationException is the base class for all authentication exceptions. * * @author Fabien Potencier + * @author Alexander */ class AuthenticationException extends \RuntimeException implements \Serializable { - private $extraInformation; - - public function __construct($message, $extraInformation = null, $code = 0, \Exception $previous = null) - { - parent::__construct($message, $code, $previous); + private $token; - $this->extraInformation = $extraInformation; - } - - public function getExtraInformation() + /** + * Get the token. + * + * @return TokenInterface + */ + public function getToken() { - return $this->extraInformation; + return $this->token; } - public function setExtraInformation($extraInformation) + /** + * Set the token. + * + * @param TokenInterface $token + */ + public function setToken(TokenInterface $token) { - $this->extraInformation = $extraInformation; + $this->token = $token; } public function serialize() { return serialize(array( - $this->extraInformation, + $this->token, $this->code, $this->message, $this->file, @@ -51,11 +57,31 @@ public function serialize() public function unserialize($str) { list( - $this->extraInformation, + $this->token, $this->code, $this->message, $this->file, $this->line ) = unserialize($str); } + + /** + * Message key to be used by the translation component. + * + * @return string + */ + public function getMessageKey() + { + return 'An authentication exception occurred.'; + } + + /** + * Message data to be used by the translation component. + * + * @return array + */ + public function getMessageData() + { + return array(); + } } diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php index 5b32d8110f10e..758a4f024501e 100644 --- a/src/Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php +++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php @@ -15,7 +15,15 @@ * AuthenticationServiceException is thrown when an authentication request could not be processed due to a system problem. * * @author Fabien Potencier + * @author Alexander */ class AuthenticationServiceException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Authentication request could not be processed due to a system problem.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/BadCredentialsException.php b/src/Symfony/Component/Security/Core/Exception/BadCredentialsException.php index 2eae5b811dc5d..5deecca9b301e 100644 --- a/src/Symfony/Component/Security/Core/Exception/BadCredentialsException.php +++ b/src/Symfony/Component/Security/Core/Exception/BadCredentialsException.php @@ -15,11 +15,15 @@ * BadCredentialsException is thrown when the user credentials are invalid. * * @author Fabien Potencier + * @author Alexander */ class BadCredentialsException extends AuthenticationException { - public function __construct($message, $code = 0, \Exception $previous = null) + /** + * {@inheritDoc} + */ + public function getMessageKey() { - parent::__construct($message, null, $code, $previous); + return 'Invalid credentials.'; } } diff --git a/src/Symfony/Component/Security/Core/Exception/CookieTheftException.php b/src/Symfony/Component/Security/Core/Exception/CookieTheftException.php index 2ada78d73b0f3..8d9e1549448e1 100644 --- a/src/Symfony/Component/Security/Core/Exception/CookieTheftException.php +++ b/src/Symfony/Component/Security/Core/Exception/CookieTheftException.php @@ -16,7 +16,15 @@ * detects that a presented cookie has already been used by someone else. * * @author Johannes M. Schmitt + * @author Alexander */ class CookieTheftException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Cookie has already been used by someone else.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php b/src/Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php index a4d42c842f739..b9bf2d158aef5 100644 --- a/src/Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php +++ b/src/Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php @@ -15,7 +15,15 @@ * CredentialsExpiredException is thrown when the user account credentials have expired. * * @author Fabien Potencier + * @author Alexander */ class CredentialsExpiredException extends AccountStatusException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Credentials have expired.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/DisabledException.php b/src/Symfony/Component/Security/Core/Exception/DisabledException.php index fd26221502ecf..5571ab14a9c7f 100644 --- a/src/Symfony/Component/Security/Core/Exception/DisabledException.php +++ b/src/Symfony/Component/Security/Core/Exception/DisabledException.php @@ -15,7 +15,15 @@ * DisabledException is thrown when the user account is disabled. * * @author Fabien Potencier + * @author Alexander */ class DisabledException extends AccountStatusException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Account is disabled.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php index bbf5517dce8df..74fc2b9b64206 100644 --- a/src/Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php @@ -17,7 +17,15 @@ * This is the case when a user is anonymous and the resource to be displayed has an access role. * * @author Fabien Potencier + * @author Alexander */ class InsufficientAuthenticationException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Not privileged to request the resource.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php b/src/Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php index 4181bacc01a87..ce0e1f410eb88 100644 --- a/src/Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php +++ b/src/Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php @@ -15,7 +15,15 @@ * This exception is thrown when the csrf token is invalid. * * @author Johannes M. Schmitt + * @author Alexander */ class InvalidCsrfTokenException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Invalid CSRF token.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/LockedException.php b/src/Symfony/Component/Security/Core/Exception/LockedException.php index 6fa0b778f7fd0..6532f70a5357c 100644 --- a/src/Symfony/Component/Security/Core/Exception/LockedException.php +++ b/src/Symfony/Component/Security/Core/Exception/LockedException.php @@ -15,7 +15,15 @@ * LockedException is thrown if the user account is locked. * * @author Fabien Potencier + * @author Alexander */ class LockedException extends AccountStatusException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Account is locked.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/NonceExpiredException.php b/src/Symfony/Component/Security/Core/Exception/NonceExpiredException.php index 6a6a7811e3c91..da6fba82b70d2 100644 --- a/src/Symfony/Component/Security/Core/Exception/NonceExpiredException.php +++ b/src/Symfony/Component/Security/Core/Exception/NonceExpiredException.php @@ -18,7 +18,15 @@ * the digest nonce has expired. * * @author Fabien Potencier + * @author Alexander */ class NonceExpiredException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Digest nonce has expired.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php index e11c8aa161f61..ea2b1fdf1f3a4 100644 --- a/src/Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php +++ b/src/Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php @@ -16,7 +16,15 @@ * supports an authentication Token. * * @author Fabien Potencier + * @author Alexander */ class ProviderNotFoundException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'No authentication provider found to support the authentication token.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/SessionUnavailableException.php b/src/Symfony/Component/Security/Core/Exception/SessionUnavailableException.php index 519164a323bd6..4b47b189efc2a 100644 --- a/src/Symfony/Component/Security/Core/Exception/SessionUnavailableException.php +++ b/src/Symfony/Component/Security/Core/Exception/SessionUnavailableException.php @@ -21,7 +21,15 @@ * request. * * @author Johannes M. Schmitt + * @author Alexander */ class SessionUnavailableException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'No session available, it either timed out or cookies are not enabled.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/TokenNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/TokenNotFoundException.php index 593f3ad2690e8..fb85abf0cf595 100644 --- a/src/Symfony/Component/Security/Core/Exception/TokenNotFoundException.php +++ b/src/Symfony/Component/Security/Core/Exception/TokenNotFoundException.php @@ -1,5 +1,4 @@ + * @author Alexander */ class TokenNotFoundException extends AuthenticationException { + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'No token could be found.'; + } } diff --git a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php index 38533e7ff3182..f656bacc6b603 100644 --- a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php +++ b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php @@ -15,7 +15,58 @@ * UsernameNotFoundException is thrown if a User cannot be found by its username. * * @author Fabien Potencier + * @author Alexander */ class UsernameNotFoundException extends AuthenticationException { + private $username; + + /** + * {@inheritDoc} + */ + public function getMessageKey() + { + return 'Username could not be found.'; + } + + /** + * Get the username. + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Set the username. + * + * @param string $username + */ + public function setUsername($username) + { + $this->username = $username; + } + + /** + * {@inheritDoc} + */ + public function serialize() + { + return serialize(array( + $this->username, + parent::serialize(), + )); + } + + /** + * {@inheritDoc} + */ + public function unserialize($str) + { + list($this->username, $parentData) = unserialize($str); + + parent::unserialize($parentData); + } } diff --git a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php index 376ba1c724046..3ff1ea9372383 100644 --- a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php @@ -44,7 +44,9 @@ public function loadUserByUsername($username) } } - throw new UsernameNotFoundException(sprintf('There is no user with name "%s".', $username)); + $ex = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $username)); + $ex->setUsername($username); + throw $ex; } /** @@ -66,7 +68,9 @@ public function refreshUser(UserInterface $user) } if ($supportedUserFound) { - throw new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername())); + $ex = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername())); + $ex->setUsername($user->getUsername()); + throw $ex; } else { throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user))); } diff --git a/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php b/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php index bd748044879af..e87f80c10af09 100644 --- a/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php @@ -68,7 +68,10 @@ public function createUser(UserInterface $user) public function loadUserByUsername($username) { if (!isset($this->users[strtolower($username)])) { - throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); + $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); + $ex->setUsername($username); + + throw $ex; } $user = $this->users[strtolower($username)]; diff --git a/src/Symfony/Component/Security/Core/User/UserChecker.php b/src/Symfony/Component/Security/Core/User/UserChecker.php index 93897a1010a41..8dde3a6670383 100644 --- a/src/Symfony/Component/Security/Core/User/UserChecker.php +++ b/src/Symfony/Component/Security/Core/User/UserChecker.php @@ -33,7 +33,9 @@ public function checkPreAuth(UserInterface $user) } if (!$user->isCredentialsNonExpired()) { - throw new CredentialsExpiredException('User credentials have expired.', $user); + $ex = new CredentialsExpiredException('User credentials have expired.'); + $ex->setUser($user); + throw $ex; } } @@ -47,15 +49,21 @@ public function checkPostAuth(UserInterface $user) } if (!$user->isAccountNonLocked()) { - throw new LockedException('User account is locked.', $user); + $ex = new LockedException('User account is locked.'); + $ex->setUser($user); + throw $ex; } if (!$user->isEnabled()) { - throw new DisabledException('User account is disabled.', $user); + $ex = new DisabledException('User account is disabled.'); + $ex->setUser($user); + throw $ex; } if (!$user->isAccountNonExpired()) { - throw new AccountExpiredException('User account has expired.', $user); + $ex = new AccountExpiredException('User account has expired.'); + $ex->setUser($user); + throw $ex; } } } diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index f134f9c819de5..99389ef5a51a2 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -106,7 +106,9 @@ public function onKernelException(GetResponseForExceptionEvent $event) } try { - $response = $this->startAuthentication($request, new InsufficientAuthenticationException('Full authentication is required to access this resource.', $token, 0, $exception)); + $insufficientAuthenticationException = new InsufficientAuthenticationException('Full authentication is required to access this resource.', 0, $exception); + $insufficientAuthenticationException->setToken($token); + $response = $this->startAuthentication($request, $insufficientAuthenticationException); } catch (\Exception $e) { $event->setException($e); diff --git a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php index bd828f265cc2b..5a66fe4539945 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php @@ -43,7 +43,7 @@ protected function processAutoLoginCookie(array $cookieParts, Request $request) $user = $this->getUserProvider($class)->loadUserByUsername($username); } catch (\Exception $ex) { if (!$ex instanceof AuthenticationException) { - $ex = new AuthenticationException($ex->getMessage(), null, $ex->getCode(), $ex); + $ex = new AuthenticationException($ex->getMessage(), $ex->getCode(), $ex); } throw $ex; diff --git a/src/Symfony/Component/Security/Resources/translations/security.en.xlf b/src/Symfony/Component/Security/Resources/translations/security.en.xlf new file mode 100644 index 0000000000000..3640698ce9fb3 --- /dev/null +++ b/src/Symfony/Component/Security/Resources/translations/security.en.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + An authentication exception occurred. + + + Authentication credentials could not be found. + Authentication credentials could not be found. + + + Authentication request could not be processed due to a system problem. + Authentication request could not be processed due to a system problem. + + + Invalid credentials. + Invalid credentials. + + + Cookie has already been used by someone else. + Cookie has already been used by someone else. + + + Not privileged to request the resource. + Not privileged to request the resource. + + + Invalid CSRF token. + Invalid CSRF token. + + + Digest nonce has expired. + Digest nonce has expired. + + + No authentication provider found to support the authentication token. + No authentication provider found to support the authentication token. + + + No session available, it either timed out or cookies are not enabled. + No session available, it either timed out or cookies are not enabled. + + + No token could be found. + No token could be found. + + + Username could not be found. + Username could not be found. + + + Account has expired. + Account has expired. + + + Credentials have expired. + Credentials have expired. + + + Account is disabled. + Account is disabled. + + + Account is locked. + Account is locked. + + + + diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php index c57967bfa4f8a..12eb568a29be9 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/AuthenticationProviderManagerTest.php @@ -37,7 +37,7 @@ public function testAuthenticateWhenNoProviderSupportsToken() $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); $this->fail(); } catch (ProviderNotFoundException $e) { - $this->assertSame($token, $e->getExtraInformation()); + $this->assertSame($token, $e->getToken()); } } @@ -51,7 +51,7 @@ public function testAuthenticateWhenProviderReturnsAccountStatusException() $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); $this->fail(); } catch (AccountStatusException $e) { - $this->assertSame($token, $e->getExtraInformation()); + $this->assertSame($token, $e->getToken()); } } @@ -65,7 +65,7 @@ public function testAuthenticateWhenProviderReturnsAuthenticationException() $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); $this->fail(); } catch (AuthenticationException $e) { - $this->assertSame($token, $e->getExtraInformation()); + $this->assertSame($token, $e->getToken()); } }