getCredentials.

@param InputInterface  $input
@param OutputInterface $output

@return array
511568
protected function getCredentials(InputInterface $input, OutputInterface $output)
    {
        if (null !== $connection = $input->getOption('connection')) {
            $file = rtrim(getenv('HOME'), '/').'/.rabbitmq_admin_toolkit';
            if (!file_exists($file)) {
                throw new \InvalidArgumentException('Can\'t use connection option without a ~/.rabbitmq_admin_toolkit file');
            }
            $credentials = json_decode(file_get_contents($file), true);
            if (!isset($credentials[$connection])) {
                throw new \InvalidArgumentException("Connection $connection not found in ~/.rabbitmq_admin_toolkit");
            }

            $defaultCredentials = [
                'host' => '127.0.0.1',
                'port' => 15672,
                'user' => 'root',
                'password' => 'root',
            ];

            return array_merge($defaultCredentials, $credentials[$connection]);
        }

        $credentials = [
            'host' => $input->getOption('host'),
            'port' => $input->getOption('port'),
            'user' => $input->getOption('user'),
        ];

        if ($input->hasParameterOption(['--password', '-p'])) {
            $credentials['password'] = $input->getOption('password');
        } elseif (null === $input->getOption('password')) {
            $question = new Question('<question>Password?</question>');
            $question->setHidden(true);

            $credentials['password'] = $this->getHelperSet()->get('question')->ask($input, $output, $question);
        }

        return $credentials;
    }
677976
public function retrieveByCredentials(array $credentials)
    {
        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // generic "user" object that will be utilized by the Guard instances.
        $query = array();
        $coll = $this->conn->{$this->table};

        foreach ($credentials as $key => $value)
        {
            if ( ! str_contains($key, 'password'))
            {
                $query[$key] = $value;
            }
        }

        // Now we are ready to execute the query to see if we have an user matching
        // the given credentials. If not, we will just return nulls and indicate
        // that there are no matching users for these given credential arrays.
        $user = $coll->findOne($query);

        if ( ! is_null($user))
        {
            return new MongolUser((array) $user);
        }
    }
346397
protected function getOptions(InputInterface $input)
    {
        return [
            'dir'    => (bool) $input->getOption('fix_dir'),
            'file'   => (bool) $input->getOption('fix_file'),
            'skip'   => (bool) $input->getOption('skip_dir_file'),
            'strict' => (bool) $input->getOption('strict_types'),
        ];
    }
144243
protected function getListCredential()
    {
        $options = $this->query_filter;
        $options['limit'] = $this->data_limit;

        return $this->credential->getList($options);
    }
1122322
protected function findGApiAccessTokenFileValue(InputInterface $input, OutputInterface $output): ?string
    {

        $needToParseConfigFile = false;


        $gApiAccessTokenFile = $this->getGApiAccessTokenFileOption($input);
        if ($gApiAccessTokenFile === null) {
            $needToParseConfigFile = true;
            if ($output->isVerbose()) {
                $output->writeln('The access token file path is not specified, will try to get the path from a configuration file');
            }
        }

        // If the API file paths are not specified, find and read a configuration file
        if ($needToParseConfigFile) {
            if(!$this->isGApiAuthConfigOptionsFindable($output)){
                return null;
            }

            if ($gApiAccessTokenFile === null && $this->findGApiAccessTokenFileConfig($output)) {
                $gApiAccessTokenFile = $this->findGApiAccessTokenFileConfig($output);
            }
        }

        return $gApiAccessTokenFile;
    }
1039327
public function getServerCredentials($connection = null, $server = 0)
    {
        $connection = $this->sanitizeConnection($connection);
        $servers = $this->getServersCredentials($connection);

        return (array) Arr::get($servers, $server ?: $connection->server);
    }
141558
protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $username = $this->getUsername($input, $output);
        if ($input->getOption('if-not-exists')) {
            try {
                $user = $this->userManager->loadUserByUsername($username);
            } catch (\Exception $e) {
                $user = null;
            }
            if ($user) {
                $message = $this->translator->trans(
                    'user.already_exists',
                    [
                        '%username%' => $username,
                    ],
                    'security'
                );
                $output->writeln("<comment>{$message}</comment>");

                return 0;
            }
        }

        try {
            $user = $this->userManager->createUser($username);
        } catch (BadUsernameException $e) {
            $output->writeln("<error>{$e->getMessage()}</error>");

            return 1;
        }

        $user->setSuperAdmin($input->getOption('admin'));
        $password = $this->getPassword($input, $output);
        if ($password) {
            $this->userManager->setPlainTextPassword($user, $password);
        }
        $this->userManager->save($user);

        $message = $this->translator->trans('user.created_success', ['%username%' => $username], 'security');
        $output->writeln("<info>{$message}</info>");

        return 0;
    }
952891
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<info>Following strategies to extract an authentication key are available:</info>');
        $output->writeln(
            "<info>\t* " .
            implode(PHP_EOL . "\t* ", $this->strategies) .
            "</info>"
        );
    }
