Retrieve an association. If no handle is specified, return the
association with the most recent issue time.

@param string $server_url
@param string|null $handle
@return Auth_OpenID_Association|mixed|null
965018
function getAssociation($server_url, $handle = null)
    {
        if (!$this->active) {
            trigger_error("FileStore no longer active", E_USER_ERROR);
            return null;
        }

        if ($handle === null) {
            $handle = '';
        }

        // The filename with the empty handle is a prefix of all other
        // associations for the given server URL.
        $filename = $this->getAssociationFilename($server_url, $handle);

        if ($handle) {
            return $this->_getAssociation($filename);
        } else {
            $association_files =
                Auth_OpenID_FileStore::_listdir($this->association_dir);
            $matching_files = array();

            // strip off the path to do the comparison
            $name = basename($filename);
            foreach ($association_files as $association_file) {
                $base = basename($association_file);
                if (strpos($base, $name) === 0) {
                    $matching_files[] = $association_file;
                }
            }

            $matching_associations = array();
            // read the matching files and sort by time issued
            foreach ($matching_files as $full_name) {
                $association = $this->_getAssociation($full_name);
                if ($association !== null) {
                    $matching_associations[] = array($association->issued,
                                                     $association);
                }
            }

            $issued = array();
            $assocs = array();
            foreach ($matching_associations as $key => $assoc) {
                $issued[$key] = $assoc[0];
                $assocs[$key] = $assoc[1];
            }

            array_multisort($issued, SORT_DESC, $assocs, SORT_DESC,
                            $matching_associations);

            // return the most recently issued one.
            if ($matching_associations) {
                list(, $assoc) = $matching_associations[0];
                return $assoc;
            } else {
                return null;
            }
        }
    }
673421
private static function getHandler(string $handler = null)
    {
        if (null === $handler) {
            return null;
        }

        if (!\in_array($handler, self::$handlers, true)) {
            throw new DatabaseException(
                sprintf(
                    'Cannot set "%s" as onDelete or onUpdate. Use one of these instead: "%s"',
                    $handler,
                    implode('", "', self::$handlers)
                )
            );
        }

        return $handler;
    }
681242
public function get($token)
    {
        foreach ($this->getDbConnection()->fetchAll(
            'SELECT * FROM oauth_refresh_token
            WHERE refresh_token = :token', [
                'token' => $token
            ]
        ) as $row) {
            if ($row) {
                return (new RefreshTokenEntity($this->server))
                    ->setAccessTokenId($row['access_token'])
                    ->setExpireTime($row['expire_time'])
                    ->setId($row['refresh_token']);
            }
        }
        return null;
    }
397990
protected function serverIpAddress($servers, $server_id)
    {
        $found_server = $this->searchServer($servers, 'forge_id', $server_id);
        return $found_server->first() ? $found_server->first()->ipAddress : null;
    }
1202434
public static function fetchIDFromHandle($handle)
    {
        return Symphony::Database()->fetchVar('id', 0, sprintf(
            "SELECT `id`
            FROM `tbl_pages`
            WHERE `handle` = '%s'
            LIMIT 1",
            Symphony::Database()->cleanValue($handle)
        ));
    }
61384
protected function loadUser($handle)
    {
        if (!$handle) {
            return null;
        }

        // Try to get user by ID
        $user = $this->modelFactory()->create(User::class);
        $user->load($handle);
        if ($user->id() !== null) {
            return $user;
        }

        // Try to get user by email
        $user->loadFrom('email', $handle);
        if ($user->id() !== null) {
            return $user;
        }

        return null;
    }
1189420
public Session getSession( JcrSessionHandle handle ) {
        if ((handles.size() > 0) && (handles.get(0) == handle)) {
            return session;
        }
        throw new java.lang.IllegalStateException("Inactive logical session handle called");
    }
231231
function useNonce($server_url, $timestamp, $salt)
    {
        global $Auth_OpenID_SKEW;

        // save one request to memcache when nonce obviously expired
        if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
            return false;
        }

        // returns false when nonce already exists
        // otherwise adds nonce
        return $this->connection->add(
            'openid_nonce_' . sha1($server_url) . '_' . sha1($salt),
            1, // any value here
            $this->compress,
            $Auth_OpenID_SKEW);
    }
