vendor/lexik/jwt-authentication-bundle/Security/Authentication/Token/JWTUserToken.php line 28

Open in your IDE?
  1. <?php
  2. namespace Lexik\Bundle\JWTAuthenticationBundle\Security\Authentication\Token;
  3. use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
  4. use Symfony\Component\Security\Core\User\UserInterface;
  5. use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
  6. if (interface_exists(GuardTokenInterface::class)) {
  7.     /**
  8.      * Compatibility layer ensuring the guard token interface is applied when available.
  9.      *
  10.      * @internal
  11.      */
  12.     abstract class JWTCompatUserToken extends AbstractToken implements GuardTokenInterface {}
  13. } else {
  14.     /**
  15.      * @internal
  16.      */
  17.     abstract class JWTCompatUserToken extends AbstractToken {}
  18. }
  19. /**
  20.  * JWTUserToken.
  21.  *
  22.  * @author Nicolas Cabot <n.cabot@lexik.fr>
  23.  */
  24. class JWTUserToken extends JWTCompatUserToken
  25. {
  26.     /**
  27.      * @var string
  28.      */
  29.     protected $rawToken;
  30.     /**
  31.      * @var string
  32.      */
  33.     protected $providerKey;
  34.     /**
  35.      * {@inheritdoc}
  36.      */
  37.     public function __construct(array $roles = [], UserInterface $user null$rawToken null$firewallName null)
  38.     {
  39.         parent::__construct($roles);
  40.         if ($user) {
  41.             $this->setUser($user);
  42.         }
  43.         $this->setRawToken($rawToken);
  44.         if (method_exists($this'setAuthenticated')) {
  45.             $this->setAuthenticated(true);
  46.         }
  47.         $this->providerKey $firewallName;
  48.     }
  49.     /**
  50.      * @param string $rawToken
  51.      */
  52.     public function setRawToken($rawToken)
  53.     {
  54.         $this->rawToken $rawToken;
  55.     }
  56.     /**
  57.      * {@inheritdoc}
  58.      */
  59.     public function getCredentials()
  60.     {
  61.         return $this->rawToken;
  62.     }
  63.     /**
  64.      * @deprecated since 2.10, use getFirewallName() instead
  65.      */
  66.     public function getProviderKey()
  67.     {
  68.         @trigger_error(sprintf('The "%s" method is deprecated since version 2.10 and will be removed in 3.0. Use "%s::getFirewallName()" instead.'__METHOD__self::class), E_USER_DEPRECATED);
  69.         return $this->getFirewallName();
  70.     }
  71.     /**
  72.      * @return string
  73.      */
  74.     public function getFirewallName()
  75.     {
  76.         return $this->providerKey;
  77.     }
  78. }