@param string $local_name
@param string $remote
@param string $auth
@param array  $request

@return mixed

@throws \Exception
483645
public function upgrade(string $local_name,
                            string $remote,
                            string $auth,
                            array $request)
    {
        $url = $this->base_url.'/'.$local_name.'/upgrade?'.http_build_query([
                    'remote' => $remote,
                ]
            );

        $header = [];

        if ($auth) {
            $header = ['X-Registry-Auth' => $auth];
        }

        return $this->curl->post($url, json_encode($request), $header);
    }
204595
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the UserService.
    UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);

    // Get the current user.
    User user = userService.getCurrentUser();

    System.out.printf(
        "User with ID %d, name '%s', email '%s', and role '%s' is the current user.%n",
        user.getId(), user.getName(), user.getEmail(), user.getRoleName());
  }
1299542
public function get($remote_file, $local_file)
    {

        $stream = @fopen("ssh2.sftp://".$this->sftp.$remote_file, 'r');
        if (! $stream){
            throw new \Exception("Could not get remote file:". $remote_file);
        }

        $size = $this->size($remote_file);
        $contents = '';
        $read = 0;
        $len = $size;
        while ($read < $len && ($buf = fread($stream, $len - $read))) {
          $read += strlen($buf);
          $contents .= $buf;
        }
        file_put_contents ($local_file, $contents);
        @fclose($stream);

        return true;

    }
576069
public function __doRequest($request, $location, $action, $version, $oneWay = null)
    {
        $this->requestId = substr(str_replace(' ', '', microtime()), 2);

        $response = parent::__doRequest($request, $location, $action, $version, $oneWay);

        if (!empty($response)) {
            $xml = new \SimpleXMLElement($response);
            $nss = array_flip($xml->getDocNamespaces(true));
            $invalidNs = 'http://namespaces.soaplite.com/perl';

            if (isset($nss[$invalidNs]) && isset($nss['API'])) {
                $response = str_replace($nss[$invalidNs] . ':', $nss['API'] . ':', $response);
            }
        }

        return $response;
    }
1201461
protected function SimpleResultCall(string $actionName, $request, string $resultPropName, int $cacheTtl = 0)
    {
        $response = $this->ExecuteCall($actionName, $request, GnResponseType::Json, FALSE, $cacheTtl);
        $result = $response->{$resultPropName};
        return $result;
    }
652321
public function send($local_file, $remote_file, $overwrite = false)
    {
        if (false === file_exists($local_file)) {
            return $this->_trigger_error(sprintf('Could not open local file: %s.', $local_file));
        }

        $remote_file = $this->_getAbsoluteRemotePath($remote_file);
        if (false === $overwrite && true === file_exists($remote_file)) {
            return $this->_trigger_error(sprintf('Remote file already exists: %s.', $remote_file));
        }

        if (false === file_exists(dirname($remote_file))) {
            @$this->mkdir(dirname($remote_file), true);
        }

        if (false === @copy($local_file, $remote_file)) {
            return $this->_trigger_error(sprintf('Could not send data from file %s to file %s.', $local_file, $remote_file));
        }

        return true;
    }
673726
def call_remote(method, args)
      # Blank out username and password
      safe_args = args.inject([]) {|memo, v| memo << ((memo.last == :username or memo.last == :password) ? "" : v) }
      key = "#{method}(#{safe_args.join(':')})"
      
      if @recording
        response = super(method, args)
        
        unless @recorded_responses[key]
          # track this { key => request } to avoid duplication in the YAML
          @recorded_responses[key] = true
          
          YAML.dump({ key => response }, @recording_source)
        end
      else
        response = @recorded_responses[key]
        raise ASFRecordingBindingError.new(@logger, "Unable to find matching response for recorded request '#{key}'") unless response
      end
      
      response
    end
