@param string $username
@param string $password

@throws Mollie_Exception
@return SimpleXMLElement
553915
public function accountValid($username, $password)
    {
        return $this->performRequest(
            self::METHOD_POST,
            sprintf('/api/reseller/v%d/account-valid', self::API_VERSION),
            ["username" => $username, "password" => $password]
        );
    }
490428
public function connect($username, $password)
    {
        $error = parent::connect($username, $password);

        if ($error) {
            return $error;
        }

        return $this->load_script();
    }
734697
public function basicAuthentication(string $username, string $password = ""): HttpRequest
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
1029197
protected function _findUser($username, $password = null)
    {
        $userModel = $this->_config['userModel'];
        list($plugin, $model) = pluginSplit($userModel);
        $fields = $this->_config['fields'];

        $conditions = [$model . '.' . $fields['token'] => $username];
        if (!empty($this->_config['scope'])) {
            $conditions = array_merge($conditions, $this->_config['scope']);
        }
        $table = TableRegistry::get($userModel)->find('all');
        if ($this->_config['contain']) {
            $table = $table->contain($this->_config['contain']);
        }

        $result = $table
            ->where($conditions)
            ->hydrate(false)
            ->first();

        if (empty($result)) {
            return false;
        }

        unset($result[$fields['password']]);

        return $result;
    }
475980
public function signin($username, $password)
    {
        $rules = [
            'username' => ['required' => true],
            'password' => ['required' => true],
        ];
        $inputs = [
            'username' => $username,
            'password' => $password,
        ];
        $requireValidate = new Validation($inputs, $rules);
        if ($requireValidate->fail()) {
            Error::set($requireValidate->error()->get());
        }
        $user = new User();
        if (!$user->isUsername($username)) {
            Error::set(__printl('auth:error:username:not:exists'), 'username');
        } else {
            $password_hash = $user->getByWhere('username', $username)[0]['password'];
            if (!Hash::verify($password, $password_hash)) {
                Error::set(__printl('auth:error:password:confirm'), 'password');
            } else {
                $token = $user->getByWhere('username', $username)[0]['token'];
                $email = $user->getByWhere('username', $username)[0]['email'];
                if (__config()->auth->is_verify_email === true) {
                    if ($token !== 'NULL') {
                        $subject = __printl('auth:subject:need:verify');
                        $link = site_base_url().__config()->auth->verification_link.'/'.$token;
                        $html = __printl('auth:body:need:verify');
                        $html = str_replace(':email', $email, $html);
                        $html = str_replace(':link', $link, $html);
                        (new EmailHandler($subject, $html, $email));
                        Error::set(__printl('auth:error:need:verification'), 'email');
                    }
                }
            }
        }
        if (!$user->isLogin()) {
            if ($this->fail() !== true) {
                $salts = $user->getByWhere('username', $username)[0]['salts'];
                Session::set('user', $salts);
                $request = new Request();
                set_cookie('user', $salts, 31104000, '/', $request->getServerName(), false, true);
                $password_hash = $user->getByWhere('username', $username)[0]['password'];
                if (Hash::needsRehash($password_hash) === true) {
                    $hashed = Hash::make($password);
                    $update = new Update();
                    $update->update(['password'=>$hashed], $user->getByWhere('username', $username)[0]['id']);
                }

                Success::set(__printl('auth:success:signin'));
            }
        } else {
            Error::set(__printl('auth:error:already:login'), 'login');
        }
    }
812923
public function getByUsername ($username)
    {
        $entity = $this->er->findOneBy(array('username' => $username));

        if (NULL == $entity) {
            throw new Exception("User not found: username=$username");
        }

        return $this->getModel($entity);
    }
1334729
public function authenticate(string $username, string $password): ConnectionInterface
    {
        $errorMessage = null;
        $errorNumber  = 0;
        \set_error_handler(static function ($nr, $message) use (&$errorMessage, &$errorNumber) {
            $errorMessage = $message;
            $errorNumber = $nr;
        });

        $resource = \imap_open(
            $this->getServerString(),
            $username,
            $password,
            $this->options,
            $this->retries,
            $this->parameters
        );

        \restore_error_handler();

        if (false === $resource || null !== $errorMessage) {
            throw new AuthenticationFailedException(\sprintf(
                'Authentication failed for user "%s"%s',
                $username,
                null !== $errorMessage ? ': ' . $errorMessage : ''
            ), $errorNumber);
        }

        $check = \imap_check($resource);

        if (false === $check) {
            throw new ResourceCheckFailureException('Resource check failure');
        }

        $mailbox       = $check->Mailbox;
        $connection    = $mailbox;
        $curlyPosition = \strpos($mailbox, '}');
        if (false !== $curlyPosition) {
            $connection = \substr($mailbox, 0, $curlyPosition + 1);
        }

        // These are necessary to get rid of PHP throwing IMAP errors
        \imap_errors();
        \imap_alerts();

        return new Connection(new ImapResource($resource), $connection);
    }
