Obtiene las credenciales de algun usuario dentro de la configuracion si el $password
no fue pasado como parametro
@param string $destino
@param string $fichero
@param string $usuario
@param string password
@return array
768214
protected function obtenerCredenciales($destino, $fichero, $usuario, $password){
        if (!$password) {
            $yaml = new \Symfony\Component\Yaml\Parser();
            $valor = $yaml->parse(file_get_contents($fichero)); 
            $parametros = $valor['ldapPM'];
            if ($parametros['solo_default']) {
                // TODO: Implementar esto
            }else{
                return $parametros['servidores'][$destino][$usuario];
            }
        }else{
            return array('dn' => $usuario, 'contrasenia'=> $password);
        }
        
    }
516096
public function processLogin($username = null, $password = null, $encrypt = true)
    {
        if ($username === null && isset($_POST['username'])) {
            $username = $_POST['username'];
        }
        if ($password === null && isset($_POST['password'])) {
            $password = $_POST['password'];
        }
        if (isset($username) && isset($password)) {
            $this->csrf();
            $user = self::instanceUser(null);
            $db = $this->getDb();
            $username = $db->escape_string($username); // Para evitar inyecciones SQL
            if ($encrypt) {
                $password = $user->encrypt($password);
            }
            $user = $user->getByUserPassword($username, $password);
            if ($user) {
                $this->user = Model::newInstance('User', $user);
                if (!$this->user->disabled) {
                    $this->user->lastlogin = now();
                    $this->user->save();

                    Session::set($this->session_key, array($username, $password));
                    Events::dispatch('onLoginSuccess', array('user' => $this->user));
                    if (isset($_REQUEST['remember']) && $_REQUEST['remember']) {
                        setcookie($this->session_key, serialize(Session::get($this->session_key)),
                            time() + 60 * 60 * 24 * 30, '/');
                    }
                    $this->redirectLogin();
                    return true;

                } else {
                    $this->addMessage('Este usuario está desactivado', 'danger');
                }
            } else {
                $this->addMessage('Usuario o contraseña incorrecta', 'danger');
            }
        }
        return false;
    }
957349
public function checkPassword(IObject $user, $password)
    {
        return $user->getProperty($this->passwordField)->getValue() === $password;
    }
954682
protected function _getDemoShopLoginQuery($sUser, $sPassword)
    {
        if ($sPassword == "admin" && $sUser == "admin") {
            $sSelect = "SELECT `oxid` FROM `oxuser` WHERE `oxrights` = 'malladmin' ";
        } else {
            /** @var UserException $oEx */
            $oEx = oxNew(UserException::class);
            $oEx->setMessage('ERROR_MESSAGE_USER_NOVALIDLOGIN');
            throw $oEx;
        }

        return $sSelect;
    }
1147508
public function checkPassword($password, $hash)
    {
        if ($this->mode == self::MODE_BCRYPT) {
            return $this->checkModeBcrypt($password, $hash);
        } elseif ($this->mode == self::MODE_PBKDF2) {
            return $this->checkModePbkdf2($password, $hash);
        }

        $this->error = 'You have to set the mode...';
        $this->cwsDebug->error($this->error);

        return false;
    }
1140732
public function getPasswordResetTokenRules()
    {
        if (!is_string($this->passwordResetTokenAttribute) || empty($this->passwordResetTokenAttribute)) {
            return [];
        }
        if (empty($this->passwordResetTokenRules) || !is_array($this->passwordResetTokenRules)) {
            $this->passwordResetTokenRules = [
                [[$this->passwordResetTokenAttribute], 'string', 'length' => 40],
                [[$this->passwordResetTokenAttribute], 'unique'],
            ];
        }
        return $this->passwordResetTokenRules;
    }
1168481
public function getSubscriptionCredentials($email, $password)
    {
        // Build a light authenticator.
        $signature = new Signature($password);
        $signature->getNoncer()->setLength(self::NONCE_LENGTH);
        $authentiator = array(
            'time' => $signature->getRequestTime(),
            'hash' => $signature->generate(),
            'nonce' => $signature->getNonce(),
        );
        $params = array(
            'authenticator' => $authentiator,
            'body' => array('email' => $email),
        );

        $response = $this->call('acquia.agent.subscription.credentials', $params);
        // @todo catch error and/or check response is_error
        // @todo set this key/id
        return $response;
    }
