AuthenticationException.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Core\Exception;
  11. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  12. /**
  13. * AuthenticationException is the base class for all authentication exceptions.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. * @author Alexander <iam.asm89@gmail.com>
  17. */
  18. class AuthenticationException extends \RuntimeException implements \Serializable
  19. {
  20. private $token;
  21. /**
  22. * Get the token.
  23. *
  24. * @return TokenInterface
  25. */
  26. public function getToken()
  27. {
  28. return $this->token;
  29. }
  30. public function setToken(TokenInterface $token)
  31. {
  32. $this->token = $token;
  33. }
  34. public function serialize()
  35. {
  36. return serialize(array(
  37. $this->token,
  38. $this->code,
  39. $this->message,
  40. $this->file,
  41. $this->line,
  42. ));
  43. }
  44. public function unserialize($str)
  45. {
  46. list(
  47. $this->token,
  48. $this->code,
  49. $this->message,
  50. $this->file,
  51. $this->line
  52. ) = unserialize($str);
  53. }
  54. /**
  55. * Message key to be used by the translation component.
  56. *
  57. * @return string
  58. */
  59. public function getMessageKey()
  60. {
  61. return 'An authentication exception occurred.';
  62. }
  63. /**
  64. * Message data to be used by the translation component.
  65. *
  66. * @return array
  67. */
  68. public function getMessageData()
  69. {
  70. return array();
  71. }
  72. }