@param TenantInterface|null       $tenant
@param TokenStorageInterface|null $tokenStorage

@return void
8602
private function setTenant(?TenantInterface $tenant, ?TokenStorageInterface $tokenStorage): void
    {
        if ($tenant !== null) {
            $this->tenant = $tenant;
        } elseif ($tokenStorage !== null) {
            $token = $tokenStorage->getToken();

            if ($token !== null) {
                $tenant = $token->getUser();

                if ($tenant instanceof TenantInterface) {
                    $this->tenant = $tenant;
                }
            }
        } else {
            throw new \RuntimeException('Can\'t get tenant');
        }
    }
376330
protected function setTokenStorage(array $tokenStorage): self
    {
        $this->getSessionStorage()->offsetSet($this->getTokenStorageKey(), $tokenStorage);

        return $this;
    }
431217
public function verify($token, $identifier = null)
    {
        $identifier = ($identifier !== null) ? $identifier : $this->identifier;

        // Throw error for empty token or empty identifier, because the server will not handle this
        if (empty($token)) {
            throw new BackupCode\EmptyTokenException();
        }
        if (empty($identifier)) {
            throw new BackupCode\EmptyIdentifierException();
        }

        $this->sendApiCall(self::ACTION_RETRIEVE, sprintf('%s/%s?token=%s', $this->getCreateUrl(), urlencode($identifier), $token));
    }
603973
public function setCredentials(
        RepositoryReference $repositoryReference,
        TokenUUID $tokenUUID
    ) {
        parent::setCredentials($repositoryReference, $tokenUUID);
        $this
            ->repository
            ->setCredentials($repositoryReference, $tokenUUID);
    }
42182
@Override
    public void store(OAuthToken token, String envKey) {
        oAuthToken.put(envKey, token);
    }
306679
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (! $event->isMasterRequest()) {
            return;
        }

        $currentClient = Hub::getCurrent()->getClient();
        if (null === $currentClient || ! $currentClient->getOptions()->shouldSendDefaultPii()) {
            return;
        }

        $token = null;

        if ($this->tokenStorage instanceof TokenStorageInterface) {
            $token = $this->tokenStorage->getToken();
        }

        if (
            null !== $token
            && null !== $this->authorizationChecker
            && $token->isAuthenticated()
            && $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED)
        ) {
            $userData = $this->getUserData($token->getUser());
        }

        $userData['ip_address'] = $event->getRequest()->getClientIp();

        Hub::getCurrent()
            ->configureScope(function (Scope $scope) use ($userData): void {
                $scope->setUser($userData);
            });
    }
224988
public function refreshData($token, $data=null)
    {
        $key = $token;
        
        if ($key) {
            $data = static::formatData($data);
            
            $sdata = static::getStorage()->get($key);
            
            if ($sdata) {
                $data = array_merge($sdata, $data);
            }
            
            $data['_expire_time_'] = time() + static::getExpire();
            
            static::getStorage()->set($key, $data);
        }
    }
665589
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        $restUrl = $input->getArgument('rest-url');

        /** @var TenantInterface $tenant */
        if ($input->getOption('tenant-id')) {
            $tenant = $this->em->getRepository($this->tenantClass)->find($input->getOption('tenant-id'));
        } elseif ($input->getOption('client-key')) {
            /** @noinspection PhpUndefinedMethodInspection */
            $tenant = $this->em->getRepository($this->tenantClass)->findOneByClientKey($input->getOption('client-key'));
        } else {
            throw new \RuntimeException('Please provide client-key or tenant-id');
        }

        $request = new AtlassianRestClient($tenant);
        $json = $request->get($restUrl);

        $output->writeln('');
        echo \json_encode($json, \JSON_PRETTY_PRINT);
        $output->writeln('');
    }
468455
public function findRequiredTokens(FinderInterface $finder, array $tokenCollection)
    {
        foreach ($tokenCollection as $fileTokens) {
            if (!$fileTokens->hasTokens()) {
                continue;
            }
            $file = $this->plugin->directory.'/'.$fileTokens->file;

            if (!file_exists($file)) {
                $this->addWarning(sprintf('Skipping validation of missing or optional file: %s', $fileTokens->file));
                continue;
            }

            try {
                $finder->findTokens($file, $fileTokens);
                $this->addMessagesFromTokens($finder->getType(), $fileTokens);
            } catch (\Exception $e) {
                $this->addError($e->getMessage());
            }
        }
    }
121258
public function store(ImageFormRequest $request, Tenant $tenant): void
    {
        $tenant->addMediaFromRequest('file')
               ->sanitizingFileName(function ($fileName) {
                   return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION);
               })
               ->toMediaCollection('default', config('cortex.tenants.media.disk'));
    }
1168362
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition($this->tokenStorageService)) {
            return;
        }
        $tokenStorage = new Reference($this->tokenStorageService);

        $commands = [
            ExecuteTaskCommand::class,
            ReducePathCommand::class,
            GeneratePathCommand::class,
            ReduceBugCommand::class,
            CaptureScreenshotsCommand::class,
        ];
        foreach ($commands as $command) {
            $commandDefinition = $container->getDefinition($command);
            $commandDefinition->addMethodCall('setTokenStorage', [$tokenStorage]);
        }
    }
289869
public function setInternalAuthToken($tenantKey, $internalAuthToken)
    {
        if ($this->tenantTokens[$tenantKey] == null) {
            $this->tenantTokens[$tenantKey] = array();
        }
        $this->tenantTokens[$tenantKey]['internalAuthToken'] = $internalAuthToken;
    }
1286320
public function addToken(Token $token)
    {
        $this->tokens[$this->getAppKey()][$token->getTokenUUID()->composeUUID()] = $token;
    }
837275
public function setTokenIntoSession()
    {
        $token = $this->getRandomToken();

        if (empty($this->storage->csrf_tokens)) {
            $this->storage->csrf_tokens = [];
        }

        $this->storage->csrf_tokens = [trim($token) => true];

        $this->token = $token;
    }
214311
public function sendPasswordNotification($token, $request)
    {
        $this->notify(new SetPasswordNotification($token, $request->tenant, $request->site));
    }
748689
public function readByValue(string $tokenValue, int $expirationInSeconds): ?TokenInterface
    {
        $schema = $this->getDatabaseSchema();
        return $this->readEnabledTokenByColumnWithExpirationCheck(
            $tokenValue,
            $schema->getTokensValueColumn(),
            $expirationInSeconds,
            $schema->getTokensValueCreatedAtColumn()
        );
    }
954460
public function readByRefresh(string $refreshValue, int $expirationInSeconds): ?TokenInterface
    {
        $schema = $this->getDatabaseSchema();
        return $this->readEnabledTokenByColumnWithExpirationCheck(
            $refreshValue,
            $schema->getTokensRefreshColumn(),
            $expirationInSeconds,
            $schema->getTokensRefreshCreatedAtColumn()
        );
    }