175890
public function findByCredentials(array $credentials)
	{
		$model     = $this->createModel();
		$loginName = $model->getLoginName();

		if ( ! array_key_exists($loginName, $credentials))
		{
			throw new \InvalidArgumentException("Login attribute [$loginName] was not provided.");
		}

		$passwordName = $model->getPasswordName();

		$query              = $model->newQuery();
		$hashableAttributes = $model->getHashableAttributes();
		$hashedCredentials  = array();

		// build query from given credentials
		foreach ($credentials as $credential => $value)
		{
			// Remove hashed attributes to check later as we need to check these
			// values after we retrieved them because of salts
			if (in_array($credential, $hashableAttributes))
			{
				$hashedCredentials = array_merge($hashedCredentials, array($credential => $value));
			}
			else
			{
				$query = $query->where($credential, '=', $value);
			}
		}

		if ( ! $user = $query->first())
		{
			throw new UserNotFoundException("A user was not found with the given credentials.");
		}

		// Now check the hashed credentials match ours
		foreach ($hashedCredentials as $credential => $value)
		{
			if ( ! $this->hasher->checkhash($value, $user->{$credential}))
			{
				$message = "A user was found to match all plain text credentials however hashed credential [$credential] did not match.";

				if ($credential == $passwordName)
				{
					throw new WrongPasswordException($message);
				}

				throw new UserNotFoundException($message);
			}
			else if ($credential == $passwordName)
			{
				if (method_exists($this->hasher, 'needsRehashed') && 
					$this->hasher->needsRehashed($user->{$credential}))
				{
					// The algorithm used to create the hash is outdated and insecure.
					// Rehash the password and save.
					$user->{$credential} = $value;
					$user->save();
				}
			}
		}

		return $user;
	}
705981
private function getStsWithInternalCredentials($region)
    {
        if ($this->useHostCredentials) {
            return $this->aws->createSts([
                'region' => $region,
                'credentials' => $this->hostCredentials,
            ]);
        }

        $credentials = $this->em
            ->getRepository(Credential::class)
            ->findOneBy(['isInternal' => true, 'name' => $this->credentialName]);

        if (!$credentials instanceof Credential) {
            $this->logger->critical(sprintf(self::ERR_INVALID_INTERNAL_CREDENTIALS, $this->credentialName));
            return null;
        }

        if (!$credentials->details() instanceof AWSStaticCredential) {
            $this->logger->critical(sprintf(self::ERR_INVALID_INTERNAL_CREDENTIALS, $this->credentialName));
            return null;
        }

        if (!$internalCredentials = $this->getStaticCredentials($credentials->details())) {
            return null;
        }

        return $this->aws->createSts([
            'region' => $region,
            'credentials' => $internalCredentials,
        ]);
    }
157685
public function getRequestCredentials()
    {
        if ($this->requestCredentials === null) {
            $this->requestCredentials = function () {
                $credentials = [];

                if (isset($_SERVER['PHP_AUTH_USER'])) {
                    $credentials['login'] = $_SERVER['PHP_AUTH_USER'];
                }

                if (isset($_SERVER['PHP_AUTH_PW'])) {
                    $credentials['password'] = $_SERVER['PHP_AUTH_PW'];
                }

                if (count($credentials) > 0) {
                    return $credentials;
                }
            };
        }

        $credentials = $this->requestCredentials;

        return $credentials();
    }
1041112
protected function getSites(InputInterface $input)
    {
        $parameters = [];
        $identifiers = $input->getOption('site');

        if ('all' !== current($identifiers)) {
            $parameters['id'] = 1 === \count($identifiers) ? current($identifiers) : $identifiers;
        }

        return $this->getSiteManager()->findBy($parameters);
    }
910022
protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $username = $this->getUsername($input, $output);
        $user = $this->findUser($output, $username);
        if (null === $user) {
            return 1;
        }

        $password = $this->getPassword($input, $output);
        if ($password) {
            $this->userManager->setPlainTextPassword($user, $password);
        } else {
            $this->userManager->requestNewPassword($user);
        }
        $this->userManager->save($user);

        if ($password) {
            $message = $this->translator->trans(
                'user.password_changed_success',
                ['%username%' => $username],
                'security'
            );
        } else {
            $message = $this->translator->trans(
                'user.password_request_sent',
                ['%username%' => $username],
                'security'
            );
        }
        $output->writeln("<info>{$message}</info>");

        return 0;
    }
822142
public function getCredential($key)
    {
        return !isset($this->credentials[$key]) ? null : $this->credentials[$key];
    }
908002
public static function getParameters($input): array
    {
        try {
            $reflectionMethod = self::getCallableReflectionMethod($input);
        } catch (ReflectionException $e) {
            return [];
        }

        foreach ($reflectionMethod->getParameters() as $index => $param) {
            $reflectionParameters[$index]['name'] = $param->getName();
            if (null !== $param->getClass()) {
                $reflectionParameters[$index]['class'] = $param->getClass()->name;
            }
        }

        return $reflectionParameters ?? [];
    }
371813
public function retrieveByCredentials(array $credentials)
    {
        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // Eloquent User "model" that will be utilized by the Guard instances.
        $query = $this->createModel()->newQuery();

        foreach ($credentials as $key => $value) {
            if ( ! str_contains($key, 'user_pass')) {
                $query->where($key, $value);
            }
        }

        return $query->first();
    }
97819
protected function getCredentials()
    {
        if (empty($this->username) || empty($this->password)) {
            throw new \Exception('Basic authentication requires a $username & $password property.');
        }

        return [$this->username, $this->password];
    }