942184
public function provideSessionInfo( WebRequest $request ) {

		# Loop through user names given by all remote sources. First hit, which
		# matches a usable local user name, will be used for our SessionInfo then.
		foreach ( $this->remoteUserNames as $remoteUserName ) {

			if ( $remoteUserName instanceof Closure ) {
				$remoteUserName = call_user_func( $remoteUserName );
			}

			# Keep info about remote-to-local user name processing for logging and
			# and later for provider metadata.
			$metadata = [ 'remoteUserName' => (string)$remoteUserName ];

			if ( !is_string( $remoteUserName ) || empty( $remoteUserName ) ) {
				$this->logger->warning(
					"Can't login remote user '{remoteUserName}' automatically. " .
					"Given remote user name is not of type string or empty.",
					$metadata
				);
				continue;
			}

			# Process each given remote user name if needed, e.g. strip NTLM domain,
			# replace characters, rewrite to another username or even blacklist it by
			# returning false. This can be used by the wiki administrator to adjust
			# this SessionProvider to his specific needs.
			$filteredUserName = $remoteUserName;
			if ( !Hooks::run( static::HOOKNAME, [ &$filteredUserName ] ) ) {
				$metadata[ 'filteredUserName' ] = $filteredUserName;
				$this->logger->warning(
					"Can't login remote user '{remoteUserName}' automatically. " .
					"Blocked this user when applying filter to '{filteredUserName}'.",
					$metadata
				);
				continue;
			}
			$metadata[ 'filteredUserName' ] = (string)$filteredUserName;

			if ( !is_string( $filteredUserName ) || empty( $filteredUserName ) ) {
				$this->logger->warning(
					"Can't login remote user '{remoteUserName}' automatically. " .
					"Filtered remote user name '{filteredUserName}' is not of " .
					"type string or empty.",
					$metadata
				);
				continue;
			}

			# Create a UserInfo (and User) object by given user name. The factory
			# method will take care of correct validation of user names. It will also
			# canonicalize it (e.g. transform the first letter to uppercase).
			#
			# An exception gets thrown when the given user name is not 'usable' as an
			# user name for the wiki, either blacklisted or contains invalid characters
			# or is an ip address.
			#
			# @see User::getCanonicalName()
			# @see User::isUsableName()
			# @see Title::newFromText()
			try {
				$userInfo = UserInfo::newFromName( $filteredUserName, true );
			} catch ( InvalidArgumentException $e ) {
				$metadata[ 'exception' ] = $e;
				$this->logger->warning(
					"Can't login remote user '{remoteUserName}' automatically. " .
					"Filtered name '{filteredUserName}' is not usable as an " .
					"user name in MediaWiki.: {exception}",
					$metadata
				);
				continue;
			}
			$metadata[ 'userId' ] = $userInfo->getId();
			$metadata[ 'canonicalUserName' ] = $userInfo->getName();

			# Let our parent class find a valid SessionInfo.
			$sessionInfo = parent::provideSessionInfo( $request );

			# Our parent class provided a session info, but the `$wgGroupPermission` for
			# creating user accounts was changed while using this extension. This leds
			# to a behaviour where a new user won't be created automatically even if the
			# wiki administrator enabled (auto) account creation by setting the specific
			# group permission `createaccount` or `autocreateaccount` to `true`.
			#
			# This happens in rare circurmstances only: The global permission forbids
			# account creation. A new user requests the wiki and a specific session is
			# getting created (by our parent). Then the `AuthManager` permits further
			# account creation attempts due to global permission by marking this session
			# as blacklistet. This blacklist info is stored inside the session itself.
			# Now when the wiki admin changes the global account creation permission to
			# `true` and the new user wants to access the wiki, then his account is not
			# created automatically due to this blacklist marking inside his current
			# session, identified by our parent class. Hence we throw this session away
			# in these rare cases (We could manipulate the session itself and delete that
			# `AuthManager::AutoCreateBlacklist` key instead, but that would look like
			# real hacked code inside this method).
			#
			# @see AuthManager::AutoCreateBlacklist
			# @see AuthManager::autoCreateUser()
			if ( $sessionInfo && $userInfo->getUser()->isAnon() ) {
				$anon = $userInfo->getUser();
				$permissions = $anon->getGroupPermissions( $anon->getEffectiveGroups() );
				if (
					in_array( 'autocreateaccount', $permissions, true )
					|| in_array( 'createaccount', $permissions, true )
				) {
					$this->logger->warning(
						"Renew session due to global permission change " .
						"in (auto) creating new users."
					);
					$sessionInfo = null;
				}
			}

			# If our parent provides a session info, it could be from an old request
			# where the old remote user name doesn't match the one used for the current
			# request. This happens when the client switched the user remotely (because
			# he has access to two different accounts at the remote source). Therefore
			# we have to mark the local authentication part (the cookie, because we
			# inherit from `CookieSessionProvider`) and compare it against the current
			# request. We use the `filteredUserName` instead of `remoteuserName` for the
			# comparison, because the wiki admin could have mapped two differing remote
			# user names to the same local username with an according filter. For the
			# marking itself we have to overwrite some inherited methods.
			#
			# @see self::getCookieDataToExport()
			# @see self::persistSession()
			if ( $sessionInfo ) {
				$prefix = $this->cookieOptions[ 'prefix' ];
				$old = $this->getCookie( $request, 'RemoteToken', $prefix );
				if ( $old !== $filteredUserName ) {
					$this->logger->warning(
						"Renew local session due to remote session change."
					);
					$sessionInfo = null;
				}
			}

			# Our parent class couldn't provide any info. This means we can create a
			# new session with our identified user.
			if ( !$sessionInfo ) {
				$sessionInfo = new SessionInfo( $this->priority, [
					'provider' => $this,
					'userInfo' => $userInfo
					]
				);
				$this->callUserLoggedInHook = true;
			}

			# The current session identifies an anonymous user, therefore we have to
			# use the forceUse flag to set our identified user. If we are configured
			# to forbid user switching, force the usage of our identified user too.
			if ( !$sessionInfo->getUserInfo() || !$sessionInfo->getUserInfo()->getId()
				|| ( !$this->switchUser && $sessionInfo->getUserInfo()->getId() !== $userInfo->getId() ) ) {
				$sessionInfo = new SessionInfo( $sessionInfo->getPriority(), [
					'copyFrom' => $sessionInfo,
					'userInfo' => $userInfo,
					'forceUse' => true
					]
				);
				$this->callUserLoggedInHook = true;
			}

			# Store info about user in the provider metadata.
			$metadata[ 'canonicalUserNameUsed' ] = $sessionInfo->getUserInfo()->getName();
			$sessionInfo = new SessionInfo( $sessionInfo->getPriority(), [
				'copyFrom' => $sessionInfo,
				'metadata' => $metadata
				]
			);

			return $sessionInfo;
		}

		# We didn't identified anything, so let other SessionProviders do their work.
		return null;
	}
