Connects and authenticates with the CS:GO server.

@return boolean
179351
public function connect()
    {
        $socket = stream_socket_client("tcp://{$this->ip}:{$this->port}", $errno, $errstr);

        stream_set_timeout($socket, 2, 500);

        if (!$socket) {
            throw new RconConnectException("Error while connecting to the Rcon server: {$errstr}");
        }

        $this->socket = $socket;

        $this->write(self::SERVERDATA_AUTH, $this->password);

        $read = $this->read();
        if ($read[1]['ID'] == -1) {
            throw new RconAuthException('Authentication to the Rcon server failed.');
        }

        $this->connected = true;

        return true;
    }
788709
public function connect(&$cn = 1, &$cs = "Unknown error")
    {
        $fp = fsockopen($this->ip, $this->port, $cn, $cs, 3) or die("Could not connect. " . date("Y-m-d H:i:s") . PHP_EOL);     
        if (!$fp) {
            return false;
        } else {
            self::$socket = $fp;
            return true;
        }
        
    }
115564
public function authenticate()
    {

        $signer = new RequestSigner();
        $signer->setProvider('USF');
        $authenticator = new RequestAuthenticator($signer, $this->_timeout);

        $key = $authenticator->authenticate($this->_requestWrapper, $this->_keyLoader);

        if ($key) {
            $this->principal = "[HMAC]".$key->getId();
            $this->attributes = [];
            return true;
        }

        return false;

    }
1349518
public function connect()
    {
        if ($this->connection->isConnected() && !empty($this->hello)) {
            return $this->hello;
        }

        $this->connectToTheNode();
        $this->authenticateWithPassword();

        try {
            $this->sayHello();
        } catch (ResponseException $e) {
            /**
             * If the node requires a password but we didn't supply any,
             * Disque returns a message "NOAUTH Authentication required"
             *
             * HELLO is the first place we would get this error.
             *
             * @see https://github.com/antirez/disque/blob/master/src/server.c
             * Look for "noautherr"
             */
            $message = $e->getMessage();
            if (stripos($message, self::AUTH_REQUIRED_MESSAGE) === 0) {
                throw new AuthenticationException($message, 0, $e);
            }
        }

        return $this->hello;
    }
731385
public function connect() : bool
    {
        try {
            $connection_string = 'sqlsrv:SERVER=' . $this->configuration['server'] . ';DATABASE=' . $this->configuration['dbname'];
            if (isset($this->configuration['encrypt']) && true === $this->configuration['encrypt']) {
                $connection_string .= ';ENCRYPT=1';
            }
            $this->logger->debug('Connecting to database engine.');
            $this->dbconn = new PDO($connection_string, $this->configuration['username'],
                $this->configuration['password']);
            $this->dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->logger->debug('Connected to database engine.');
            $this->is_connected = true;
        } catch (\Exception $e) {
            throw new DatabaseConnectionException('MSSQL Connection to <strong>' . $this->configuration['server'] . '</strong> failed!<br>' . $e->getMessage());
        }
        return true;
    }
545906
public function connect()
    {
        $this->host = $this->options['host'];
        $this->port = $this->options['port'];
        
        if (isset($this->options['clear']) && $this->options['clear']) {
            $this->stream = stream_socket_client(
                "tcp://{$this->host}:{$this->port}", $error, $error_msg, 10
            );
        } else {
            $options = array(
                'ssl' => array(
                    'verify_peer' => false
                )
            );
            if ($this->options['verify_cert']) {
                $options['ssl']['verify_peer'] = true;
                $options['ssl']['verify_depth'] = 5;
                $options['ssl']['cafile'] = \dirname(\dirname(__FILE__)).'/data/ca-certificates.crt';
            }
            $context = stream_context_create($options);
            $this->stream = stream_socket_client(
                "tls://{$this->host}:{$this->port}", $error, $error_msg, 10,
                STREAM_CLIENT_CONNECT, $context
            );
        }
        if ($this->stream) {
            $this->connected = true;
        } else {
            $error_msg = $error_msg ?: 'Peer certificate rejected';
            throw new NetworkException(
                "Unable to connect to {$this->host}:{$this->port} "
                ."(Error:{$error} {$error_msg})"
            );
        }
    }