441913
public function getUser($username, $password)
    {
        $authHash = $this->hashUserNameAndPassword($username, $password);
        $body     = json_encode(['clientType' => 'wp-plugin']);

        try {
            $response = $this->client->post(
              $this->loginurl, [
                'headers' => ['Authorization' => 'Basic ' . $authHash],
                'verify'  => $this->certFile,
                'body'    => $body //wp-plugin value makes session not expire
              ]);
            $this->response = $response->getBody();

        } catch (ClientException $e) {
            $response       = [
              'code'     => $e->getCode(),
              'response' => $e->getMessage(),
              'error'    => true
            ];
            $this->response = json_encode($response);

        } catch (ConnectException $e) {
            $message = 'Can not connect to Leadpages Server:';
            $response = $this->parseException($e, $message);
            $this->response = $response;
        }

        return $this;
    }
975856
public static function buildWsseHeader($username, $password)
    {
        $nonce = mt_rand();
        $date = new \DateTime();
        $createdAt = $date->format("c");
        $passwordDigest = base64_encode(sha1(
            base64_decode($nonce) . $createdAt . $password,
            TRUE
        ));
        $wsseCredentials = sprintf(
            static::WSSE_CREDENTIALS_PATTERN,
            $username,
            $passwordDigest,
            $nonce,
            $createdAt
        );

        return $wsseCredentials;
    }
277073
public function checkUserCredentials($username, $password)
    {
        $userDetails = $this->getUserDetails($username);

        return $userDetails && $userDetails['password'] && $userDetails['password'] === $password;
    }
917161
public function setBasicAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;

        return $this;
    }
235458
protected function generateCookieValue($username, $password)
    {
        // $username is encoded because it might contain COOKIE_DELIMITER,
        // we assume other values don't
        return $this->encodeCookie(array(
            base64_encode($username),
            $this->generateCookieHash($username, $password),
        ));
    }
493596
public function createUser($username, $password, array $data = [])
    {
        /** @var UserInterface|EloquentUser $user */
        $user = $this->sentinel->registerAndActivate([
            'email'    => $username,
            'password' => $password,
        ]);

        if ( ! $user) {
            // @codeCoverageIgnoreStart
            throw new \Exception("Failed to create user '{$username}'");
            // @codeCoverageIgnoreEnd
        }

        $user->update($data);

        return $user;
    }
983226
public function userWithPass($username, $password)
    {
        $header = base64_encode(sprintf('%s:%s', $username, $password));

        $this->headers['Authorization'] = 'Basic ' . $header;
    }
211060
public static function makePasswordHash($username, $password)
    {
        //sha1 用户名+密码
        if (self::$password_hash == 'sha1')
        {
            return sha1($username . $password);
        }
        //使用PHP内置的password
        elseif(self::$password_hash == 'crypt')
        {
            if (!function_exists('password_hash'))
            {
                throw new \Exception("require password_hash function.");
            }
            $options = [
                'cost' => self::$password_cost,
                'salt' => mcrypt_create_iv(self::$password_salt_size, MCRYPT_DEV_URANDOM),
            ];
            return password_hash($password, PASSWORD_BCRYPT, $options);
        }
        //md5 用户名+密码
        elseif (self::$password_hash == 'md5')
        {
            return md5($username . $password);
        }
        elseif (self::$password_hash == 'sha1_single')
        {
            return sha1($password);
        }
        elseif (self::$password_hash == 'md5_single')
        {
            return md5($password);
        }
        return false;
    }
1079322
protected function createLMv2Password($password, $username, $domain, $challenge, $client)
    {
        $lmPass = '00'; // by default 00
        // if $password > 15 than we can't use this method
        if (strlen($password) <= 15) {
            $ntlmHash = $this->md4Encrypt($password);
            $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain));

            $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client);
        }

        return $this->createByte($lmPass, 24);
    }
862383
public function setup($userName, $password) {
        // we MUST have the username and password. No Blanks allowed!
        //
        // remove blanks else Empty doesn't work
        $userName = trim($userName);
        $password = trim($password);

        if (empty($userName) || empty($password)) {
            //Throw exception if the required parameters were not found
            $this->log('parameters did not include username and/or password');
            throw new RequiredParameterMissingException('One or more required parameters was not supplied. Both userName and password required!');
        }

        $this->userName = $userName;
        $this->password = $password;
    }