vendor/symfony/security-core/Authentication/AuthenticationTrustResolver.php line 24

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;
  11. use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
  12. use Symfony\Component\Security\Core\Authentication\Token\NullToken;
  13. use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
  14. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  15. /**
  16.  * The default implementation of the authentication trust resolver.
  17.  *
  18.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  19.  */
  20. class AuthenticationTrustResolver implements AuthenticationTrustResolverInterface
  21. {
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function isAnonymous(TokenInterface $token null)
  26.     {
  27.         if (null === $token) {
  28.             return false;
  29.         }
  30.         return $token instanceof AnonymousToken || $token instanceof NullToken;
  31.     }
  32.     /**
  33.      * {@inheritdoc}
  34.      */
  35.     public function isRememberMe(TokenInterface $token null)
  36.     {
  37.         if (null === $token) {
  38.             return false;
  39.         }
  40.         return $token instanceof RememberMeToken;
  41.     }
  42.     /**
  43.      * {@inheritdoc}
  44.      */
  45.     public function isFullFledged(TokenInterface $token null)
  46.     {
  47.         if (null === $token) {
  48.             return false;
  49.         }
  50.         return !$this->isAnonymous($token) && !$this->isRememberMe($token);
  51.     }
  52. }