Validate the hostname, username and password all appear valid.
@param string $hostname
@param string $username
@param string $password
@throws Radial_Amqp_Exception_Configuration_Exception
@return self
176006
protected function _validateConfiguration($hostname, $username, $password)
    {
        $invalidSettings = array();
        if ($hostname === '') {
            $invalidSettings[] = 'Hostname';
        }
        if ($username === '') {
            $invalidSettings[] = 'Username';
        }
        if ($password === '') {
            $invalidSettings[] = 'Password';
        }
        if ($invalidSettings) {
            throw Mage::exception(
                'Radial_Amqp_Exception_Configuration',
                $this->_helper->__(self::INVALID_CONFIGURATION, implode(', ', $invalidSettings))
            );
        }
        return $this;
    }
892064
public function authCredentials(string $username, string $password): self
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
228898
public function setAuth($username, $password)
    {
        if (!empty($username) && !empty($password)) {
            $this->username = stripslashes(trim($username));
            $this->password = stripslashes(trim($password));
        }
    }
490229
protected function authenticate(string $username, string $password)
    {
        if (!isset($this->users[$username]) || $this->users[$username]['password'] != $password) {
            return false;
        }

        return true;
    }
921927
public static function setDefaultAdmin($username, $password)
    {
        // don't overwrite if already set
        if (static::hasDefaultAdmin()) {
            throw new BadMethodCallException(
                "Default admin already exists. Use clearDefaultAdmin() first."
            );
        }

        if (empty($username) || empty($password)) {
            throw new InvalidArgumentException("Default admin username / password cannot be empty");
        }

        static::$default_username = $username;
        static::$default_password = $password;
        static::$has_default_admin = true;
    }
242720
public function failLogin($username, $password)
    {
        $ipFailed = false;
        $userFailed = false;

        // Track both failed logins from this IP and attempts to login to this user account
        $this->ipService->logFailedLogin();
        $this->loginAttemptService->trackAttempt($username, $password);

        // Deal with excessive logins from an IP
        if ($this->ipService->failedLoginsThresholdReached()) {
            $this->ipService->addToBlacklistForThresholdReached();
            $ipFailed = true;
        }

        // If the remaining attempts are less than 0
        if ($this->loginAttemptService->remainingAttempts($username, $password) <= 0) {
            $this->loginAttemptService->deactivate($username);
            $userFailed = true;
        }

        // Throw the IP ban error if we hit both ip limit and user limit at the same time
        if ($ipFailed) {
            $message = $this->ipService->getErrorMessage();
            throw new FailedLoginThresholdExceededException($message);
        }

        // If the user has been automatically deactivated and the IP has not been banned
        if ($userFailed) {
            throw new UserDeactivatedException($this->config->get('concrete.user.deactivation.message'));
        }
    }
949107
protected function _validateSftpSettings($host, $username, $key, $port)
    {
        $invalidSettings = [];
        if ($host === '') {
            $invalidSettings[] = 'Remote Host';
        }
        if ($username === '') {
            $invalidSettings[] = 'SFTP User Name';
        }
        if ($key === '') {
            $invalidSettings[] = 'Private Key';
        }
        // valid port would be int between 1 and 65535
        if ((int) $port < 1 || (int) $port > 65535) {
            $invalidSettings[] = 'Remote Port';
        }
        if (!empty($invalidSettings)) {
            throw new Radial_Core_Exception_Sftp_Configuration(
                $this->_helper->__(self::INVALID_SFTP_SETTINGS_ERROR_MESSAGE, implode(', ', $invalidSettings))
            );
        }
        return $this;
    }
1346888
final public static function setSMTP (string $host, string $username, string $password, string $SMTPSecure, int $port) : \stdClass
	{
		return (object) $SMTPConfig = [
			'host' 			=> $host,
			'username' 		=> $username,
			'password' 		=> $password,
			'SMTPSecure' 	=> $SMTPSecure,
			'port' 			=> $port
		];
	}
1284506
protected function _bindUser($username, $password)
    {
        $config = $this->getConfig();
        try {
            $ldapBind = $this->_ldap->bind($config['bindDN']($username), $password);
            if ($ldapBind === true) {
                $this->_ldap->unbind();

                return new ArrayObject([
                    $config['fields'][self::CREDENTIAL_USERNAME] => $username
                ]);
            }
        } catch (ErrorException $e) {
            $this->_handleLdapError($e->getMessage());
        }
        $this->_ldap->unbind();

        return null;
    }
560474
public function isValidUser($userName, $password)
    {
        $filter = new IteratorFilter();
        $passwordGenerator = $this->getUserDefinition()->getClosureForUpdate('password');
        $filter->addRelation($this->getUserDefinition()->loginField(), Relation::EQUAL, strtolower($userName));
        $filter->addRelation(
            $this->getUserDefinition()->getPassword(),
            Relation::EQUAL,
            $passwordGenerator($password, null)
        );
        return $this->getUser($filter);
    }
1330885
public function amHttpAuthenticated($username, $password)
    {
        $this->client->setServerParameter('PHP_AUTH_USER', $username);
        $this->client->setServerParameter('PHP_AUTH_PW', $password);
    }
1316698
public function withBasicAuth(?string $username = null, string $password = null): self
    {
        if ($username === null) {
            return $this->withoutHeader('Authorization');
        } else {
            $auth = base64_encode($username . ':' . $password);

            return $this->withHeader('Authorization', "Basic {$auth}");
        }
    }
1144977
private function _login($username, $password) {
        $data["Envelope"] = array(
            "Body" => array(
                "Login" => array(
                    "USERNAME" => $username,
                    "PASSWORD" => $password,
                ),
            ),
        );
        $response = $this->_request($data);
        $result = $response["Envelope"]["Body"]["RESULT"];
        if ($this->_isSuccess($result)) {
            $this->_jsessionid = $result['SESSIONID'];
            $this->_session_encoding = $result['SESSION_ENCODING'];
            $this->_username = $username;
            $this->_password = $password;
        } else {
            throw new \Exception("Login Error: ".$this->_getErrorFromResponse($response));
        }
    }
1175131
public function setCredentials($username, $password)
    {
        $this->connectOptions['username'] = $username;
        $this->connectOptions['password'] = $password;
        
        return $this;
    }
734697
public function basicAuthentication(string $username, string $password = ""): HttpRequest
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
1245935
protected function authenticate($username, $password)
    {
        if (!isset($username)) {
            return ValidationResult::error("username isn't set");
        }
        
        if (!isset($password)) {
            return ValidationResult::error("password isn't set");
        } 
        
        if (!isset(self::$users[$username]) || !password_verify($password, self::$users[$username]['password'])) {
            return ValidationResult::error("Invalid credentials");
        }

        return ValidationResult::success();
    }
526529
public function withCredentials($username, $password)
	{
		$this->cookie = null;
		$this->credentials = array('username' => $username, 'password' => $password);
		return $this;
	}