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

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.     private $token;
  21.     /**
  22.      * Get the token.
  23.      *
  24.      * @return TokenInterface|null
  25.      */
  26.     public function getToken()
  27.     {
  28.         return $this->token;
  29.     }
  30.     public function setToken(TokenInterface $token)
  31.     {
  32.         $this->token $token;
  33.     }
  34.     /**
  35.      * Returns all the necessary state of the object for serialization purposes.
  36.      *
  37.      * There is no need to serialize any entry, they should be returned as-is.
  38.      * If you extend this method, keep in mind you MUST guarantee parent data is present in the state.
  39.      * Here is an example of how to extend this method:
  40.      * <code>
  41.      *     public function __serialize(): array
  42.      *     {
  43.      *         return [$this->childAttribute, parent::__serialize()];
  44.      *     }
  45.      * </code>
  46.      *
  47.      * @see __unserialize()
  48.      */
  49.     public function __serialize(): array
  50.     {
  51.         return [$this->token$this->code$this->message$this->file$this->line];
  52.     }
  53.     /**
  54.      * {@inheritdoc}
  55.      *
  56.      * @final since Symfony 4.3, use __serialize() instead
  57.      *
  58.      * @internal since Symfony 4.3, use __serialize() instead
  59.      */
  60.     public function serialize()
  61.     {
  62.         $serialized $this->__serialize();
  63.         if (null === $isCalledFromOverridingMethod = \func_num_args() ? func_get_arg(0) : null) {
  64.             $trace debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT2);
  65.             $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
  66.         }
  67.         return $isCalledFromOverridingMethod $serialized serialize($serialized);
  68.     }
  69.     /**
  70.      * Restores the object state from an array given by __serialize().
  71.      *
  72.      * There is no need to unserialize any entry in $data, they are already ready-to-use.
  73.      * If you extend this method, keep in mind you MUST pass the parent data to its respective class.
  74.      * Here is an example of how to extend this method:
  75.      * <code>
  76.      *     public function __unserialize(array $data): void
  77.      *     {
  78.      *         [$this->childAttribute, $parentData] = $data;
  79.      *         parent::__unserialize($parentData);
  80.      *     }
  81.      * </code>
  82.      *
  83.      * @see __serialize()
  84.      */
  85.     public function __unserialize(array $data): void
  86.     {
  87.         [$this->token$this->code$this->message$this->file$this->line] = $data;
  88.     }
  89.     /**
  90.      * {@inheritdoc}
  91.      *
  92.      * @final since Symfony 4.3, use __unserialize() instead
  93.      *
  94.      * @internal since Symfony 4.3, use __unserialize() instead
  95.      */
  96.     public function unserialize($serialized)
  97.     {
  98.         $this->__unserialize(\is_array($serialized) ? $serialized unserialize($serialized));
  99.     }
  100.     /**
  101.      * @internal
  102.      */
  103.     public function __sleep()
  104.     {
  105.         if (__CLASS__ !== $c = (new \ReflectionMethod($this'serialize'))->getDeclaringClass()->name) {
  106.             @trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3, implement the __serialize() and __unserialize() methods instead.'$c), E_USER_DEPRECATED);
  107.             $this->serialized $this->serialize();
  108.         } else {
  109.             $this->serialized $this->__serialize();
  110.         }
  111.         return ['serialized'];
  112.     }
  113.     /**
  114.      * @internal
  115.      */
  116.     public function __wakeup()
  117.     {
  118.         if (__CLASS__ !== $c = (new \ReflectionMethod($this'unserialize'))->getDeclaringClass()->name) {
  119.             @trigger_error(sprintf('Implementing the "%s::unserialize()" method is deprecated since Symfony 4.3, implement the __serialize() and __unserialize() methods instead.'$c), E_USER_DEPRECATED);
  120.             $this->unserialize($this->serialized);
  121.         } else {
  122.             $this->__unserialize($this->serialized);
  123.         }
  124.         unset($this->serialized);
  125.     }
  126.     /**
  127.      * Message key to be used by the translation component.
  128.      *
  129.      * @return string
  130.      */
  131.     public function getMessageKey()
  132.     {
  133.         return 'An authentication exception occurred.';
  134.     }
  135.     /**
  136.      * Message data to be used by the translation component.
  137.      *
  138.      * @return array
  139.      */
  140.     public function getMessageData()
  141.     {
  142.         return [];
  143.     }
  144. }