Detects auth method using the PROTOCOLINFO command.

@throws Exception\ProtocolError
436540
private function detectAuthMethod()
    {
        $data = $this->executeCommand('PROTOCOLINFO');

        foreach ($data as $info) {
            if ('AUTH METHODS=NULL' === $info['message']) {
                $this->options['authmethod'] = static::AUTH_METHOD_NULL;

                return;
            }

            if ('AUTH METHODS=HASHEDPASSWORD' === $info['message']) {
                $this->options['authmethod'] = static::AUTH_METHOD_HASHEDPASSWORD;

                return;
            }

            if (preg_match('/^AUTH METHODS=(.*) COOKIEFILE="(.*)"/', $info['message'], $matches) === 1) {
                $this->options['authmethod'] = static::AUTH_METHOD_COOKIE;
                $this->options['cookiefile'] = $matches[2];

                return;
            }
        }

        throw new Exception\ProtocolError('Auth method not supported');
    }
690147
public function auth() {

        try {
            $this->authResponse = $this->authAdapterInterface->authenticate();
        } catch (\Exception $ex) {
            throw $ex;
        }

        $message = $this->authResponse->getMessage();

        if ($message->getCode() == AuthResponse::AUTHRESPONSE_SUCCESS) {
            $this->session->set($message->getKeysession(), $message->getAttrsession());
        }

        return;
    }
807511
def on_auth_event(ctx, authorization_id, authentication_id, authentication)
      # if authentification is used, override this event
      # and implement your own user management.
      # otherwise all authentifications are blocked per default
      logger.debug("Deny access from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]} for #{authentication_id}" + (authorization_id == '' ? '' : "/#{authorization_id}") + " with #{authentication}")
      raise Smtpd535Exception
    end
1090274
public function detectClientExtension()
    {
        // Check if FirePHP is installed on client via User-Agent header
        if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) &&
           version_compare($m[1][0],'0.0.6','>=')) {
            return true;
        } else
        // Check if FirePHP is installed on client via X-FirePHP-Version header
        if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) &&
           version_compare($m[1][0],'0.0.6','>=')) {
            return true;
        }
        return false;
    }
1221487
protected static function detectIP()
	{
		// Normally the $_SERVER superglobal is set
		if (isset($_SERVER))
		{
			// Do we have an x-forwarded-for HTTP header (e.g. NginX)?
			if (self::$allowIpOverrides && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER))
			{
				return $_SERVER['HTTP_X_FORWARDED_FOR'];
			}

			// Do we have a client-ip header (e.g. non-transparent proxy)?
			if (self::$allowIpOverrides && array_key_exists('HTTP_CLIENT_IP', $_SERVER))
			{
				return $_SERVER['HTTP_CLIENT_IP'];
			}

			// Normal, non-proxied server or server behind a transparent proxy
			return $_SERVER['REMOTE_ADDR'];
		}

		/*
		 * This part is executed on PHP running as CGI, or on SAPIs which do not set the $_SERVER superglobal
		 * If getenv() is disabled, you're screwed
		 */
		if (!\function_exists('getenv'))
		{
			return '';
		}

		// Do we have an x-forwarded-for HTTP header?
		if (self::$allowIpOverrides && getenv('HTTP_X_FORWARDED_FOR'))
		{
			return getenv('HTTP_X_FORWARDED_FOR');
		}

		// Do we have a client-ip header?
		if (self::$allowIpOverrides && getenv('HTTP_CLIENT_IP'))
		{
			return getenv('HTTP_CLIENT_IP');
		}

		// Normal, non-proxied server or server behind a transparent proxy
		if (getenv('REMOTE_ADDR'))
		{
			return getenv('REMOTE_ADDR');
		}

		// Catch-all case for broken servers, apparently
		return '';
	}
36712
public function validateAuth()
    {
        // Send a get request to the API
        $response = $this->uniRequest->get(implode([$this->authURL, 'validate/']), $this->headers);
        // Check that we get 20X back
        if (in_array($response->code, $this->validCodes)) {
            // Return the response
            return $response;
        } else {
            // If we did not get 20X throw an exception
            throw new Exception($response->body->message, $response->code);
        }
    }
1216529
protected function determineMethod()
    {
        $methods = [
            'block'         => ['unblock', 'block'],
            'delete'        => ['restore', 'delete'],
            'activate'      => ['activate'],
            'resetPassword' => ['resetPassword'],
            'resendInvite'  => ['resendInvite'],
            'revokeInvite'  => ['revokeInvite'],
        ];

        $this->method = array_get($methods, $this->status . '.' . $this->action);
    }
1314819
public function authorize(): bool
    {
        parent::authorize();

        $user = $this->user($this->route('guard'))
                ?? $this->attemptUser($this->route('guard'))
                   ?? app('cortex.auth.admin')->whereNotNull('phone')->where('phone', $this->get('phone'))->first();

        if (! $user) {
            // User instance required to detect active TwoFactor methods
            throw new GenericException(trans('cortex/foundation::messages.session_required'), route('adminarea.login'));
        }

        return true;
    }
869586
public function connect()
    {
        if ( ! ($this->connection = ssh2_connect($this->host, $this->port))) {
            throw new \Exception('Cannot connect to server');
        }
        
        if ( ! ssh2_auth_pubkey_file($this->connection, $this->authUser, $this->authPub, $this->authPriv,
            $this->authPass)
        ) {
            throw new \Exception('Autentication rejected by server');
        }
    }
