Authenticate the user.

@return boolean whether user was successfuly authenticated.
@throws EAuthException
423874
public function authenticate() {
		$this->authenticated = $this->auth->authenticate();
		$error = $this->auth->getError();
		if (isset($error)) {
			throw new EAuthException($error);
		}

		// In case of successful authentication save access token and
		// customer to session.
		if ($this->authenticated) {
			$this->saveCredentials();
		}

		return $this->getIsAuthenticated();
	}
101871
public function authenticate() {
		if ($this->service->isAuthenticated) {
			$this->id = $this->service->id;
			$this->name = $this->service->getAttribute('name');

			$this->setState('id', $this->id);
			$this->setState('name', $this->name);
			$this->setState('service', $this->service->serviceName);

			// You can save all given attributes in session.
			//$attributes = $this->service->getAttributes();
			//$session = Yii::app()->session;
			//$session['eauth_attributes'][$this->service->serviceName] = $attributes;

			$this->errorCode = self::ERROR_NONE;
		}
		else {
			$this->errorCode = self::ERROR_NOT_AUTHENTICATED;
		}
		return !$this->errorCode;
	}
835053
private function _authenticate($credentials)
    {
        try {
            $response = $this->getService('com:people.authentication.response');
            dispatch_plugin('authentication.onAuthenticate', array(
                                'credentials' => $credentials,
                                'response' => $response
                            ));

            if ($response->status === ComPeopleAuthentication::STATUS_SUCCESS) {
                return true;
            }

        } catch (RuntimeException $e) {
            //only throws exception if we are using JSON format
            //otherwise let the current app handle it
            if (AnRequest::format() == 'json') {
                throw $e;
            }
        }

        return false;
    }
131690
public function authorize()
    {
        $this->hash = $this->route('profile');
        $this->user_id = $this->getUserId();

        if ($this->auth->user()->getAuthIdentifier() != $this->user_id) {
            return false;
        }

        return true;
    }
294802
public function authenticate()
    {
        $response = $this->client->write(
            sprintf('/auth/userpass/login/%s', $this->username),
            ['password' => $this->password]
        );

        return $response->getAuth();
    }
91001
public function authenticate()
	{
		if (!empty($_REQUEST['openid_mode'])) {
			switch ($_REQUEST['openid_mode']) {
				case 'id_res':
					$this->id_res();
					return true;
					break;

				case 'cancel':
					$this->cancel();
					break;

				default:
					throw new HttpException(400, Yii::t('yii', 'Your request is invalid.'));
					break;
			}
		} else {
			$this->processRequest();
		}

		return false;
	}
431672
def authenticate!
      if u = user_class.send(config[:authenticate_method], *required_param_values)
        success!(u)
      else
        fail!(config[:error_message])
      end
    end
732733
public function authenticate() {
        $currentStage = $this->_multiFactorStages['current'];
        
        //set stage as inactive
        if ($currentStage == 1) {
            $this->_multiFactorStages[1]['statuss'] = parent::authenticate();
            
            //stage one sucessfull, bootstrap stage 2
            if ($this->_multiFactorStages[1]['statuss'] === true ) {
                $this->_multiFactorStages[2] = array (
                    'enc_key' => \openssl_random_pseudo_bytes($this->getEncKeyLength()),
                    'statuss' => false
                );                
            }

            return $this->_multiFactorStages;
        } elseif ($currentStage != 2) {
            throw new UserCredentialException('The current stage of the multi factor auth process is in an unknown state', 2101);
        }
        
        //authenticate stage 2
        $totpTimestamp = $this->userTotpProfile['totp_timestamp'];
        $totpTimelimit = $this->userTotpProfile['totp_timelimit'];
        $currDateTime = new \DateTime();
        $totpTimeElapsed = $currDateTime->getTimestamp() - $totpTimestamp->getTimestamp();
        $encKey = $this->userTotpProfile['enc_key'];
        $verificationHash = $this->getVerificationHash();
        $comparisonHash = \crypt($this->getCurrentPassword(), $encKey);
        $currentOneTimeToken = $this->getCurrentOneTimeToken();
        $oneTimeToken = $this->oneTimeToken;
        
        //initialize verification - comparison
        $verificationEqualsComparison = false;
        
        //verify if verification hash equals comparison hash. Use hash_equals function if exists
        if (!\function_exists('hash_equals')) {
            if ($verificationHash === $comparisonHash) {
                $verificationEqualsComparison = true;
            }
        } else {
            if (\hash_equals($verificationHash, $comparisonHash)) {
                $verificationEqualsComparison = true;
            }
        }

        if (
            !($totpTimeElapsed < $totpTimelimit)
            || !($verificationEqualsComparison === true)
            || !(\password_verify($oneTimeToken,$currentOneTimeToken))
        ) {
            return false;
        } else {
            return true;
        }
    }
