Set the endpoint, username and password for next requests

@param string $xmlrpcEndPoint The wordpress XML-RPC endpoint
@param string $username       The client's username
@param string $password       The client's password

@since 2.4.0
349964
function setCredentials($xmlrpcEndPoint, $username, $password)
    {
        // prepend http protocol to the end point if needed
        $scheme = parse_url($xmlrpcEndPoint, PHP_URL_SCHEME);
        if (!$scheme) {
            $xmlrpcEndPoint = "http://{$xmlrpcEndPoint}";
        }

        // swith to https when working with wordpress.com blogs
        $host = parse_url($xmlrpcEndPoint, PHP_URL_HOST);
        if (substr($host, -14) == '.wordpress.com') {
            $xmlrpcEndPoint = preg_replace('|http://|', 'https://', $xmlrpcEndPoint, 1);
        }

        // save information
        $this->endPoint = $xmlrpcEndPoint;
        $this->username = $username;
        $this->password = $password;
    }
719299
public function login($username, $password)
    {
        $this->visit("wp-login.php");
        $currentPage = $this->getSession()->getPage();

        $currentPage->fillField('user_login', $username);
        $currentPage->fillField('user_pass', $password);
        $currentPage->findButton('wp-submit')->click();

        assertTrue($this->getSession()->getPage()->hasContent('Dashboard'));
    }
169018
public function setUsername($username, $password = null) {
		$this->username = (string) $username;
		
		if ($password !== null) {
			$this->setPassword($password);
		}
		
		return $this;
	}
1330885
public function amHttpAuthenticated($username, $password)
    {
        $this->client->setServerParameter('PHP_AUTH_USER', $username);
        $this->client->setServerParameter('PHP_AUTH_PW', $password);
    }
1056693
public function verify(string $username = null, string $password = null, string $user = null)
    {
        if ($username && $password) {
            $users = $this->getUsers($user);

            foreach ($users as $user => $credentials) {
                if (
                    password_verify($username, reset($credentials)) &&
                    password_verify($password, end($credentials))
                ) {
                    $this->currentUser = $user;

                    return;
                }
            }
        }

        throw new UnauthorizedHttpException('Basic');
    }
1005523
public function acquireTokenForUser($username, $password)
    {
        $this->provider = new SamlTokenProvider($this->authorityUrl);
        $parameters = array(
            'username' => $username,
            'password' => $password
        );
        $this->provider->acquireToken($parameters);
    }
956503
public function setAccount($prefix, $username, $password) {
		$this->credentialsName = $this->computeCredentialsName($prefix);
		// Looking for existing credentials
		$credentials = array();
		if ($auth = $this->get('auth')) {
			foreach($this->configuration['auth'] as $k => $v) {
				$pos = strrpos($k, '.'); $attr = substr($k, $pos + 1); $pref = substr($k, 0, $pos);
				if (!array_key_exists($pref, $credentials)) $credentials[$pref] = array();
				$credentials[$pref][$attr] = $v;
			}
		}
		if (count($credentials)) {
			foreach($credentials as $k => $auth) {
				if (isset($auth['prefix']) && $auth['prefix'] == $prefix) {
					$this->credentialsName = $k;
					if (isset($auth['username']) || isset($auth['password'])) {
						if (	isset($auth['username']) && ($auth['username'] == $username || !strlen($username))
							&&	isset($auth['password']) && ($auth['password'] == $password || !strlen($username))
							)
						{
							// Same user/password
							return $this;
						}
						else {
							// user/password DO NOT match
						}
					}
					else {
						// user/password not defined
					}
					$PHPHg = array("{$this->credentialsName}.prefix" => $auth['prefix']);
					if (isset($auth['username'])) $PHPHg["{$this->credentialsName}.username"] = $auth['username'];
					if (isset($auth['password'])) $PHPHg["{$this->credentialsName}.password"] = $auth['password'];
					$this->set(array('PHPHg' => $PHPHg))->save();
					break;
				}
			}
		}
		else {
			// no credentials
			$this->set(array('PHPHg' => array()))->save();
		}

		$this->set(array('auth' => array(
			"{$this->credentialsName}.prefix" => $prefix,
			"{$this->credentialsName}.username" => $username,
			"{$this->credentialsName}.password" => $password,
		)))->save();
		
		return $this;
    }
76950
public function setDigestAuthentication($username, $password = '')
    {
        $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
        $this->setOpt(CURLOPT_USERPWD, $username . ':' . $password);
    }
