Send http request.

@param array $credentials

@return ResponseInterface

@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
962895
protected function sendRequest(array $credentials): ResponseInterface
    {
        $options = [
            ('GET' === $this->requestMethod) ? 'query' : 'json' => $credentials,
        ];

        return $this->setHttpClient($this->app['http_client'])->request($this->getEndpoint(), $this->requestMethod, $options);
    }
242829
protected function doFindIdentityMatch(array $credentials)
    {
        ErrorStack::handleError(E_WARNING); // {
            $hFile = fopen($this->getPwdFilePath(), 'r');
        $error = ErrorStack::handleDone();  // }

        if ($hFile === false)
            throw new \RuntimeException("Cannot open '{$this->getPwdFilePath()}' for reading", 0, $error);


        $username = $this->getUsername();
        $password = $this->getPassword();
        if (!isset($username))
            throw new exMissingCredential('Adapter Credential not contains Username.');

        $realm = $this->getRealm();

        $id       = "$username:$realm";
        while (($line = fgets($hFile)) !== false) 
        {
            $line = trim($line);
            
            if (substr($line, 0, strlen($id)) !== $id)
                ## try next (user:realm) not match
                continue;

            if (!isset($password)) {
                // just username match, digest http authorization need secret key (A1)
                $identity = new IdentityHttpDigest;
                $identity->setUsername($username);
                $a1Hash = substr($line, strlen($id)+1 /* +1 for : */);
                if (strlen($a1Hash) !== 32) continue; // it seems invalid a1hash just continue; if match others.
                $identity->setA1(strtolower($a1Hash));

                return $identity;
            }

            if (isset($password)
                ## 32 for md5 length
                && strtolower(substr($line, -32)) === strtolower(md5("$username:$realm:$password"))
            ) {
                ## user/pass credential match
                $identity = new IdentityUsername;
                $identity->setUsername($username);

                return $identity;
            }
        }

        return false;
    }
947808
public function retrieveByCredentials(array $credentials)
    {
        $criteria = [];
        foreach ($credentials as $key => $value) {
            if (!Str::contains($key, 'password')) {
                $criteria[$key] = $value;
            }
        }

        return $this->getRepository()->findOneBy($criteria);
    }
400998
protected function send(array $args = [])
    {
        $this->log->debug('send()ing command', $args);
        $response = RespUtils::deserialize($this->stream->write(RespUtils::serialize($args)));
        $this->log->debug('response', [$response]);
        return $response;
    }
664217
public function sendRequest(array $data): ResponseInterface
    {
        $options[RequestOptions::BODY] = $this->encodingService->encodeJson($data);

        return $this->send($options);
    }
1089001
public function sendResetLink(array $credentials): string
    {
        // First we will check to see if we found a user at the given credentials and
        // if we did not we will redirect back to this current URI with a piece of
        // "flash" data in the session to indicate to the developers the errors.
        $user = $this->getUser($credentials);

        if (is_null($user)) {
            return static::INVALID_USER;
        }

        $expiration = now()->addMinutes($this->expiration)->timestamp;

        // Once we have the reset token, we are ready to send the message out to this
        // user with a link to reset their password. We will then redirect back to
        // the current URI having nothing set in the session to indicate errors.
        $user->sendPasswordResetNotification($this->createToken($user, $expiration), $expiration);

        return static::RESET_LINK_SENT;
    }
1100656
protected function validateReset(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateNewPassword($credentials)) {
            return static::INVALID_PASSWORD;
        }

        if (! $this->validateToken($user, $credentials)) {
            return static::INVALID_TOKEN;
        }

        if (! $this->validateTimestamp($credentials['expiration'])) {
            return static::EXPIRED_TOKEN;
        }

        return $user;
    }
315019
public function sendRawRequest(array $params)
    {
        $rawResponse = $this->performRequest($params);
        $result = $this->parseResponse($rawResponse);

        return $result;
    }
427686
public function retrieveByCredentials(array $credentials)
	{
		if (Authorizer::validateAccessToken(false, $credentials[$this->token_key])) {
			$user_id = Authorizer::getResourceOwnerId();

			return $this->retrieveById($user_id);
		}

		return null;
	}
440332
public function verify($credentials)
    {
        if(!array_key_exists("jwt", $credentials) || empty($credentials["jwt"])) {
            throw new \Exception("JWT is required");
        }

        // Make sure we have a secret key to decode the JWT
        if(!array_key_exists("secret_key", $credentials) || empty($credentials["secret_key"])) {
            throw new \Exception("Secret Key is required to decode this JWT");
        }

        // Get hash alg from params, default to HS256
        $hashAlgs = array("HS256");
        if(array_key_exists("hash_alg", $credentials) && !empty($credentials["hash_alg"])) {
            $hashAlgs[] = $credentials["hash_alg"];
            $hashAlgs = array_unique($hashAlgs);
        }

        $token = JWT::decode($credentials["jwt"], $credentials["secret_key"], $hashAlgs);

        // User ID is a good checksum to make sure we have a valid JWT
        if(empty($token) || empty($token->id)) {
            throw new \Exception("JWT Token invalid");
        }

        return $token;
    }