1082245
public function authenticate()
	{
		if ($data['code'] = $this->input->get('code', false, 'raw'))
		{
			$data['grant_type'] = 'authorization_code';
			$data['redirect_uri'] = $this->getOption('redirecturi');
			$data['client_id'] = $this->getOption('clientid');
			$data['client_secret'] = $this->getOption('clientsecret');
			$response = $this->http->post($this->getOption('tokenurl'), $data);

			if ($response->code >= 200 && $response->code < 400)
			{
				if ($response->headers['Content-Type'] == 'application/json')
				{
					$token = array_merge(json_decode($response->body, true), array('created' => time()));
				}
				else
				{
					parse_str($response->body, $token);
					$token = array_merge($token, array('created' => time()));
				}

				$this->setToken($token);

				return $token;
			}
			else
			{
				throw new \RuntimeException('Error code ' . $response->code . ' received requesting access token: ' . $response->body . '.');
			}
		}

		if ($this->getOption('sendheaders'))
		{
			$this->application->redirect($this->createUrl());
		}

		return false;
	}
997225
public function login()
    {
        $result = $this->adapter->getResult();
        if ($result === self::PHAVOUR_AUTH_SERVICE_SUCCESS) {
            $auth = Auth::getInstance();
            $auth->login($this->adapter->getIdentity());
            $auth->setRoles($this->adapter->getRoles());

            return true;

        } elseif ($result === self::PHAVOUR_AUTH_SERVICE_INVALID) {
            throw new InvalidCredentialsException('Invalid credentials exception');
        }

        throw new UnrecognisedAuthenticationResultException('Expected 1 or 2');
    }
759500
def authenticate(self):
        
        # Make sure we've stored uri for use
        predix.config.set_env_value(self.use_class, 'uri', self._get_uri())

        self.uaac = predix.security.uaa.UserAccountAuthentication()
        self.uaac.authenticate('admin', self._get_admin_secret(),
                use_cache=False)
        self.is_admin = True
52334
public function authenticate()
	{
		// Already got some credentials stored?
		if ($this->token)
		{
			$response = $this->verifyCredentials();

			if ($response)
			{
				return $this->token;
			}

			$this->token = null;
		}

		// Check for callback.
		if (strcmp($this->version, '1.0a') === 0)
		{
			$verifier = $this->input->get('oauth_verifier');
		}
		else
		{
			$verifier = $this->input->get('oauth_token');
		}

		if (empty($verifier))
		{
			// Generate a request token.
			$this->generateRequestToken();

			// Authenticate the user and authorise the app.
			$this->authorise();
		}

		// Callback
		else
		{
			$session = $this->application->getSession();

			// Get token form session.
			$this->token = array('key' => $session->get('oauth_token.key', null), 'secret' => $session->get('oauth_token.secret', null));

			// Verify the returned request token.
			if (strcmp($this->token['key'], $this->input->get('oauth_token')) !== 0)
			{
				throw new \DomainException('Bad session!');
			}

			// Set token verifier for 1.0a.
			if (strcmp($this->version, '1.0a') === 0)
			{
				$this->token['verifier'] = $this->input->get('oauth_verifier');
			}

			// Generate access token.
			$this->generateAccessToken();

			// Return the access token.
			return $this->token;
		}
	}
1284800
public void authenticate() {
		log.info("Authenticating user: " + this.name);
		WebSession result = null;
		try {
			result = getContext().getAuthenticationMethod().authenticate(
				getContext().getSessionManagementMethod(), this.authenticationCredentials, this);
		} catch (UnsupportedAuthenticationCredentialsException e) {
			log.error("User does not have the expected type of credentials:", e);
		}
		// no issues appear if a simultaneous call to #queueAuthentication() is made
		synchronized (this) {
			this.lastSuccessfulAuthTime = System.currentTimeMillis();
			this.authenticatedSession = result;
		}
	}
