Skip to content

Commit

Permalink
[Security] Add getMessageKey and getMessageData to auth exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
asm89 committed Jan 7, 2013
1 parent 694c47c commit ed6eed4
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,24 @@ public function unserialize($str)
$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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <fabien@symfony.com>
* @author Alexander <iam.asm89@gmail.com>
*/
class InsufficientAuthenticationException extends AuthenticationException
{
/**
* {@inheritDoc}
*/
public function getMessageKey()
{
return 'security.exception.insufficient_authentication_exception';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
* 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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
* 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';
}
}

0 comments on commit ed6eed4

Please sign in to comment.