823975
public function sendAllAsync(array $requests)
    {
        return $this->httpClient->sendAsync($this->createRequest(
            RequestInterface::BATCH,
            $this->getBatchRequestOptions($requests)
        ))->then(function (ResponseInterface $response) {
            return $this->getBatchResponses($response);
        });
    }
654619
public function authenticate(array $credentials)
	{
		[$username, $password] = $credentials;

		$ldap = $this->ldap->ldap_connect($this->server, $this->port);
		$this->ldap->ldap_set_option($ldap); //Set LDAP_OPT_PROTOCOL_VERSION (default 3)

		$res = ldap_bind($ldap, $this->user, $this->password);
		if (!$res) {
			throw new \Exception(self::ERROR_MESSAGE_LDAP_BIND);
		}

		$res = $this->ldap->ldap_search($ldap, $this->dn, $this->searchString($username));
		if ($this->ldap->ldap_count_entries($ldap, $res) !== 1) {
			throw new Nette\Security\AuthenticationException(self::ERROR_MESSAGE_AUTH_USER, self::IDENTITY_NOT_FOUND);
		}

		$entry = $this->ldap->ldap_first_entry($ldap, $res);
		$dn = $this->ldap->ldap_get_dn($ldap, $entry);

		//bind na prihlasovaneho uzivatele
		$res = $this->ldap->ldap_bind($ldap, $dn, $password);
		if (!$res) {
			throw new Nette\Security\AuthenticationException(self::ERROR_MESSAGE_AUTH_PASS, self::INVALID_CREDENTIAL);
		}
	}
1356712
public function authenticate(array $credentials): Identity
	{
		list($username, $password) = $credentials;

		$user = $this->orm->users->getByUsername($username);

		if (!$user) {
			throw new AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
		} elseif (!Passwords::verify($password, $user->password)) {
			throw new AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
		} elseif (!$user->active) {
			throw new AuthenticationException('Account is deactivated.', self::NOT_APPROVED);
		} elseif (Passwords::needsRehash($user->password)) {
			$user->setPassword($password);
			$this->orm->persistAndFlush($user);
		}

		return new Identity($user->id);
	}
550783
public function setAuthentication(array $credentials): AbstractClientBuilder
    {
        if (array_key_exists('session_id', $credentials)) {
            $this->authentication = new HeaderAuthenticate($credentials['session_id']);
        } elseif (array_key_exists('username', $credentials) && array_key_exists('password', $credentials)) {
            $this->authentication = new HeaderLogin($credentials['username'], $credentials['password']);
        } else {
            throw new \InvalidArgumentException('No credentials given.');
        }

        return $this;
    }
202287
public function connect($credentials = [])
    {
        if ($diff = array_diff(array_keys($this->settings), array_keys($credentials))) {
            throw new \Exception("Missing credentials, the following fields are missing ".implode('/', $diff));
        }

        $this->settings = array_merge($this->settings, $credentials);

        if (isset($this->settings['port']) === false) {
            $this->settings['port'] = 143;
        }

        $this->conn = @imap_open('{'.$this->settings['server'].':'.$this->settings['port'].'/notls}',
            $this->settings['username'], $this->settings['password']);

        if ($this->conn == false) {
            throw new \Exception("Could not connect or authorize to ".$this->settings['server'].':'.$this->settings['port']);
        }

        return ($this->conn != null);
    }
164717
public function authenticate(array $credentials)
	{
		list($email, $password) = $credentials;

		/** @var ActiveRow $row */
		$row = $this->model->getTableSelection()->where(self::COLUMN_NAME, $email)->fetch();

		if (!$row || !Passwords::verify($password, $row[self::COLUMN_PASSWORD_HASH])) {
			throw new Nette\Security\AuthenticationException('Špatné přihlašovací údaje', self::INVALID_CREDENTIAL);
		} elseif (Passwords::needsRehash($row[self::COLUMN_PASSWORD_HASH])) {
			$row->update(array(
				self::COLUMN_PASSWORD_HASH => Passwords::hash($password),
			));
		}

		$arr    = $row->toArray();
		$rules = json_decode($arr['rules'], true);

		unset($arr[self::COLUMN_PASSWORD_HASH], $arr['rules'], $arr[self::COLUMN_ROLE]);
		return new Nette\Security\Identity($row[self::COLUMN_ID], array_merge([$row[self::COLUMN_ROLE]], $rules), $arr);
	}
520712
public function send(RequestInterface $request, array $options = [])
    {
        $response = parent::send($request, $options);

        // re-authenticate if 403 and token is expired
        if (
            $this->token &&
            $response->getStatusCode() === 403 &&
            $this->isTokenExpired($this->token) &&
            !$this->authenticate()
        ) {
            throw new ClientException('Cannot re-authenticate.');
        }

        $this->checkResponse($response);

        return $response;
    }