Gets the logoURL entries from the IDP's metadata and adds them to
the sources array that is available to the multiauth page.
Doesn't add an entry at all, if it is missing or invalid.

@param array &$sources
516433
public static function addIdpLogoUrls(
        &$sources, 
        $authSourcesConfig, 
        $metadataPath
    ) {     
        
        $idpMetadata = Metadata::getIdpMetadataEntries($metadataPath);
        $idpEntries = self::getIdpsFromAuthSources($authSourcesConfig);      

        foreach ($sources as &$source) {
            $idpLabel = $source['source'];
            $idpEntityId = $idpEntries[$idpLabel];    
            
            // If there is no entry for the idp in saml20-idp-remote.php, skip it
            if ( ! isset($idpMetadata[$idpEntityId])) {
                continue;
            }
            $idpMdEntry = $idpMetadata[$idpEntityId];
            
            // If there is no logo URL entry in the metadata, skip it
            if ( ! isset($idpMdEntry[Utils::IDP_LOGO_KEY])) {
                continue;
            }        

            $logoURL = $idpMdEntry[Utils::IDP_LOGO_KEY];
            
            // sanitize the url (remove bad characters and just return false if it's not a string)
            $logoURL = filter_var($logoURL, FILTER_SANITIZE_URL);
            $source[Utils::IDP_LOGO_KEY] = $logoURL;
        }  
    }
230603
public function getAuthorizationUrl($scopes = [])
    {
        $this->provider;
        $authorizationUrl = $this->provider->getAuthorizationUrl([
            'scope' => join(' ', $scopes)
        ]);
        $_SESSION['oauth2_lockme_state'] = $this->provider->getState();
        return $authorizationUrl;
    }
1155340
private function assureUuids(array $resources): array {
        echo self::$debug ? "Assuring all resources to be imported have ACDH UUIDs...\n" : '';

        $result = array();
        $map    = array();
        foreach ($resources as $n => $res) {
            echo self::$debug ? "\t" . $res->getUri() . " (" . ($n + 1) . "/" . count($resources) . ")\n" : '';

            $ids = array();
            foreach ($res->allResources(RC::idProp()) as $id) {
                $ids[] = $id->getUri();
            }

            $found = 'found';
            try {
                $fedoraRes = $this->fedora->getResourceByIds($ids);
            } catch (NotFound $e) {
                $meta  = (new Graph())->resource('.');
                $title = 'title stub created by the MetadataCollection';
                foreach ($ids as $id) {
                    $meta->addResource(RC::idProp(), $id);
                    if (strpos($id, RC::get('fedoraIdNamespace')) === 0) {
                        $title = substr($id, strlen(RC::get('fedoraIdNamespace')));
                    }
                }
                $meta->addLiteral(RC::titleProp(), $title);
                $fedoraRes = $this->fedora->createResource($meta);
                $found     = 'new';
                $this->handleAutoCommit();
            }
            echo self::$debug ? "\t\t" . $found . ' ' . $fedoraRes->getId() . "\n" : '';

            $uuid                   = $fedoraRes->getId();
            $result[$res->getUri()] = $fedoraRes;
            $map[$res->getUri()]    = $uuid;
            foreach ($ids as $id) {
                $map[$id] = $uuid;
            }
        }

        echo self::$debug ? "Mapping objects to ACDH UUIDs...\n" : '';
        foreach ($resources as $res) {
            $properties = array_diff($res->propertyUris($res), array(RC::idProp()));
            foreach ($properties as $prop) {
                foreach ($res->allResources($prop) as $value) {
                    $uri = $value->getUri();
                    if (isset($map[$uri])) {
                        $res->delete($prop, $value);
                        $res->addResource($prop, $map[$uri]);
                        echo self::$debug ? "\t" . $res->getUri() . " " . $prop . " " . $uri . " to " . $map[$uri] . "\n" : '';
                    }
                }
            }
        }

        return $result;
    }
70235
private function getUrlGenerator($sourceUrl)
    {
        foreach ($this->urlGenerators as $urlGenerator) {
            if ($urlGenerator->supports($sourceUrl)) {
                return $urlGenerator;
            }
        }

        return null;
    }