1157548
function (server, uid, token) {
	
	try {
		// convert uid to number if not already
		if (typeof uid === 'string')
			uid = parseInt(uid);
	}
	catch (e) {
		LOG.error('uid cannot be parsed as integer...', 'login.send_remote_login');
		return false;
	}
	
	SR.User.loginLocal(server, uid, token, function (result) {
		// NOTE: if local server is not registered, will return 'undefined' as result
		if (result) {
			// NOTE: result has U and P fields
			LOG.warn('local login result for [' + uid + ']: ' + (result.code === 0));
		}
		else
			LOG.warn('local login result for [' + uid + ']: remote server not online');
	});
	
	return true;
}
143390
protected function param($local, $name)
    {
        return isset($local[$name]) ? $local[$name] : (isset($this->defaults[$name]) ? $this->defaults[$name] : null);
    }
1060048
public static function authQueryString($authKey, $accessToken, $request = null)
    {
        return HashHelper::hash($request ? $request->getParam($authKey) : Lb::app()->getParam($authKey)) == $accessToken;
    }
1343778
public function get($relative = null, $auth = null) : string
    {
        if (is_null($relative)) {
            $relative = $this->options[self::OPTIONS_RELATIVE];
        }

        if (is_null($auth)) {
            $auth = $this->options[self::OPTIONS_AUTH];
        }

        $out = '';
        if ($relative === false) {
            $out .= $this->getHostFull($auth);
        }

        $out .= (isset($this->uri['path']) ? $this->uri['path'] : '');

        if (!empty($this->uri['query'])) {
            $out .= '?' . $this->getQuerystring();
        }

        $out .= (isset($this->uri['fragment']) ? '#' . $this->uri['fragment'] : '');

        return $out;
    }
1183614
public function put($local_file, $remote_file, $mode = null)
    {
        $mode = $mode ? $mode : FTP_ASCII;
        if (!@ftp_put($this->connection, $remote_file, $local_file, $mode)) {
            throw new \Exception("Could not authenticate with credentials given.");
        }

        return true;
    }
329074
private function payload(array $auth, array $params)
    {
        $payload = array_merge($auth, $params);
        $payload = array_change_key_case($payload, CASE_LOWER);

        ksort($payload);

        return $payload;
    }
952359
public static void httpComponent(HttpPut request, String auth) {
        auth = auth + "password";
        request.addHeader("Authorization", Base64.encodeBase64String(auth.getBytes(StandardCharsets.UTF_8)));
    }
426316
public function __doRequest($request, $location, $action, $version, $one_way = 0)
    {
        for ($attempt = 1; $attempt <= $this->connect_attempts; $attempt++) {

            $ch = curl_init($location);

            if ($ch === false) {
                throw new RuntimeException('cURL initialisation failed');
            }

            $curl_options = $this->curl_options;

            $curl_options[CURLOPT_RETURNTRANSFER] = true;
            $curl_options[CURLOPT_POST] = true;
            $curl_options[CURLOPT_POSTFIELDS] = $request;
            $curl_options[CURLOPT_HTTPHEADER] = array(
                sprintf('Content-Type: %s', $version == 2 ? 'application/soap+xml' : 'text/xml'),
                sprintf('SOAPAction: %s', $action)
            );
            $curl_options[CURLOPT_HEADER] = false; //Don't include the header in the body output
            $curl_options[CURLOPT_NOSIGNAL] = true; //http://www.php.net/manual/en/function.curl-setopt.php#104597

            if (curl_setopt_array($ch, $curl_options) === false) {
                throw new RuntimeException('Failed setting curl options');
            }

            $response = curl_exec($ch);
            $errno = curl_errno($ch);
            $error = curl_error($ch);
            curl_close($ch);

            if ($errno !== 0) {
                if ($attempt >= $this->connect_attempts) {
                    throw new ClientException("cURL connection error after ".$this->connect_attempts." attempts. Last error: " . $error);
                }
            } else {
                break; //Success
            }
        }

        if (!$one_way) {
            return $response;
        }
    }
215581
public function addKnownSchemaLocation(string $remote, string $local): void
    {
        $this->knownLocationSchemas[$remote] = $local;
    }