401442
private function getPassword()
    {
        $password = $this->secret("Enter your password");
        $passwordAgain = $this->secret("Enter your password again");

        $validator = Validator::make([
            'password'              => $password,
            'password_confirmation' => $passwordAgain,
        ], [
            'password' => 'required|min:5|confirmed',
        ]);

        if( $validator->fails() ) {
            $this->info('');
            $this->error("The password must be at least 5 characters and must match!");
            $this->info('');

            return $this->getPassword();
        }

        $this->password = bcrypt($password);
    }
556807
public function getPassword($unhashed = false) {
        if((bool) $unhashed === true){
            return $this->_inputPassword;
        }else{
            return \password_hash($this->_inputPassword, \PASSWORD_DEFAULT);
        }
    }
887299
public function sscan(&$Iterator, $field, $pattern = null, $count = null)
    {
        return $this->__call('sscan', [$field, &$Iterator, $pattern, $count]);
    }
1318084
public function getAuthToken($scramble, $password)
    {
        return sha1($scramble . sha1($hash1 = sha1($password, true), true), true) ^ $hash1;
    }
477642
public function checkMemberPassword($member, $password, $bypass = false)
    {
        $timeStamp = time();
        if (!is_string($password)) {
            return $this->createException('InvalidParameterValueException', 'Password must be a string.', 'E:S:007');
        }
        $response = $this->getMember($member);
        if ($response->error->exist) {
            return $response;
        }
        $member = $response->result->set;
        /** We will need the encryption service to encrypt password. */
        $enc = $this->kernel->getContainer()->get('encryption');
        $password = $enc->input($password)->key($this->kernel->getContainer()->getParameter('app_key'))->encrypt('enc_reversible_pkey')->output();

        $correct = false;
        if ($member->getPasword() === $password) {
            $correct = true;
        }

        if ($bypass) {
            return $correct;
        }
        return new ModelResponse($correct, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, time());
    }
492696
private function password($cadena){
        $valores = array();
        $valor = 0;
        $encadena = str_split(strtolower($cadena));
        foreach ($encadena as $i){
            $j = array_search($i, $this->letras) % 10;
            $valores[] = $j;
            $valor += $j;
        }
        $digito = implode(array_slice(str_split($valor), -1 ));
        $prima = implode(array_slice($valores,0, 3));
        $secon = implode(array_slice($valores,-2));
        $operacion = abs($prima - $secon);
        $longitud = strlen($operacion);
        if ($longitud == 1){
            $resultado_final = "00" . $operacion;
        }elseif($longitud == 2){
            $resultado_final = "0" . $operacion;
        }else{
            $resultado_final = $operacion;
        }
        $texto = ucfirst(implode(array_slice($encadena,0, 3)));
        $this->entrada['password'] = $texto . "_" . $digito . $resultado_final;
        return $this->entrada['password'];
    }
243636
public function lostpassword()
    {
        $handlers = [];
        $authenticators = $this->getApplicableAuthenticators(Authenticator::RESET_PASSWORD);
        /** @var Authenticator $authenticator */
        foreach ($authenticators as $authenticator) {
            $handlers[] = $authenticator->getLostPasswordHandler(
                Controller::join_links($this->Link(), 'lostpassword')
            );
        }

        return $this->delegateToMultipleHandlers(
            $handlers,
            _t('SilverStripe\\Security\\Security.LOSTPASSWORDHEADER', 'Lost Password'),
            $this->getTemplatesFor('lostpassword'),
            [$this, 'aggregateAuthenticatorResponses']
        );
    }
