Skip to content
Snippets Groups Projects
Commit 1071c4a2 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Psalm: fix ParamNameMismatch (4x)

parent 3e46ee41
No related branches found
No related tags found
No related merge requests found
...@@ -296,7 +296,7 @@ class MetaDataStorageHandler implements ClearableState ...@@ -296,7 +296,7 @@ class MetaDataStorageHandler implements ClearableState
* This function looks up the metadata for the given entity id in the given set. It will throw an * This function looks up the metadata for the given entity id in the given set. It will throw an
* exception if it is unable to locate the metadata. * exception if it is unable to locate the metadata.
* *
* @param string|null $index The entity id we are looking up. This parameter may be NULL, in which case we look up * @param string|null $entityId The entity id we are looking up. This parameter may be NULL, in which case we look up
* the current entity id based on the current hostname/path. * the current entity id based on the current hostname/path.
* @param string $set The set of metadata we are looking up the entity id in. * @param string $set The set of metadata we are looking up the entity id in.
* *
...@@ -304,33 +304,33 @@ class MetaDataStorageHandler implements ClearableState ...@@ -304,33 +304,33 @@ class MetaDataStorageHandler implements ClearableState
* @throws \Exception If metadata for the specified entity is expired. * @throws \Exception If metadata for the specified entity is expired.
* @throws \SimpleSAML\Error\MetadataNotFound If no metadata for the entity specified can be found. * @throws \SimpleSAML\Error\MetadataNotFound If no metadata for the entity specified can be found.
*/ */
public function getMetaData(?string $index, string $set): array public function getMetaData(?string $entityId, string $set): array
{ {
if ($index === null) { if ($entityId === null) {
$index = $this->getMetaDataCurrentEntityID($set, 'metaindex'); $entityId = $this->getMetaDataCurrentEntityID($set, 'metaindex');
} }
foreach ($this->sources as $source) { foreach ($this->sources as $source) {
$metadata = $source->getMetaData($index, $set); $metadata = $source->getMetaData($entityId, $set);
if ($metadata !== null) { if ($metadata !== null) {
if (array_key_exists('expire', $metadata)) { if (array_key_exists('expire', $metadata)) {
if ($metadata['expire'] < time()) { if ($metadata['expire'] < time()) {
throw new \Exception( throw new \Exception(
'Metadata for the entity [' . $index . '] expired ' . 'Metadata for the entity [' . $entityId . '] expired ' .
(time() - $metadata['expire']) . ' seconds ago.' (time() - $metadata['expire']) . ' seconds ago.'
); );
} }
} }
$metadata['metadata-index'] = $index; $metadata['metadata-index'] = $entityId;
$metadata['metadata-set'] = $set; $metadata['metadata-set'] = $set;
Assert::keyExists($metadata, 'entityid'); Assert::keyExists($metadata, 'entityid');
return $metadata; return $metadata;
} }
} }
throw new Error\MetadataNotFound($index); throw new Error\MetadataNotFound($entityId);
} }
......
...@@ -176,7 +176,7 @@ abstract class MetaDataStorageSource ...@@ -176,7 +176,7 @@ abstract class MetaDataStorageSource
foreach ($metadataSet as $index => $entry) { foreach ($metadataSet as $index => $entry) {
$cidrHints = []; $cidrHints = [];
// support hint.cidr for idp discovery // support hint.cidr for idp discovery
if (array_key_exists('hint.cidr', $entry) && is_array($entry['hint.cidr'])) { if (array_key_exists('hint.cidr', $entry) && is_array($entry['hint.cidr'])) {
$cidrHints = $entry['hint.cidr']; $cidrHints = $entry['hint.cidr'];
...@@ -220,17 +220,17 @@ abstract class MetaDataStorageSource ...@@ -220,17 +220,17 @@ abstract class MetaDataStorageSource
* override this function if it doesn't implement the getMetadataSet function, or if the * override this function if it doesn't implement the getMetadataSet function, or if the
* implementation of getMetadataSet is slow. * implementation of getMetadataSet is slow.
* *
* @param string $index The entityId or metaindex we are looking up. * @param string $entityId The entityId or metaindex we are looking up.
* @param string $set The set we are looking for metadata in. * @param string $set The set we are looking for metadata in.
* *
* @return array|null An associative array with metadata for the given entity, or NULL if we are unable to * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to
* locate the entity. * locate the entity.
*/ */
public function getMetaData(string $index, string $set): ?array public function getMetaData(string $entityId, string $set): ?array
{ {
$metadataSet = $this->getMetadataSet($set); $metadataSet = $this->getMetadataSet($set);
$indexLookup = $this->lookupIndexFromEntityId($index, $metadataSet); $indexLookup = $this->lookupIndexFromEntityId($entityId, $metadataSet);
if (isset($indexLookup) && array_key_exists($indexLookup, $metadataSet)) { if (isset($indexLookup) && array_key_exists($indexLookup, $metadataSet)) {
return $metadataSet[$indexLookup]; return $metadataSet[$indexLookup];
} }
......
...@@ -235,7 +235,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource ...@@ -235,7 +235,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
* override this function if it doesn't implement the getMetadataSet function, or if the * override this function if it doesn't implement the getMetadataSet function, or if the
* implementation of getMetadataSet is slow. * implementation of getMetadataSet is slow.
* *
* @param string $index The entityId or metaindex we are looking up. * @param string $entityId The entityId or metaindex we are looking up.
* @param string $set The set we are looking for metadata in. * @param string $set The set we are looking for metadata in.
* *
* @return array|null An associative array with metadata for the given entity, or NULL if we are unable to * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to
...@@ -243,13 +243,13 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource ...@@ -243,13 +243,13 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
* @throws \Exception If an error occurs while validating the signature or the metadata is in an * @throws \Exception If an error occurs while validating the signature or the metadata is in an
* incorrect set. * incorrect set.
*/ */
public function getMetaData(string $index, string $set): ?array public function getMetaData(string $entityId, string $set): ?array
{ {
Logger::info(__CLASS__ . ': loading metadata entity [' . $index . '] from [' . $set . ']'); Logger::info(__CLASS__ . ': loading metadata entity [' . $entityId . '] from [' . $set . ']');
// read from cache if possible // read from cache if possible
try { try {
$data = $this->getFromCache($set, $index); $data = $this->getFromCache($set, $entityId);
} catch (\Exception $e) { } catch (\Exception $e) {
Logger::error($e->getMessage()); Logger::error($e->getMessage());
// proceed with fetching metadata even if the cache is broken // proceed with fetching metadata even if the cache is broken
...@@ -263,14 +263,14 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource ...@@ -263,14 +263,14 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
if (isset($data)) { if (isset($data)) {
// metadata found in cache and not expired // metadata found in cache and not expired
Logger::debug(__CLASS__ . ': using cached metadata for: ' . $index . '.'); Logger::debug(__CLASS__ . ': using cached metadata for: ' . $entityId . '.');
return $data; return $data;
} }
// look at Metadata Query Protocol: https://github.com/iay/md-query/blob/master/draft-young-md-query.txt // look at Metadata Query Protocol: https://github.com/iay/md-query/blob/master/draft-young-md-query.txt
$mdq_url = $this->server . '/entities/' . urlencode($index); $mdq_url = $this->server . '/entities/' . urlencode($entityId);
Logger::debug(__CLASS__ . ': downloading metadata for "' . $index . '" from [' . $mdq_url . ']'); Logger::debug(__CLASS__ . ': downloading metadata for "' . $entityId . '" from [' . $mdq_url . ']');
try { try {
$xmldata = Utils\HTTP::fetch($mdq_url); $xmldata = Utils\HTTP::fetch($mdq_url);
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -280,7 +280,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource ...@@ -280,7 +280,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
if (empty($xmldata)) { if (empty($xmldata)) {
$error = error_get_last(); $error = error_get_last();
Logger::info('Unable to fetch metadata for "' . $index . '" from ' . $mdq_url . ': ' . Logger::info('Unable to fetch metadata for "' . $entityId . '" from ' . $mdq_url . ': ' .
(is_array($error) ? $error['message'] : 'no error available')); (is_array($error) ? $error['message'] : 'no error available'));
return null; return null;
} }
...@@ -291,11 +291,11 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource ...@@ -291,11 +291,11 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
$data = self::getParsedSet($entity, $set); $data = self::getParsedSet($entity, $set);
if ($data === null) { if ($data === null) {
throw new \Exception(__CLASS__ . ': no metadata for set "' . $set . '" available from "' . $index . '".'); throw new \Exception(__CLASS__ . ': no metadata for set "' . $set . '" available from "' . $entityId . '".');
} }
try { try {
$this->writeToCache($set, $index, $data); $this->writeToCache($set, $entityId, $data);
} catch (\Exception $e) { } catch (\Exception $e) {
// Proceed without writing to cache // Proceed without writing to cache
Logger::error('Error writing MDQ result to cache: ' . $e->getMessage()); Logger::error('Error writing MDQ result to cache: ' . $e->getMessage());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment