[Security] Add getMessageKey and getMessageData to auth exceptions

This commit is contained in:
Alexander 2012-07-15 15:16:07 +02:00
parent 694c47ce96
commit ed6eed4c36
12 changed files with 106 additions and 2 deletions

View File

@ -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 'security.exception.authentication_credentials_not_found_exception';
}
}

View File

@ -52,4 +52,24 @@ class AuthenticationException extends \RuntimeException implements \Serializable
$this->line
) = unserialize($str);
}
/**
* Message key to be used by the translation component.
*
* @return string
*/
public function getMessageKey()
{
return 'security.exception.authentication_exception';
}
/**
* Message data to be used by the translation component.
*
* @return array
*/
public function getMessageData()
{
return array();
}
}

View File

@ -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 'security.exception.authentication_service_exception';
}
}

View File

@ -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 'security.exception.bad_credentials_exception';
}
}

View File

@ -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 'security.exception.cookie_theft_exception';
}
}

View File

@ -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 'security.exception.insufficient_authentication_exception';
}
}

View File

@ -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 'security.exception.invalid_csrf_token_exception';
}
}

View File

@ -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 'security.exception.nonce_expired_exception';
}
}

View File

@ -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 'security.exception.provider_not_found_exception';
}
}

View File

@ -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 'security.exception.session_unavailable_exception';
}
}

View File

@ -14,7 +14,15 @@ 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 'security.exception.token_not_found_exception';
}
}

View File

@ -15,7 +15,15 @@ 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
{
/**
* {@inheritDoc}
*/
public function getMessageKey()
{
return 'security.exception.username_not_found_exception';
}
}