327842
public function getIsSecureConnection()
    {
        $https = $this->getServerParam('HTTPS');
        if ($https !== null && (strcasecmp($https, 'on') === 0 || $https == 1)) {
            return true;
        }
        foreach ($this->secureProtocolHeaders as $header => $values) {
            if ($this->hasHeader($header)) {
                foreach ($values as $value) {
                    if (strcasecmp($this->getHeaderLine($header), $value) === 0) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
176014
public function connect()
    {
        if ($this->isConnected()) {
            return true;
        }
        $this->isConnecting = true;
        $this->connection->connect();
        $this->connection->getParser()->legacyMode(true);
        $this->protocol = new Protocol($this->clientId);

        $this->host = $this->host ?: $this->connection->getHost();

        $connectFrame = $this->protocol->getConnectFrame(
            $this->login,
            $this->passcode,
            $this->versions,
            $this->host,
            $this->heartbeat
        );
        $this->sendFrame($connectFrame, false);

        if ($frame = $this->getConnectedFrame()) {
            $version = new Version($frame);

            if ($version->hasVersion(Version::VERSION_1_1)) {
                $this->connection->getParser()->legacyMode(false);
            }

            $this->sessionId = $frame['session'];
            $this->protocol = $version->getProtocol($this->clientId);
            $this->isConnecting = false;
            return true;
        }
        throw new ConnectionException('Connection not acknowledged');
    }
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;
        }
    }
522721
public function isSecureConnection()
    {
        return isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'], 'on') === 0 || $_SERVER['HTTPS'] == 1)
        || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0;
    }
186110
public function authenticate(){
		bimport('http.request');
		$code=BRequest::GetString('code');
		if(empty($code)) {
			return false;
			}
		$params = array(
			'client_id'	 => $this->clientId,
			'client_secret' => $this->clientSecret,
			'redirect_uri'  => $this->redirectUri,
			'grant_type'	=> 'authorization_code',
			'code'		  => $code
			);
		$tokenInfo = $this->post('https://accounts.google.com/o/oauth2/token', $params);

		if(!isset($tokenInfo['access_token'])) {
			return false;
			}
		$params['access_token'] = $tokenInfo['access_token'];
		$userInfo = $this->get('https://www.googleapis.com/oauth2/v1/userinfo', $params);
		if(!isset($userInfo[$this->socialFieldsMap['socialId']])) {
			BLog::addToLog('[Social.Google] userInfo socialId is not set!',LL_ERROR);
			BLog::addToLog('[Social.Google] userInfo="'.var_export($userInfo,true).'".',LL_ERROR);
			return false;
			}
		$this->userInfo = $userInfo;
		//
		if(!$this->createsession()){
			BLog::addToLog('[Social.Google] Could not create session!',LL_ERROR);
			return false;
			}
		BLog::addToLog('[Social.Google] All done!');
		return true;

		}
1301502
public function connect()
    {
        if ($this->_connection) {
            return true;
        }
        $config = $this->_config;
        $config['flags'] += [
            PDO::ATTR_PERSISTENT => $config['persistent'],
            PDO::ATTR_EMULATE_PREPARES => false,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        ];
        if (empty($config['unix_socket'])) {
            $dsn = "pgsql:host={$config['host']};port={$config['port']};dbname={$config['database']}";
        } else {
            $dsn = "pgsql:dbname={$config['database']}";
        }

        $this->_connect($dsn, $config);
        $this->_connection = $connection = $this->getConnection();
        if (!empty($config['encoding'])) {
            $this->setEncoding($config['encoding']);
        }

        if (!empty($config['schema'])) {
            $this->setSchema($config['schema']);
        }

        if (!empty($config['timezone'])) {
            $config['init'][] = sprintf('SET timezone = %s', $connection->quote($config['timezone']));
        }

        foreach ($config['init'] as $command) {
            $connection->exec($command);
        }

        return true;
    }
470930
public function authenticate()
    {
        if (!$this->validate())
            return false;

        // Load the RemoteUserIdentity model, and return if we successfully could authenticate against it
        $this->_identity = new RemoteUserIdentity($this->adapter, $this->provider, $this->_user);
        return $this->_identity->authenticate();
    }
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;
	}
793229
public function authenticate()
	{
		$result = false;

		if (isset($_GET['code'])) {
			$params = array(
				'client_id'	 => $this->clientId,
				'client_secret' => $this->clientSecret,
				'grant_type'	=> 'authorization_code',
				'code'		  => $_GET['code'],
				'redirect_uri'  => $this->redirectUri
			);

			$tokenInfo = $this->post('https://connect.mail.ru/oauth/token', $params);

			if (isset($tokenInfo['access_token'])) {
				$sign = md5("app_id={$this->clientId}method=users.getInfosecure=1session_key={$tokenInfo['access_token']}{$this->clientSecret}");

				$params = array(
					'method'	   => 'users.getInfo',
					'secure'	   => '1',
					'app_id'	   => $this->clientId,
					'session_key'  => $tokenInfo['access_token'],
					'sig'		  => $sign
				);

				$userInfo = $this->get('http://www.appsmail.ru/platform/api', $params);

				if (isset($userInfo[0]['uid'])) {
					$this->userInfo = array_shift($userInfo);
					$result = true;
				}
			}
		}

		return $result;
	}
1004917
public function check_connection()
    {
        // Establish connection if it wasn't done yet
        if (!$this->connect_done && !empty($this->options['user'])) {
            return $this->connect(
                $this->options['host'],
                $this->options['user'],
                $this->options['password'],
                $this->options['port'],
                $this->options['ssl']
            );
        }

        return $this->is_connected();
    }
390011
private function authenticate() {
        if (!is_resource($this->connection))
            throw new RuntimeException('Cannot authenticate: Not connected');

        // init authentication
        $this->writeData('AUTH LOGIN');
        $response = $this->readResponse();

        $this->parseResponse($response);
        if ($this->responseStatus == 503)
            return;                                     // already authenticated

        if ($this->responseStatus != 334)
            throw new RuntimeException('AUTH LOGIN command not supported: '.$this->responseStatus.' '.$this->response);

        // send username
        $this->writeData(base64_encode($this->options['auth_username']));
        $response = $this->readResponse();

        $this->parseResponse($response);
        if ($this->responseStatus != 334)
            throw new RuntimeException('Username '.$this->options['auth_username'].' not accepted'.$this->responseStatus.' '.$this->response);

        // send password
        $this->writeData(base64_encode($this->options['auth_password']));
        $response = $this->readResponse();

        $this->parseResponse($response);
        if ($this->responseStatus != 235)
            throw new RuntimeException('Login failed for username '.$this->options['auth_username'].': '.$this->responseStatus.' '.$this->response);
    }