vendor/symfony/security-core/Authentication/Token/RememberMeToken.php line 21

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\Authentication\Token;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. /**
  13.  * Authentication Token for "Remember-Me".
  14.  *
  15.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  16.  */
  17. class RememberMeToken extends AbstractToken
  18. {
  19.     private string $secret;
  20.     private string $firewallName;
  21.     /**
  22.      * @param string $secret A secret used to make sure the token is created by the app and not by a malicious client
  23.      *
  24.      * @throws \InvalidArgumentException
  25.      */
  26.     public function __construct(UserInterface $userstring $firewallNamestring $secret)
  27.     {
  28.         parent::__construct($user->getRoles());
  29.         if (empty($secret)) {
  30.             throw new \InvalidArgumentException('$secret must not be empty.');
  31.         }
  32.         if ('' === $firewallName) {
  33.             throw new \InvalidArgumentException('$firewallName must not be empty.');
  34.         }
  35.         $this->firewallName $firewallName;
  36.         $this->secret $secret;
  37.         $this->setUser($user);
  38.     }
  39.     public function getFirewallName(): string
  40.     {
  41.         return $this->firewallName;
  42.     }
  43.     public function getSecret(): string
  44.     {
  45.         return $this->secret;
  46.     }
  47.     /**
  48.      * {@inheritdoc}
  49.      */
  50.     public function __serialize(): array
  51.     {
  52.         return [$this->secret$this->firewallNameparent::__serialize()];
  53.     }
  54.     /**
  55.      * {@inheritdoc}
  56.      */
  57.     public function __unserialize(array $data): void
  58.     {
  59.         [$this->secret$this->firewallName$parentData] = $data;
  60.         $parentData \is_array($parentData) ? $parentData unserialize($parentData);
  61.         parent::__unserialize($parentData);
  62.     }
  63. }