1206283
public function getSitesIdFromSiteUrlHavingAccess($login, $urls)
    {
        $siteUrlTable  = Common::prefixTable('site_url');
        $sqlAccessSite = Access::getSqlAccessSite('idsite');

        $db = $this->getDb();
        $ids = $db->fetchAll(
            'SELECT idsite
                FROM ' . $this->table . '
                    WHERE main_url IN ( ' . Common::getSqlStringFieldsArray($urls) . ')' .
            'AND idsite IN (' . $sqlAccessSite . ') ' .
            'UNION
                SELECT idsite
                FROM ' . $siteUrlTable . '
                    WHERE url IN ( ' . Common::getSqlStringFieldsArray($urls) . ')' .
            'AND idsite IN (' . $sqlAccessSite . ')',

            // Bind
            array_merge(    $urls,
                            array( $login ),
                            $urls,
                            array( $login )
            )
        );

        return $ids;
    }
1080515
public function getFollowersIds(array $parameters = array(), $multipart = false, $appOnlyAuth = false)
    {
        return $this->get('followers/ids', $parameters, $multipart, $appOnlyAuth);
    }
763856
public function get_request_token_secret(array $identifiers) {

        if (empty($identifiers) || empty($identifiers['caller'])) {
            throw new coding_exception('Invalid call identification');
        }

        $cache = cache::make_from_params(cache_store::MODE_SESSION, 'core', 'flickrclient', $identifiers);

        return $cache->get('request_token_secret');
    }
623767
protected function printSyncMap($multisites) {
    $this->say("Sync operations be performed for the following drush aliases:");
    $sync_map = [];
    foreach ($multisites as $multisite) {
      $this->switchSiteContext($multisite);
      $sync_map[$multisite]['local'] = '@' . $this->getConfigValue('drush.aliases.local');
      $sync_map[$multisite]['remote'] = '@' . $this->getConfigValue('drush.aliases.remote');
      $this->say("  * <comment>" . $sync_map[$multisite]['remote'] . "</comment> => <comment>" . $sync_map[$multisite]['local'] . "</comment>");
    }
    $this->say("To modify the set of aliases for syncing, set the values for drush.aliases.local and drush.aliases.remote in docroot/sites/[site]/blt.yml");
  }
1234609
public function getLogoutURI($params = array()) {
        $default_params = array(
            'redirect_uri'=> $this->getCurrentURI(),
            'oauth_token' => $this->getAccessToken()
        );
        if ($this->xiti) {
            $default_params['xiti_json'] = $this->getXitiConfiguration();
        }
        $default_params['v'] = self::VERSION;
        return $this->getUrl('www', 'logout', array_merge($default_params, $params));
    }
1363191
public function getAuthLoginUrl($name, $params = array())
	{
		return static::AUTH_DOMAIN . $name . (empty($params) ? '' : ('?' . $this->http_build_query($params)));
	}
788965
private function getFields1Source(Source $source, $localEntryInfo)
    {
        $this->resetStatus();
        // Get invoice status field and other invoice status related info.
        $statusInfo = $this->getInvoiceStatusInfo($localEntryInfo);

        $this->setStatus($statusInfo['severity'], $statusInfo['severity-message']);
        /** @var string $invoiceStatus */
        $invoiceStatus = $statusInfo['status'];
        /** @var string $statusText */
        $statusText = $statusInfo['text'];
        /** @var string $statusDescription */
        $statusDescription = $statusInfo['description'];
        /** @var Result|null $result */
        $result = $statusInfo['result'];
        /** @var array $entry */
        $entry = $statusInfo['entry'];

        // Create and add additional fields based on invoice status.
        switch ($invoiceStatus) {
            case static::Invoice_NotSent:
                $additionalFields = $this->getNotSentFields($source);
                break;
            case static::Invoice_SentConcept:
                $additionalFields = $this->getConceptFields($source);
                break;
            case static::Invoice_CommunicationError:
                /** @noinspection PhpUndefinedVariableInspection */
                $additionalFields = $this->getCommunicationErrorFields($result);
                break;
            case static::Invoice_NonExisting:
                $additionalFields = $this->getNonExistingFields($source);
                break;
            case static::Invoice_Deleted:
                $additionalFields = $this->getDeletedFields($source);
                break;
            case static::Invoice_Sent:
                $additionalFields = $this->getEntryFields($source, $localEntryInfo, $entry);
                break;
            default:
                $additionalFields = array(
                    'unknown' => array(
                        'type' => 'markup',
                        'value' => sprintf($this->t('invoice_status_unknown'), $invoiceStatus),
                    )
                );
                break;
        }

        // Create main status field after we have the other fields, so we can
        // use the results in rendering the overall status.
        $fields = array(
            'status' => array(
                'type' => 'markup',
                'label' => $this->getStatusIcon($this->status),
                'attributes' => array(
                    'class' => str_replace('_', '-', $invoiceStatus),
                    'label' => $this->getStatusLabelAttributes($this->status, $this->statusMessage),
                ),
                'value' => $statusText,
                'description' => $statusDescription,
            ),
        ) + $additionalFields;
        return $fields;
    }
