Loads the user for the given public API key.

@param string $publicApiKey The username

@return UserInterface

@throws UsernameNotFoundException if the user is not found
966323
public function loadUserByPublicKey($publicApiKey)
    {
        if (null === $user = $this->findOneBy(array('_api_key_public' => $publicApiKey))) {
            throw new UsernameNotFoundException(sprintf('Unknown public API key `%s`.', $publicApiKey));
        }

        return $this->checkActivatedStatus($user);
    }
716531
public function validateKey()
    {
        try {
            $this->api->get('');
        } catch (\Exception $e) {
            if (starts_with($e->getMessage(), '{')) {
                $json = json_decode($e->getMessage());
                if ($json->status == 401) {
                    throw new InvalidApiKey($json->detail);
                }
            }

            throw $e;
        }
    }
887279
public function loadUserByUsername($username)
    {
        if ($username !== 'testUsername') {
            return false;
        }

        /** @var UserInterface $user */
        $user = new \stdClass();
        $user->id = 123;
        $user->username = $username;
        $user->firstName = 'aName';
        $user->lastName = 'aSurname';

        return $user;
    }
193350
public function getPublicKey()
    {
        $cached = $this->getCache('publicKey');
        if (!empty($cached)) {
            return $cached;
        }

        $wellKnown = $this->getWellKnown();
        if (empty($wellKnown->jwks_uri)) {
            return null;
        }

        try {
            $response = $this->client->get($wellKnown->jwks_uri);
        } catch (RequestException $e) {
            $this->lastException = $e;
            return null;
        }

        $jwks = json_decode($response->getBody());
        if (empty($jwks->keys[0]->x5c[0])) {
            return null;
        }

        $X509 = new X509();
        if (!$X509->loadX509($jwks->keys[0]->x5c[0])) {
            return null;
        }

        $key = (string)$X509->getPublicKey();

        $this->setCache('publicKey', $key);

        return $key;
    }
1209855
public function loadUserByAPIUser(User $apiUser)
    {
        $eZSyliusUser = $this->eZUserRepository->findOneBy(
            array(
                'eZUserId' => $apiUser->getUserId(),
                'syliusUserType' => $this->syliusUserType,
            )
        );

        if (!$eZSyliusUser instanceof EzSyliusUser) {
            return null;
        }

        return $this->syliusUserRepository->find(
            $eZSyliusUser->getSyliusUserId()
        );
    }
422674
public static PublicKey loadPublicKey(byte[] keyBytes) {
        X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(keyBytes);

        try {
            KeyFactory factory = KeyFactory.getInstance(KEY_ALGORITHM);
            PublicKey publicKey = factory.generatePublic(x509EncodedKeySpec);
            return publicKey;
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
1100192
protected function getKey($userid, $apikey, $scope, $name, $args)
    {
        $key = implode('|', compact('userid', 'apikey', 'scope', 'name'));

        foreach ($args as $k => $v) {
            if (!in_array(strtolower($key), array('userid', 'apikey', 'keyid', 'vcode'))) {
                $key .= sprintf('|%s:%s', $k, $v);
            }
        }

        return sprintf('%s|%s', $this->options['prefix'], $key);
    }
458137
public function load(string $key, string $useragent = ''): array
    {
        if (!$this->initData->hasItem($key)) {
            throw new NotFoundException('the browser with key "' . $key . '" was not found');
        }

        $browserData = $this->initData->getItem($key);

        if (null === $browserData) {
            throw new NotFoundException('the browser with key "' . $key . '" was not found');
        }

        $engineKey = $browserData->engine;
        $engine    = null;

        if (null !== $engineKey) {
            try {
                $engine = $this->engineParser->load($engineKey, $useragent);
            } catch (NotFoundException $e) {
                $this->logger->warning($e);
            }
        }

        $browser = (new BrowserFactory($this->companyLoader, new VersionFactory(), new TypeLoader()))->fromArray($this->logger, (array) $browserData, $useragent);

        return [$browser, $engine];
    }
763563
public function loadUser(string $name): UserInterface
    {
        foreach ($this->loaders as $loader) {
            try {
                return $loader->loadUser($name);
            } catch (UserNotFoundException $e) {
                continue;
            }
        }
        
        throw new UserNotFoundException("This user '{$name}' cannot be loaded over registered loaders into UserLoaderCollection");
    }
149292
public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface
    {
        $token = $this->userProvider->getDecodedToken($credentials['jwt']);
        $clientKey = $token->iss;

        if (!$clientKey) {
            throw new AuthenticationException(
                \sprintf('API Key "%s" does not exist.', $credentials['jwt'])
            );
        }

        /** @var TenantInterface|UserInterface $user */
        $user = $this->userProvider->loadUserByUsername($clientKey);
        if (\property_exists($token, 'sub')) {
            // for some reasons, when webhooks are called - field sub is undefined
            $user->setUsername($token->sub);
        }

        return $user;
    }
607959
public function getUser()
    {
        if (is_null($this->user)) {
            /**
             * @var \OxidEsales\PayPalModule\Core\Exception\PayPalMissingParameterException $exception
             */
            $exception = oxNew(\OxidEsales\PayPalModule\Core\Exception\PayPalMissingParameterException::class);
            throw $exception;
        }

        return $this->user;
    }
607374
protected function getUserFromPayload(array $payload)
    {
        if (!isset($payload[$this->userIdClaim])) {
            throw $this->createAuthenticationException();
        }

        return $this->userProvider->loadUserByUsername($payload[$this->userIdClaim]);
    }
801735
protected static function getApiKey($customApiKey=null)
	{
		//check if key was provided
		if ($customApiKey !== null) return $customApiKey;

		//otherwise lookup the key in the params or throw exception
		if (!isset(Yii::$app->params['api.google.key'])) {
			$msg = Yii::t('app', 'You need to set the google api key into your params (index: `api.google.key`)');
			throw new InvalidConfigException($msg);
		}

		return Yii::$app->params['api.google.key'];
	}
1354366
public function findUserByUserName(string $username): User
    {
        foreach ($this->userRepositories as $repository) {
            $user = $repository->findByUsername($username);

            if ($user) {
                return $user;
            }
        }

        throw UserNotFound::withUsername($username);
    }
334719
protected function findUser(OutputInterface $output, string $username): ?User
    {
        try {
            /** @var User $user */

            return $this->userManager->loadUserByUsername($username);
        } catch (UsernameNotFoundException $e) {
            $message = $this->translator->trans(
                'user.does_not_exists',
                ['%username%' => $username],
                'security'
            );
            $output->writeln("<error>{$message}</error>");

            return null;
        }
    }
146156
private function findUser($identifier)
    {
        try {
            $user = $this->getUserRepository()->findUserByIdentifier($identifier);
        } catch (NoResultException $exc) {
            throw new EntityNotFoundException($this->getUserRepository()->getClassName(), $identifier);
        }

        if (!$this->hasSystem($user)) {
            throw new UserNotInSystemException($this->getSystem(), $identifier);
        }

        return $user;
    }
1284545
public function user()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $user = null;

        // If a user ID was provided in the JWT, then
        // we should attempt to fetch their profile.
        if (! empty($this->id())) {
            $user = $this->provider->retrieveById($this->id());
        }

        return $this->user = $user;
    }