@param \CosmonovaRnD\JWT\Token\TokenInterface $token

@return bool
@throws \CosmonovaRnD\JWT\Exception\NotSupportedAlgorithmException
344545
public function verify(TokenInterface $token): bool
    {
        $signer = $this->factory->create($token->algorithm());
        $key    = new Key($this->verifyKey->content(), $this->verifyKey->passphrase());

        return $signer->verify($token->signature(), $token->payload(), $key);
    }
113785
protected function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $refreshedUser = $this->userProvider->refreshUser($user);
        $token->setUser($refreshedUser);

        return $token;
    }
489554
public function getSecurityIdentities(TokenInterface $token)
    {
        $sids = parent::getSecurityIdentities($token);

        if ($token->getUser() instanceof \BackBee\Security\User) {
            foreach ($token->getUser()->getGroups() as $group) {
                $securityIdentity = new UserSecurityIdentity($group->getObjectIdentifier(), ClassUtils::getRealClass($group));
                array_unshift($sids, $securityIdentity);
            }
        }

        return $sids;
    }
782058
protected function isOrganizationManager(TokenInterface $token, $object)
    {
        $adminOrganizations = $token->getUser()->getAdministratedOrganizations();
        $objectOrganizations = $object->getOrganizations();

        foreach ($adminOrganizations as $adminOrganization) {
            foreach ($objectOrganizations as $objectOrganization) {
                if ($objectOrganization === $adminOrganization) {
                    return true;
                }
            }
        }

        return false;
    }
1183920
private function tokenExists($token)
    {
        $tokenData = $this->getTokenData($token);
        if ($tokenData == false) {
            return false;
        }

        return $tokenData == false ? true : false;
    }
1344268
private function checkTokenForOnlyRule(RuleInterface $rule, $token): bool
    {
        $fitRuleRequirements = false;
        foreach ($rule->getRequirements() as $req) {
            if (false !== strpos($token, $req)) {
                $fitRuleRequirements = true;
            }
        }

        return $fitRuleRequirements;
    }
754059
protected function voteForReadAction($subject, TokenInterface $token)
    {
        $contentType = $subject;
        if (is_object($subject)) {
            $contentType = $subject->getContentType();
        }

        return $this->isSubjectInPerimeter($contentType, $token->getUser(), ContentTypeInterface::ENTITY_TYPE);
    }