125518
protected function addIdentifierToTags(string $entryIdentifier, array $tags)
    {
        foreach ($tags as $tag) {
            // Update tag-to-identifier index
            $identifiers = $this->findIdentifiersByTag($tag);
            if (array_search($entryIdentifier, $identifiers) === false) {
                $identifiers[] = $entryIdentifier;
                $this->memcache->set($this->identifierPrefix . 'tag_' . $tag, $identifiers);
            }

            // Update identifier-to-tag index
            $existingTags = $this->findTagsByIdentifier($entryIdentifier);
            if (array_search($tag, $existingTags) === false) {
                $this->memcache->set($this->identifierPrefix . 'ident_' . $entryIdentifier, array_merge($existingTags, $tags));
            }
        }
    }
912054
public function loginpage_idp_list($wantsurl) {
        if (empty($this->config->hostname)) {
            // CAS is not configured.
            return [];
        }

        $iconurl = moodle_url::make_pluginfile_url(
            context_system::instance()->id,
            'auth_cas',
            'logo',
            null,
            '/',
            $this->config->auth_logo);

        return [
            [
                'url' => new moodle_url(get_login_url(), [
                        'authCAS' => 'CAS',
                    ]),
                'iconurl' => $iconurl,
                'name' => format_string($this->config->auth_name),
            ],
        ];
    }
1331827
protected function mergeMetadata($source, $target)
    {
        if ($source instanceof \ArrayAccess) {
            if ($target instanceof \ArrayAccess) {
                if ($source instanceof MetadataInterface) {
                    $metadata = $source->getMetadata();
                    foreach ($metadata as $offset => $value) {
                        $target->offsetSet($offset, $value);
                    }
                } else {
                    throw new \RuntimeException('Source had to make all metadata available!');
                }
            } else {
                throw new \RuntimeException('Source metadata can not be merged!');
            }
        }
    }
1055977
public static function findingSecurityMarksName($organization, $source, $finding)
    {
        return self::getFindingSecurityMarksNameTemplate()->render([
            'organization' => $organization,
            'source' => $source,
            'finding' => $finding,
        ]);
    }
510119
public function getIdentityVerificationAttributes($identities)
    {
        $this->_action = 'GetIdentityVerificationAttributes';
        $this->_method = 'GET';
        $this->_refreshDate();

        $parameters = array();

        $index = 1;
        if (is_array($identities)) {
            foreach ($identities as $identity) {
                if (!(filter_var($identity, FILTER_VALIDATE_EMAIL) || preg_match('/^([a-z\d]+(-[a-z\d]+)*\.)+[a-z]{2,}$/', $identity))) {
                    throw new Exception('Identity must be EmailAddress or Domain');
                    return;
                }
                $parameters['Identities.member.' . $index] = $identity;
                $index++;
            }
        }

        $this->_generateSignature($parameters);
        $res = $this->_request();
        if ($res['code'] == 200) {
            $entries = $res['body']->GetIdentityVerificationAttributesResult->VerificationAttributes->entry;
            $ret = array();
            foreach ($entries as $entry) {
                $ret[] = array(
                    'Email' => (string) $entry->key,
                    'Token' => (string) $entry->value->VerificationToken,
                    'Status' => (string) $entry->value->VerificationStatus
                );
            }
            return $ret;
        } else {
            return new SimpleEmailServiceError((string) $res['body']->Error->Code);
        }
    }
602178
public function getCredentials(array $parameters = array(), $multipart = false, $appOnlyAuth = false)
    {
        return $this->getAccountVerifyCredentials($parameters, $multipart, $appOnlyAuth);
    }