833568
public static function Auth ($user_name = null, $password = null, $name = self::DEFAULT_CONNECTION_NAME) {
		if (static::IsAuthenticated($name)) {
			return static::$_loginUserName[$name];
		}

		//==============================================
		//設定確認
		//==============================================
		$options = static::GetAuthCookieOptions($name);
		foreach (['server_key', 'server_salt', 'client_key', 'client_salt'] as $key) {
			if (empty($options[$key])) {
				throw CoreException::RaiseSystemError('クッキー認証の%sが設定されていません。CookieAuth::Connect([\'%s\' => 任意のパスキー])として設定を行ってください。', [$key, $key]);
			}
		}
		if (empty($options['stretcher'])) {
			throw CoreException::RaiseSystemError('クッキー認証のstretcherが設定されていません。CookieAuth::Connect([\'stretcher\' => [一つ目のstretch, 二つ目のstretch, 三つ目のstretch]])として設定を行ってください。');
		}
		if (empty($options['password_callback'])) {
			throw CoreException::RaiseSystemError('クッキー認証のpassword_callbackが設定されていません。CookieAuth::Connect([\'password_callback\' => call back function]])として設定を行ってください。');
		}

		//==============================================
		//ガベージコレクタ
		//==============================================
		static::AuthCookieSessionGarbageCollection($options['divisor'], $options['probability'], $options, $name);

		//==============================================
		//認証クッキー取得
		//==============================================
		$auth_cookie	= static::GetAuthCookieValue($name);

		//ユーザー名とパスワードがある場合は強制再認証
		if ($auth_cookie !== null && $user_name !== null && $password !== null) {
			list($cookie_name, $cookie_value) = $auth_cookie;
			$auth_cookie = null;
			static::AuthDelete($cookie_name, $name);
		}

		//==============================================
		//認証
		//==============================================
		$password_callback	 = $options['password_callback'];

		//未認証の疑い
		if ($auth_cookie === null) {
			//認証クッキーがなく、user_nameの指定がない場合は未認証とする。
			if ($user_name === null) {
				static::$_loginUserName[$name] = null;
				return static::STATUS_UNAUTHORIZED;
			}

			//認証待ち
			//実在するユーザーかどうか確認する
			$on_storage_password = $password_callback($user_name);
			if ($on_storage_password === null) {
				//認証失敗
				static::$_loginUserName[$name] = null;
				return static::STATUS_FAILURE;
			}

			//正しいパスワードかどうか
			$auth_impact_callback	 = $options['auth_impact_callback'];
			if (!$auth_impact_callback($on_storage_password, $user_name, $password)) {
				//認証失敗
				static::$_loginUserName[$name] = null;
				return static::STATUS_FAILURE;
			}
			$password = $on_storage_password;

			//認証展開
			$cookie_name = static::CreateCookieName($name);
			if ($cookie_name === null) {
				throw CoreException::RaiseSystemError('クッキー認証ファイルの配置ができませんでした。');
			}
			static::UpdateAuthStatus($cookie_name, $user_name, $password, 1, $name);

			//認証成功
			static::$_loginUserName[$name] = $user_name;
			return ['user_name' => static::$_loginUserName[$name], 'cookie_auth' => false];
		}

		//==============================================
		//認証クッキーの正当性検証
		//==============================================
		//クッキー名と値の取得
		list($cookie_name, $cookie_value) = $auth_cookie;

		//認証データが残っているかどうか検証
		if (!is_file(static::CreateCookieSavePath($cookie_name, $name))) {
			static::AuthDelete($cookie_name, $name);
			throw CoreException::RaiseSystemError('存在しない認証クッキーを渡されました。cookie_name:%s, cookie_save_dir:%s', [$cookie_name, $options['cookie_save_dir']]);
		}

		//ユーザ名の取得
		$user_name = static::GetUserNameFromSessionData($cookie_name, $name);

		//パスワードを取得する
		$password = $password_callback($user_name);

		//実在するユーザーかどうか確認する
		if ($password === null || $password === false) {
			//認証失敗
			static::AuthDelete($cookie_name, $name);
			static::$_loginUserName[$name] = null;
			return static::STATUS_FAILURE;
		}

		//クッキー認証セッションデータの取得
		$server_data = static::GetAuthSessionData($cookie_name, $user_name, $password, $name);

		//クッキー値の展開
		$client_data = static::PurseAuthCookieData($cookie_value, $user_name, $password, $name);
		if ($client_data === false) {
			static::AuthDelete($cookie_name, $name);
			throw CoreException::RaiseSystemError('認証クッキーそのものが改ざんされています。');
		}

		//不動キーの突合検証
		if (!Hash::ValidRandomHash($client_data['shadow'], $options['client_key'], $options['server_salt'], $options['server_key'])) {
			static::AuthDelete($cookie_name, $name);
			throw CoreException::RaiseSystemError('認証クッキーの内容が改ざんされています。key:%s', [$client_data['shadow']]);
		}

		//認証値の突合確認
		foreach ($options['valid_alter_lv'] === static::VALID_ALTER_LV_LAZY ? [] : ['username', 'realm', 'uri', 'nc', 'nonce', 'cnonce', 'response'] as $key) {
			if ($server_data[$key] !== $client_data[$key]) {
				static::AuthDelete($cookie_name, $name);
				throw CoreException::RaiseSystemError('認証クッキーの内容が改ざんされています。key:%s', [$key]);
			}
		}

		//認証情報更新
		static::UpdateAuthStatus($cookie_name, $user_name, $password, $server_data['nc'] + 1, $name);

		//認証成功
		static::$_loginUserName[$name] = $user_name;
		return ['user_name' => static::$_loginUserName[$name], 'cookie_auth' => true];
	}
