summaryrefslogtreecommitdiffstats
path: root/Core/Exception
diff options
context:
space:
mode:
Diffstat (limited to 'Core/Exception')
-rw-r--r--Core/Exception/AccountExpiredException.php8
-rw-r--r--Core/Exception/AccountStatusException.php45
-rw-r--r--Core/Exception/AuthenticationCredentialsNotFoundException.php8
-rw-r--r--Core/Exception/AuthenticationException.php54
-rw-r--r--Core/Exception/AuthenticationServiceException.php8
-rw-r--r--Core/Exception/BadCredentialsException.php8
-rw-r--r--Core/Exception/CookieTheftException.php8
-rw-r--r--Core/Exception/CredentialsExpiredException.php8
-rw-r--r--Core/Exception/DisabledException.php8
-rw-r--r--Core/Exception/InsufficientAuthenticationException.php8
-rw-r--r--Core/Exception/InvalidCsrfTokenException.php8
-rw-r--r--Core/Exception/LockedException.php8
-rw-r--r--Core/Exception/NonceExpiredException.php8
-rw-r--r--Core/Exception/ProviderNotFoundException.php8
-rw-r--r--Core/Exception/SessionUnavailableException.php8
-rw-r--r--Core/Exception/TokenNotFoundException.php11
-rw-r--r--Core/Exception/UsernameNotFoundException.php51
17 files changed, 248 insertions, 17 deletions
diff --git a/Core/Exception/AccountExpiredException.php b/Core/Exception/AccountExpiredException.php
index f899b1b..a5618ce 100644
--- a/Core/Exception/AccountExpiredException.php
+++ b/Core/Exception/AccountExpiredException.php
@@ -15,7 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* AccountExpiredException is thrown when the user account has expired.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class AccountExpiredException extends AccountStatusException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Account has expired.';
+ }
}
diff --git a/Core/Exception/AccountStatusException.php b/Core/Exception/AccountStatusException.php
index 958f584..7819e4d 100644
--- a/Core/Exception/AccountStatusException.php
+++ b/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 <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
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/Core/Exception/AuthenticationCredentialsNotFoundException.php b/Core/Exception/AuthenticationCredentialsNotFoundException.php
index 16686ad..633b2be 100644
--- a/Core/Exception/AuthenticationCredentialsNotFoundException.php
+++ b/Core/Exception/AuthenticationCredentialsNotFoundException.php
@@ -16,7 +16,15 @@ namespace Symfony\Component\Security\Core\Exception;
* because no Token is available.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class AuthenticationCredentialsNotFoundException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Authentication credentials could not be found.';
+ }
}
diff --git a/Core/Exception/AuthenticationException.php b/Core/Exception/AuthenticationException.php
index 074dad0..2b897c2 100644
--- a/Core/Exception/AuthenticationException.php
+++ b/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 <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
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 @@ class AuthenticationException extends \RuntimeException implements \Serializable
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/Core/Exception/AuthenticationServiceException.php b/Core/Exception/AuthenticationServiceException.php
index 5b32d81..758a4f0 100644
--- a/Core/Exception/AuthenticationServiceException.php
+++ b/Core/Exception/AuthenticationServiceException.php
@@ -15,7 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* AuthenticationServiceException is thrown when an authentication request could not be processed due to a system problem.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class AuthenticationServiceException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Authentication request could not be processed due to a system problem.';
+ }
}
diff --git a/Core/Exception/BadCredentialsException.php b/Core/Exception/BadCredentialsException.php
index 2eae5b8..5deecca 100644
--- a/Core/Exception/BadCredentialsException.php
+++ b/Core/Exception/BadCredentialsException.php
@@ -15,11 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* BadCredentialsException is thrown when the user credentials are invalid.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
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/Core/Exception/CookieTheftException.php b/Core/Exception/CookieTheftException.php
index 2ada78d..8d9e154 100644
--- a/Core/Exception/CookieTheftException.php
+++ b/Core/Exception/CookieTheftException.php
@@ -16,7 +16,15 @@ namespace Symfony\Component\Security\Core\Exception;
* detects that a presented cookie has already been used by someone else.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class CookieTheftException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Cookie has already been used by someone else.';
+ }
}
diff --git a/Core/Exception/CredentialsExpiredException.php b/Core/Exception/CredentialsExpiredException.php
index a4d42c8..b9bf2d1 100644
--- a/Core/Exception/CredentialsExpiredException.php
+++ b/Core/Exception/CredentialsExpiredException.php
@@ -15,7 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* CredentialsExpiredException is thrown when the user account credentials have expired.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class CredentialsExpiredException extends AccountStatusException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Credentials have expired.';
+ }
}
diff --git a/Core/Exception/DisabledException.php b/Core/Exception/DisabledException.php
index fd26221..5571ab1 100644
--- a/Core/Exception/DisabledException.php
+++ b/Core/Exception/DisabledException.php
@@ -15,7 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* DisabledException is thrown when the user account is disabled.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class DisabledException extends AccountStatusException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Account is disabled.';
+ }
}
diff --git a/Core/Exception/InsufficientAuthenticationException.php b/Core/Exception/InsufficientAuthenticationException.php
index bbf5517..74fc2b9 100644
--- a/Core/Exception/InsufficientAuthenticationException.php
+++ b/Core/Exception/InsufficientAuthenticationException.php
@@ -17,7 +17,15 @@ namespace Symfony\Component\Security\Core\Exception;
* This is the case when a user is anonymous and the resource to be displayed has an access role.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class InsufficientAuthenticationException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Not privileged to request the resource.';
+ }
}
diff --git a/Core/Exception/InvalidCsrfTokenException.php b/Core/Exception/InvalidCsrfTokenException.php
index 4181bac..ce0e1f4 100644
--- a/Core/Exception/InvalidCsrfTokenException.php
+++ b/Core/Exception/InvalidCsrfTokenException.php
@@ -15,7 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* This exception is thrown when the csrf token is invalid.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class InvalidCsrfTokenException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Invalid CSRF token.';
+ }
}
diff --git a/Core/Exception/LockedException.php b/Core/Exception/LockedException.php
index 6fa0b77..6532f70 100644
--- a/Core/Exception/LockedException.php
+++ b/Core/Exception/LockedException.php
@@ -15,7 +15,15 @@ namespace Symfony\Component\Security\Core\Exception;
* LockedException is thrown if the user account is locked.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class LockedException extends AccountStatusException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Account is locked.';
+ }
}
diff --git a/Core/Exception/NonceExpiredException.php b/Core/Exception/NonceExpiredException.php
index 6a6a781..da6fba8 100644
--- a/Core/Exception/NonceExpiredException.php
+++ b/Core/Exception/NonceExpiredException.php
@@ -18,7 +18,15 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
* the digest nonce has expired.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class NonceExpiredException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Digest nonce has expired.';
+ }
}
diff --git a/Core/Exception/ProviderNotFoundException.php b/Core/Exception/ProviderNotFoundException.php
index e11c8aa..ea2b1fd 100644
--- a/Core/Exception/ProviderNotFoundException.php
+++ b/Core/Exception/ProviderNotFoundException.php
@@ -16,7 +16,15 @@ namespace Symfony\Component\Security\Core\Exception;
* supports an authentication Token.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class ProviderNotFoundException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'No authentication provider found to support the authentication token.';
+ }
}
diff --git a/Core/Exception/SessionUnavailableException.php b/Core/Exception/SessionUnavailableException.php
index 519164a..4b47b18 100644
--- a/Core/Exception/SessionUnavailableException.php
+++ b/Core/Exception/SessionUnavailableException.php
@@ -21,7 +21,15 @@ namespace Symfony\Component\Security\Core\Exception;
* request.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class SessionUnavailableException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'No session available, it either timed out or cookies are not enabled.';
+ }
}
diff --git a/Core/Exception/TokenNotFoundException.php b/Core/Exception/TokenNotFoundException.php
index 593f3ad..fb85abf 100644
--- a/Core/Exception/TokenNotFoundException.php
+++ b/Core/Exception/TokenNotFoundException.php
@@ -1,5 +1,4 @@
<?php
-namespace Symfony\Component\Security\Core\Exception;
/*
* This file is part of the Symfony package.
@@ -10,11 +9,21 @@ namespace Symfony\Component\Security\Core\Exception;
* file that was distributed with this source code.
*/
+namespace Symfony\Component\Security\Core\Exception;
+
/**
* TokenNotFoundException is thrown if a Token cannot be found.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
class TokenNotFoundException extends AuthenticationException
{
+ /**
+ * {@inheritDoc}
+ */
+ public function getMessageKey()
+ {
+ return 'No token could be found.';
+ }
}
diff --git a/Core/Exception/UsernameNotFoundException.php b/Core/Exception/UsernameNotFoundException.php
index 38533e7..f656bac 100644
--- a/Core/Exception/UsernameNotFoundException.php
+++ b/Core/Exception/UsernameNotFoundException.php
@@ -15,7 +15,58 @@ namespace Symfony\Component\Security\Core\Exception;
* UsernameNotFoundException is thrown if a User cannot be found by its username.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Alexander <iam.asm89@gmail.com>
*/
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);
+ }
}