1305920
protected function _assertCookieRestriction()
    {
        $stat = false;
        if ( php_sapi_name() !== 'cli' ) {
            if ( headers_sent() )
                throw new \Exception('Headers was sent, cookies must be sent before any output from your script.');

            $stat = true;
        }

        if ( false === $stat )
            throw new \Exception('Session Cant Be Initialized.');
    }
829678
public function isMethodFailure(): bool
    {
        if ($this->isSuccess() || $this->allowedMethods === self::HTTP_METHOD_ANY) {
            return false;
        }

        return true;
    }
221621
private function guessPeerCountMethod()
    {
        $selectMethod = $this->getPeerSelectMethod();
        if ($selectMethod == 'doSelect') {
            $countMethod = 'doCount';
        } elseif (($pos = stripos($selectMethod, 'doSelectJoin')) === 0) {
            $countMethod = 'doCount' . substr($selectMethod, strlen('doSelect'));
        } else {
            // we will fall back to doCount() if we don't understand the join
            // method; however, it probably won't be accurate.  Maybe triggering an error would
            // be appropriate ...
            $countMethod = 'doCount';
        }
        $this->setPeerCountMethod($countMethod);
    }
1281541
private function authenticateWithPassword()
    {
        if ($this->credentials->havePassword()) {
            $authCommand = new Auth();
            $authCommand->setArguments([$this->credentials->getPassword()]);
            $authResponse = $this->connection->execute($authCommand);
            $response = $authCommand->parse($authResponse);
            if ($response !== self::AUTH_SUCCESS_MESSAGE) {
                throw new AuthenticationException();
            }
        }
    }
1083155
public function onAfterRoute()
    {
        $app = JFactory::getApplication();

        $username = $app->input->server->get('PHP_AUTH_USER', null, 'string');
        $password = $app->input->server->get('PHP_AUTH_PW', null, 'string');

        if ($username && $password)
        {
            if (!$this->_login($username, $password, $app)) {
                throw new Exception('Login failed', 401);
            }
        }
    }
1267492
function() {
        if (!self.initialized_) {
          self.initialized_ = true;
          // Listen to Auth events on iframe.
          self.oauthSignInHandler_.addAuthEventListener(self.authEventHandler_);
        }
      }
813243
void activate(ProtocolVersion helloVersion) throws IOException {
        if (activeProtocols == null) {
            activeProtocols = getActiveProtocols();
        }

        if (activeProtocols.collection().isEmpty() ||
                activeProtocols.max.v == ProtocolVersion.NONE.v) {
            throw new SSLHandshakeException(
                    "No appropriate protocol (protocol is disabled or " +
                    "cipher suites are inappropriate)");
        }

        if (activeCipherSuites == null) {
            activeCipherSuites = getActiveCipherSuites();
        }

        if (activeCipherSuites.collection().isEmpty()) {
            throw new SSLHandshakeException("No appropriate cipher suite");
        }

        // temporary protocol version until the actual protocol version
        // is negotiated in the Hello exchange. This affects the record
        // version we sent with the ClientHello.
        if (!isInitialHandshake) {
            protocolVersion = activeProtocolVersion;
        } else {
            protocolVersion = activeProtocols.max;
        }

        if (helloVersion == null || helloVersion.v == ProtocolVersion.NONE.v) {
            helloVersion = activeProtocols.helloVersion;
        }

        // We accumulate digests of the handshake messages so that
        // we can read/write CertificateVerify and Finished messages,
        // getting assurance against some particular active attacks.
        Set<String> localSupportedHashAlgorithms =
            SignatureAndHashAlgorithm.getHashAlgorithmNames(
                getLocalSupportedSignAlgs());
        handshakeHash = new HandshakeHash(!isClient, needCertVerify,
            localSupportedHashAlgorithms);

        // Generate handshake input/output stream.
        input = new HandshakeInStream(handshakeHash);
        if (conn != null) {
            output = new HandshakeOutStream(protocolVersion, helloVersion,
                                        handshakeHash, conn);
            conn.getAppInputStream().r.setHandshakeHash(handshakeHash);
            conn.getAppInputStream().r.setHelloVersion(helloVersion);
            conn.getAppOutputStream().r.setHelloVersion(helloVersion);
        } else {
            output = new HandshakeOutStream(protocolVersion, helloVersion,
                                        handshakeHash, engine);
            engine.inputRecord.setHandshakeHash(handshakeHash);
            engine.inputRecord.setHelloVersion(helloVersion);
            engine.outputRecord.setHelloVersion(helloVersion);
        }

        // move state to activated
        state = -1;
    }
711841
protected function _auth()
    {
        if (isset($this->_config['username'], $this->_config['password'])) {
            $replyCode = (string)$this->_smtpSend('AUTH LOGIN', '334|500|502|504');
            if ($replyCode === '334') {
                try {
                    $this->_smtpSend(base64_encode($this->_config['username']), '334');
                } catch (SocketException $e) {
                    throw new SocketException('SMTP server did not accept the username.', null, $e);
                }
                try {
                    $this->_smtpSend(base64_encode($this->_config['password']), '235');
                } catch (SocketException $e) {
                    throw new SocketException('SMTP server did not accept the password.', null, $e);
                }
            } elseif ($replyCode === '504') {
                throw new SocketException('SMTP authentication method not allowed, check if SMTP server requires TLS.');
            } else {
                throw new SocketException('AUTH command not recognized or not implemented, SMTP server may not require authentication.');
            }
        }
    }