673334
protected function findAuthHeader(array $server) {
        if (array_has($server, 'HTTP_AUTHORIZATION')) {
            return array_get($server, 'HTTP_AUTHORIZATION');
        } else if (array_has($server, 'REDIRECT_HTTP_AUTHORIZATION')) {
            return array_get($server, 'REDIRECT_HTTP_AUTHORIZATION');
        }

        return null;
    }
1245548
@Override
	public Object retrieve(int handle) throws DataStoreException
    {
        if (SAFE_MODE) checkHandle(handle);
        return data[handle];
    }
731589
public function getHeader($handle, array $options = [])
    {
        /** @var AbstractHttpRequest $request */
        $request          = $this->getRequest();
        $request->options = $options;
        $request->path    = $this->client->fullDatabasePath . static::API_PATH . '/' . $handle;
        $request->method  = static::METHOD_HEAD;

        return $this->getReturnObject($request);
    }
1186720
public function getOauthRedirect($redirect_url, $state = '', $scope = 'snsapi_base')
    {
        $appid = $this->config->get('appid');
        $redirect_uri = urlencode($redirect_url);
        return "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$appid}&redirect_uri={$redirect_uri}&response_type=code&scope={$scope}&state={$state}#wechat_redirect";
    }
1331272
private function _getProviderRecordByHandle($handle)
    {
        $providerRecord = Oauth_ProviderInfosRecord::model()->find(

            // conditions
            'class=:provider',

            // params
            array(
                ':provider' => $handle
            )
        );

        if($providerRecord)
        {
            return $providerRecord;
        }

        return null;
    }
1057132
function(handle) {
        if (!isValidID(handle)) return null;

        var i, j, instance;
        for (i = 0, j = instances.length; i < j; i++) {
          instance = instances[i];
          if (instance.$$mdHandle === handle) {
            return instance;
          }
        }
        return null;
      }
1219443
public function getByHandle($handle)
    {
        return isset($this->converters[$handle]) ? $this->converters[$handle] : null;
    }
1240557
public function getProviderInfos($handle)
    {
        $record = $this->_getProviderRecordByHandle($handle);

        if($record)
        {
            return Oauth_ProviderInfosModel::populateModel($record);
        }
        else
        {
            $configProviderInfos = craft()->config->get('providerInfos', 'oauth');

            if(isset($configProviderInfos[$handle]))
            {
                $attributes = [];

                if(isset($configProviderInfos[$handle]['clientId']))
                {
                    $attributes['clientId'] = $configProviderInfos[$handle]['clientId'];
                }

                if(isset($configProviderInfos[$handle]['clientSecret']))
                {
                    $attributes['clientSecret'] = $configProviderInfos[$handle]['clientSecret'];
                }

                return Oauth_ProviderInfosModel::populateModel($attributes);
            }
        }
    }
1346610
private function getHandle()
    {
        // make sure to clean up old handles
        if ($this->handle !== null && feof($this->handle)) {
            $this->resetHandle();
        }

        // provision new handle
        if ($this->handle == null) {
            $params = $this->params;
            if (!empty($this->getResourceVersion())) {
                $params['resourceVersion'] = $this->getResourceVersion();
            }
            $query = http_build_query($params);
            $base = $this->getClient()->getConfig()->getServer().$this->endpoint;
            $url = $base;

            if (!empty($query)) {
                $parsed = parse_url($base);
                if (key_exists('query', $parsed) || substr($base, -1) == "?") {
                    $url .= '&'.$query;
                } else {
                    $url .= '?'.$query;
                }
            }
            $handle = @fopen($url, 'r', false, $this->getClient()->getStreamContext());
            if ($handle === false) {
                $e = error_get_last();
                throw new \Exception($e['message'], $e['type']);
            }
            stream_set_timeout($handle, 0, $this->getStreamTimeout());
            $this->handle = $handle;
        }

        return $this->handle;
    }