1047549
protected function _setToken($token)
    {
        if ($token !== null && !($token instanceof TokenInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid token'), null, null, $token);
        }

        $this->token = $token;
    }
86100
private function isAdminToken($providerKey, TokenInterface $token = null)
    {
        return is_callable([$token, 'getProviderKey']) && $token->getProviderKey() === $providerKey;
    }
581743
public function canEditPwsPerm(TokenInterface $token)
    {
        if ($this->container->get('security.context')->isGranted('ROLE_ADMIN')) return true;

        $roles = $this->roleManager->getStringRolesFromToken($token);
        $accesses = $this->om
            ->getRepository('ClarolineCoreBundle:Resource\PwsRightsManagementAccess')
            ->findByRoles($roles);

        foreach ($accesses as $access) {
            if ($access->isAccessible()) return true;
        }

        return false;
    }
1304303
public function createToken(TokenInterface $token): TokenInterface
    {
        try {
            $now        = $this->ignoreException(function (): DateTimeImmutable {
                return new DateTimeImmutable();
            });
            $schema     = $this->getDatabaseSchema();
            $hasRefresh = $token->getRefreshValue() !== null;
            $values     = $hasRefresh === false ? [
                $schema->getTokensClientIdentityColumn() => $token->getClientIdentifier(),
                $schema->getTokensUserIdentityColumn()   => $token->getUserIdentifier(),
                $schema->getTokensValueColumn()          => $token->getValue(),
                $schema->getTokensTypeColumn()           => $token->getType(),
                $schema->getTokensIsScopeModified()      => $token->isScopeModified(),
                $schema->getTokensIsEnabledColumn()      => $token->isEnabled(),
                $schema->getTokensValueCreatedAtColumn() => $now,
            ] : [
                $schema->getTokensClientIdentityColumn()   => $token->getClientIdentifier(),
                $schema->getTokensUserIdentityColumn()     => $token->getUserIdentifier(),
                $schema->getTokensValueColumn()            => $token->getValue(),
                $schema->getTokensTypeColumn()             => $token->getType(),
                $schema->getTokensIsScopeModified()        => $token->isScopeModified(),
                $schema->getTokensIsEnabledColumn()        => $token->isEnabled(),
                $schema->getTokensValueCreatedAtColumn()   => $now,
                $schema->getTokensRefreshColumn()          => $token->getRefreshValue(),
                $schema->getTokensRefreshCreatedAtColumn() => $now,
            ];

            $tokenIdentifier = null;
            if (empty($scopeIdentifiers = $token->getScopeIdentifiers()) === false) {
                $this->inTransaction(function () use ($values, $scopeIdentifiers, &$tokenIdentifier) {
                    $this->createResource($values);
                    $tokenIdentifier = $this->getLastInsertId();
                    $this->bindScopeIdentifiers($tokenIdentifier, $scopeIdentifiers);
                });
            } else {
                $this->createResource($values);
                $tokenIdentifier = $this->getLastInsertId();
            }

            $token->setIdentifier($tokenIdentifier)->setValueCreatedAt($now);
            if ($hasRefresh === true) {
                $token->setRefreshCreatedAt($now);
            }

            return $token;
        } catch (RepositoryException $exception) {
            $message = 'Token creation failed';
            throw new RepositoryException($message, 0, $exception);
        }
    }
164004
public function onAuthenticationSuccess( Request $request, TokenInterface $token )
	{
		// if AJAX login
		if ( ! $request->isXmlHttpRequest() ) {
			throw new NotFoundHttpException('Must use AJAX Login');
		}

		return new JsonResponse(array(
			"success" => true
		));
	}
1136984
public function contains(string $token): bool
    {
        $this->tokenize();
        return in_array($token, $this->tokens);
    }
875581
public function isValid($token)
    {
        try {
            $publicKey = openssl_pkey_get_public(file_get_contents($this->projectDir . '/var/jwt/public.pem'));

            $jws = SimpleJWS::load($token);

            return $jws->verify($publicKey, self::ALG) && $this->isTokenNotExpired($token);
        } catch (\InvalidArgumentException $ex) {
            return false;
        }
    }
1020197
public function exists(RemindableInterface $user, $token)
	{
		$email = $user->getReminderEmail();

		$reminder = $this->getTable()->where('email', $email)->where('token', $token)->first();

		return $reminder && ! $this->reminderExpired($reminder);
	}
116269
public function authenticate(TokenInterface $token)
    {
        if (!$token instanceof GuardTokenInterface) {
            throw new \InvalidArgumentException('GuardAuthenticationProvider only supports GuardTokenInterface.');
        }

        if (!$token instanceof PreAuthenticationGuardToken) {
            /*
             * The listener *only* passes PreAuthenticationGuardToken instances.
             * This means that an authenticated token (e.g. PostAuthenticationGuardToken)
             * is being passed here, which happens if that token becomes
             * "not authenticated" (e.g. happens if the user changes between
             * requests). In this case, the user should be logged out, so
             * we will return an AnonymousToken to accomplish that.
             */

            // this should never happen - but technically, the token is
            // authenticated... so it could just be returned
            if ($token->isAuthenticated()) {
                return $token;
            }

            // this AccountStatusException causes the user to be logged out
            throw new AuthenticationExpiredException();
        }

        $guardAuthenticator = $this->findOriginatingAuthenticator($token);

        if (null === $guardAuthenticator) {
            throw new AuthenticationException(sprintf('Token with provider key "%s" did not originate from any of the guard authenticators of provider "%s".', $token->getGuardProviderKey(), $this->providerKey));
        }

        return $this->authenticateViaGuard($guardAuthenticator, $token);
    }
1236657
protected function setBaseApiUri(TokenInterface $token)
    {
        // Make request uri.
        $endpoint = 'https://login.mailchimp.com/oauth2/metadata?oauth_token=' . $token->getAccessToken();

        // Grab meta data about the token.
        $response = $this->httpRequest($endpoint, [], [], 'GET');

        // Parse JSON.
        $meta = json_decode($response, true);

        // Set base api uri.
        $this->baseApiUri = new Url('https://' . $meta[ 'dc' ] . '.api.mailchimp.com/{apiVersion}/');

        // Allow chaining.
        return $this;
    }