42832
final public function isAuthenticated()
    {

        $self = $this;
        $auth = $self->get("handler", "auth");

        if (is_a($auth, Authenticate::class)) {
            if (isset($auth->authenticated)) {
                return (bool)$auth->authenticated;
            }
        }

        return false;
    }
574336
public function authenticate() {

		if (!empty($_REQUEST['openid_mode'])) {
			switch ($_REQUEST['openid_mode']) {
				case 'id_res':
					try {
						$this->auth->returnUrl = $this->getState('returnUrl');
						if ($this->auth->validate()) {
							$this->attributes['id'] = $this->auth->identity;

							$attributes = $this->auth->getAttributes();
							foreach ($this->requiredAttributes as $key => $attr) {
								if (isset($attributes[$attr[1]])) {
									$this->attributes[$key] = $attributes[$attr[1]];
								}
								else {
									throw new EAuthException(Yii::t('eauth', 'Unable to complete the authentication because the required data was not received.', array('{provider}' => $this->getServiceTitle())));
									return false;
								}
							}

							foreach ($this->optionalAttributes as $key => $attr) {
								if (isset($attributes[$attr[1]])) {
									$this->attributes[$key] = $attributes[$attr[1]];
								}
							}

							$this->authenticated = true;
							return true;
						}
						else {
							throw new EAuthException(Yii::t('eauth', 'Unable to complete the authentication because the required data was not received.', array('{provider}' => $this->getServiceTitle())));
							return false;
						}
					} catch (Exception $e) {
						throw new EAuthException($e->getMessage(), $e->getCode());
					}
					break;

				case 'cancel':
					$this->cancel();
					break;

				default:
					throw new CHttpException(400, Yii::t('yii', 'Your request is invalid.'));
					break;
			}
		}
		else {
			$this->auth->identity = $this->url; //Setting identifier
			$this->auth->required = array(); //Try to get info from openid provider
			foreach ($this->requiredAttributes as $attribute) {
				$this->auth->required[$attribute[0]] = $attribute[1];
			}
			foreach ($this->optionalAttributes as $attribute) {
				$this->auth->required[$attribute[0]] = $attribute[1];
			}

			if (isset($this->realm)) {
				if (!preg_match('#^[a-z]+\://#', $this->realm)) {
					$this->auth->realm = 'http' . (Yii::app()->request->getIsSecureConnection() ? 's' : '') . '://' . $this->realm;
				}
				else {
					$this->auth->realm = $this->realm;
				}
			}
			else {
				$this->auth->realm = Yii::app()->request->hostInfo;
			}

			$this->auth->returnUrl = Yii::app()->request->hostInfo . Yii::app()->request->url; //getting return URL
			$this->setState('returnUrl', $this->auth->returnUrl);

			try {
				$url = $this->auth->authUrl();
				Yii::app()->request->redirect($url);
			} catch (Exception $e) {
				throw new EAuthException($e->getMessage(), $e->getCode());
			}
		}

		return false;
	}
137868
public function authentication()
    {
        $response = \Aperdia\Clef::authentication($_GET['code']);

        // error
        if (!$response) {
            $error = 'Error';
        // error
        } elseif (isset($response['error'])) {
            $error = $response['error'];
        // success
        } elseif (isset($response['success'])) {
            // verif if exists account in Authentication table
            $verif = Authentication::whereprovider("clef")->whereprovider_uid($response['info']['id'])->first();

            // no account
            if (empty($verif)) {


            // Find account
            } else {
                // Find the user using the user id
                $user = User::find($verif->user_id);

                // RAZ logout
                if ($user->logout == 1) {
                    $user->logout = 0;
                    $user->save();
                }

                // Log the user in
                Auth::login($user);

                return Redirect::intended('/');
            }
        // error
        } else {
            $error = 'Unknown error';
        }

        return Redirect::to("login")->withErrors($error);
    }
1074575
private function authenticate()
    {
        $this->requestTimestamp = time();
        $requestData = $this->getDefaultRequestData('json', [
            'userIdentifier' => $this->getUserIdentifier(),
            'userSecret' => $this->getSecretKey()
        ], false);

        return $this->sendRequest('authenticate', $requestData, self::HTTP_METHOD_POST);
    }