83818
public function setProxy($proxy, $username = null, $password = null){
        $this->proxy = $proxy;
        if($username != null && $password != null){
            $this->proxyCredentials = $username . ":" . $password;
        }
    }
669075
function user_password($username,$password){
        if ($username==NULL){ return (false); }
        if ($password==NULL){ return (false); }
        if (!$this->_bind){ return (false); }
        if (!$this->_use_ssl){ echo ("FATAL: SSL must be configured on your webserver and enabled in the class to set passwords."); exit(); }
        
        $user=$this->user_info($username,array("cn"));
        if ($user[0]["dn"]==NULL){ return (false); }
        $user_dn=$user[0]["dn"];
                
        $add=array();
        $add["unicodePwd"][0]=$this->encode_password($password);
        
        $result=ldap_mod_replace($this->_conn,$user_dn,$add);
        if ($result==false){ return (false); }
        
        return (true);
    }
1168037
protected function setEndpoint(string $endpoint)
    {
        $fullEndpoint = 'https://' . $endpoint . '/rpc';

        if (!empty($endpoint) && $fullEndpoint !== $this->endpoint) {
            $this->endpoint = $fullEndpoint;
        }
    }
1372547
public function resetPasswordRequest($username, $remoteIP, Event $event)
    {
        /** @var UsersRepository $repo */
        $repo = $this->em->getRepository(Entity\Users::class);
        /** @var Entity\Users $userEntity */
        $userEntity = $repo->getUser($username);

        if (!$userEntity) {
            // For safety, this is the message we display, regardless of whether user exists.
            $this->app['logger.flash']->clear();
            $this->app['logger.flash']->info(Trans::__('page.login.password-reset-link-sent', ['%user%' => $username]));
            $this->app['dispatcher']->dispatch(AccessControlEvents::RESET_FAILURE, $event);

            return false;
        }

        // Generate shadow password and hash
        $shadowPassword = $this->app['randomgenerator']->generateString(12);
        $shadowPasswordHash = $this->app['password_factory']->createHash($shadowPassword, '$2y$');

        // Generate shadow token and hash
        $shadowToken = $this->app['randomgenerator']->generateString(32);
        $shadowTokenHash = md5($shadowToken . '-' . str_replace('.', '-', $remoteIP));

        // Set the shadow password and related stuff in the database.
        $userEntity->setShadowpassword($shadowPasswordHash);
        $userEntity->setShadowtoken($shadowTokenHash);
        $userEntity->setShadowvalidity(Carbon::create()->addHours(2));

        $this->em->getRepository(Entity\Users::class)->save($userEntity);

        $mailoptions = $this->app['config']->get('general/mailoptions'); // PHP 5.4 compatibility
        if (empty($mailoptions)) {
            $this->app['logger.flash']->danger(Trans::__('general.phrase.error-mail-options-not-set'));
        }

        // Sent the password reset notification
        $this->resetPasswordNotification($userEntity, $shadowPassword, $shadowToken);
        $this->app['dispatcher']->dispatch(AccessControlEvents::RESET_REQUEST, $event);

        return true;
    }
368528
public function setBasicAuth( $username, $password )
	{
		$this->curl->setOption( CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
		$this->curl->setOption( CURLOPT_USERPWD, $username.":".$password );
	}
578454
@SuppressWarnings("unused")
    public void setSmtpAuth(String userName, String password) {
        setSmtpUsername(userName);
        setSmtpPassword(password);
    }
465737
public function setAuth($username, $password)
    {
        $this->connectionOptions[CURLOPT_USERPWD] = $username . ':' . $password;
        $this->connectionOptions[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
        return $this;
    }
139925
public function authenticate($username, $password) {

    // Get some things.
    $client = $this->getClient();
    $parameters = $this->getAuthParams();
    $endpoint = $this->getEndpoint();
    $code = NULL;

    $response = $client->get($endpoint,
      ['query' => $parameters, 'auth' => [$username, $password]]
    );

    $code = $response->getStatusCode();
    $this->setLastResponse($response);

    // @todo: handle non 200 responses with error logging.
    switch ($code) {
      case '200':
        $body = $response->getBody();
        $json = json_decode($body->getContents());
        if (empty($json)) {
          throw new \Exception("Could not get JSON from body.");
        }
        $this->setAuthApiToken($json->access_token);
        $this->setAuthApiTokenExpires($json->expires_in);
        break;
    }

    return $this;
  }
1164674
public function sendDigestAuthentication($url, $username, $password = null)
    {
        $this->httpClient->setDigestAuthentication($username, $password);

        return $this->httpClient->get($url);
    }