vendor/symfony/security-core/Exception/AuthenticationException.php line 29

Open in your IDE?
  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
  19. {
  20.     /** @internal */
  21.     protected $serialized;
  22.     private ?TokenInterface $token null;
  23.     public function __construct(string $message ''int $code 0\Throwable $previous null)
  24.     {
  25.         unset($this->serialized);
  26.         parent::__construct($message$code$previous);
  27.     }
  28.     public function getToken(): ?TokenInterface
  29.     {
  30.         return $this->token;
  31.     }
  32.     public function setToken(TokenInterface $token)
  33.     {
  34.         $this->token $token;
  35.     }
  36.     /**
  37.      * Returns all the necessary state of the object for serialization purposes.
  38.      *
  39.      * There is no need to serialize any entry, they should be returned as-is.
  40.      * If you extend this method, keep in mind you MUST guarantee parent data is present in the state.
  41.      * Here is an example of how to extend this method:
  42.      * <code>
  43.      *     public function __serialize(): array
  44.      *     {
  45.      *         return [$this->childAttribute, parent::__serialize()];
  46.      *     }
  47.      * </code>
  48.      *
  49.      * @see __unserialize()
  50.      */
  51.     public function __serialize(): array
  52.     {
  53.         return [$this->token$this->code$this->message$this->file$this->line];
  54.     }
  55.     /**
  56.      * Restores the object state from an array given by __serialize().
  57.      *
  58.      * There is no need to unserialize any entry in $data, they are already ready-to-use.
  59.      * If you extend this method, keep in mind you MUST pass the parent data to its respective class.
  60.      * Here is an example of how to extend this method:
  61.      * <code>
  62.      *     public function __unserialize(array $data): void
  63.      *     {
  64.      *         [$this->childAttribute, $parentData] = $data;
  65.      *         parent::__unserialize($parentData);
  66.      *     }
  67.      * </code>
  68.      *
  69.      * @see __serialize()
  70.      */
  71.     public function __unserialize(array $data): void
  72.     {
  73.         [$this->token$this->code$this->message$this->file$this->line] = $data;
  74.     }
  75.     /**
  76.      * Message key to be used by the translation component.
  77.      *
  78.      * @return string
  79.      */
  80.     public function getMessageKey()
  81.     {
  82.         return 'An authentication exception occurred.';
  83.     }
  84.     /**
  85.      * Message data to be used by the translation component.
  86.      */
  87.     public function getMessageData(): array
  88.     {
  89.         return [];
  90.     }
  91.     /**
  92.      * @internal
  93.      */
  94.     public function __sleep(): array
  95.     {
  96.         $this->serialized $this->__serialize();
  97.         return ['serialized'];
  98.     }
  99.     /**
  100.      * @internal
  101.      */
  102.     public function __wakeup(): void
  103.     {
  104.         $this->__unserialize($this->serialized);
  105.         unset($this->serialized);
  106.     }
  107. }