1324583
public function passValidateCredentialsAndCreateAccessTokenResponse(
        string $userName,
        string $password,
        ClientInterface $client = null,
        bool $isScopeModified = false,
        array $scope = null,
        array $extraParameters = []
    ): ResponseInterface {
        assert($client !== null);

        if (($userIdentifier = $this->getIntegration()->validateUserId($userName, $password)) === null) {
            $this->logDebug('User not found with provided username and password.', ['username' => $userName]);
            throw new OAuthTokenBodyException(OAuthTokenBodyException::ERROR_INVALID_GRANT);
        }
        assert(is_int($userIdentifier) === true);
        $this->logInfo('User authenticated with provided username and password.', ['username' => $userName]);

        $changedScopeOrNull = $this->getIntegration()->verifyAllowedUserScope($userIdentifier, $scope);
        if ($changedScopeOrNull !== null) {
            assert(is_array($changedScopeOrNull));
            $isScopeModified = true;
            $scope           = $changedScopeOrNull;
        }

        $unsavedToken = $this->getIntegration()->createTokenInstance();
        $unsavedToken
            ->setClientIdentifier($client->getIdentifier())
            ->setScopeIdentifiers($scope)
            ->setUserIdentifier($userIdentifier);
        $isScopeModified === true ? $unsavedToken->setScopeModified() : $unsavedToken->setScopeUnmodified();

        $tokenExpiresIn = $this->setUpTokenValues($unsavedToken);
        $savedToken     = $this->getIntegration()->getTokenRepository()->createToken($unsavedToken);

        $response = $this->createBodyTokenResponse($savedToken, $tokenExpiresIn);

        return $response;
    }
1368194
public function initPasswordReset($value, $options = []) {
		$defaults = [
			'field' => [
				$this->_table->aliasField($this->_field('email')),
				$this->_table->aliasField($this->_field('username'))
			]
		];

		$options = Hash::merge($defaults, $this->_config['initPasswordReset'], $options);
		$result = $this->_getUser($value, $options);

		if (empty($result)) {
			throw new RecordNotFoundException(__d('burzum/user_tools', 'User not found.'));
		}

		$result->set([
			$this->_field('passwordToken') => $this->generateToken($options['tokenLength']),
			$this->_field('passwordTokenExpires') => $this->expirationTime($options['expires'])
		], [
			'guard' => false
		]);

		if (!$this->_table->save($result, ['checkRules' => false])) {
			new RuntimeException('Could not initialize password reset. Data could not be saved.');
		}

		$this->sendPasswordResetToken($result, [
			'to' => $result->get($this->_field('email'))
		]);
	}