ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleSAML_Metadata_MetaDataStorageSource Class Reference
+ Inheritance diagram for SimpleSAML_Metadata_MetaDataStorageSource:
+ Collaboration diagram for SimpleSAML_Metadata_MetaDataStorageSource:

Public Member Functions

 getMetadataSet ($set)
 This function attempts to generate an associative array with metadata for all entities in the given set. More...
 
 getEntityIdFromHostPath ($hostPath, $set, $type='entityid')
 This function resolves an host/path combination to an entity id. More...
 
 getPreferredEntityIdFromCIDRhint ($set, $ip, $type='entityid')
 This function will go through all the metadata, and check the DiscoHints->IPHint parameter, which defines a network space (ip range) for each remote entry. More...
 
 getMetaData ($index, $set)
 This function retrieves metadata for the given entity id in the given set of metadata. More...
 

Static Public Member Functions

static parseSources ($sourcesConfig)
 Parse array with metadata sources. More...
 
static getSource ($sourceConfig)
 This function creates a metadata source based on the given configuration. More...
 

Private Member Functions

 lookupIndexFromEntityId ($entityId, $set)
 

Detailed Description

Definition at line 15 of file MetaDataStorageSource.php.

Member Function Documentation

◆ getEntityIdFromHostPath()

SimpleSAML_Metadata_MetaDataStorageSource::getEntityIdFromHostPath (   $hostPath,
  $set,
  $type = 'entityid' 
)

This function resolves an host/path combination to an entity id.

This class implements this function using the getMetadataSet-function. A subclass should override this function if it doesn't implement the getMetadataSet function, or if the implementation of getMetadataSet is slow.

Parameters
string$hostPathThe host/path combination we are looking up.
string$setWhich set of metadata we are looking it up in.
string$typeDo you want to return the metaindex or the entityID. [entityid|metaindex]
Returns
string|null An entity id which matches the given host/path combination, or NULL if we are unable to locate one which matches.

Definition at line 132 of file MetaDataStorageSource.php.

References $index, $type, and getMetadataSet().

133  {
134 
135  $metadataSet = $this->getMetadataSet($set);
136  if ($metadataSet === null) {
137  // this metadata source does not have this metadata set
138  return null;
139  }
140 
141  foreach ($metadataSet as $index => $entry) {
142  if (!array_key_exists('host', $entry)) {
143  continue;
144  }
145 
146  if ($hostPath === $entry['host']) {
147  if ($type === 'entityid') {
148  return $entry['entityid'];
149  } else {
150  return $index;
151  }
152  }
153  }
154 
155  // no entries matched, we should return null
156  return null;
157  }
$type
$index
Definition: metadata.php:60
getMetadataSet($set)
This function attempts to generate an associative array with metadata for all entities in the given s...
+ Here is the call graph for this function:

◆ getMetaData()

SimpleSAML_Metadata_MetaDataStorageSource::getMetaData (   $index,
  $set 
)

This function retrieves metadata for the given entity id in the given set of metadata.

It will return NULL if it is unable to locate the metadata.

This class implements this function using the getMetadataSet-function. A subclass should override this function if it doesn't implement the getMetadataSet function, or if the implementation of getMetadataSet is slow.

Parameters
string$indexThe entityId or metaindex we are looking up.
string$setThe set we are looking for metadata in.
Returns
array An associative array with metadata for the given entity, or NULL if we are unable to locate the entity.

Definition at line 256 of file MetaDataStorageSource.php.

References $index, getMetadataSet(), and lookupIndexFromEntityId().

257  {
258 
259  assert(is_string($index));
260  assert(isset($set));
261 
262  $metadataSet = $this->getMetadataSet($set);
263 
264  if (array_key_exists($index, $metadataSet)) {
265  return $metadataSet[$index];
266  }
267 
268  $indexlookup = $this->lookupIndexFromEntityId($index, $set);
269  if (isset($indexlookup) && array_key_exists($indexlookup, $metadataSet)) {
270  return $metadataSet[$indexlookup];
271  }
272 
273  return null;
274  }
$index
Definition: metadata.php:60
getMetadataSet($set)
This function attempts to generate an associative array with metadata for all entities in the given s...
+ Here is the call graph for this function:

◆ getMetadataSet()

SimpleSAML_Metadata_MetaDataStorageSource::getMetadataSet (   $set)

This function attempts to generate an associative array with metadata for all entities in the given set.

The key of the array is the entity id.

A subclass should override this function if it is able to easily generate this list.

Parameters
string$setThe set we want to list metadata for.
Returns
array An associative array with all entities in the given set, or an empty array if we are unable to generate this list.

Definition at line 112 of file MetaDataStorageSource.php.

Referenced by getEntityIdFromHostPath(), getMetaData(), getPreferredEntityIdFromCIDRhint(), and lookupIndexFromEntityId().

113  {
114  return array();
115  }
+ Here is the caller graph for this function:

◆ getPreferredEntityIdFromCIDRhint()

SimpleSAML_Metadata_MetaDataStorageSource::getPreferredEntityIdFromCIDRhint (   $set,
  $ip,
  $type = 'entityid' 
)

This function will go through all the metadata, and check the DiscoHints->IPHint parameter, which defines a network space (ip range) for each remote entry.

This function returns the entityID for any of the entities that have an IP range which the IP falls within.

Parameters
string$setWhich set of metadata we are looking it up in.
string$ipIP address
string$typeDo you want to return the metaindex or the entityID. [entityid|metaindex]
Returns
string The entity id of a entity which have a CIDR hint where the provided IP address match.

Definition at line 173 of file MetaDataStorageSource.php.

References $index, $type, and getMetadataSet().

174  {
175 
176  $metadataSet = $this->getMetadataSet($set);
177 
178  foreach ($metadataSet as $index => $entry) {
179  $cidrHints = array();
180 
181  // support hint.cidr for idp discovery
182  if (array_key_exists('hint.cidr', $entry) && is_array($entry['hint.cidr'])) {
183  $cidrHints = $entry['hint.cidr'];
184  }
185 
186  // support discohints in idp metadata for idp discovery
187  if (array_key_exists('DiscoHints', $entry)
188  && array_key_exists('IPHint', $entry['DiscoHints'])
189  && is_array($entry['DiscoHints']['IPHint'])) {
190  // merge with hints derived from discohints, but prioritize hint.cidr in case it is used
191  $cidrHints = array_merge($entry['DiscoHints']['IPHint'], $cidrHints);
192  }
193 
194  if (empty($cidrHints)) {
195  continue;
196  }
197 
198  foreach ($cidrHints as $hint_entry) {
199  if (SimpleSAML\Utils\Net::ipCIDRcheck($hint_entry, $ip)) {
200  if ($type === 'entityid') {
201  return $entry['entityid'];
202  } else {
203  return $index;
204  }
205  }
206  }
207  }
208 
209  // no entries matched, we should return null
210  return null;
211  }
$type
$index
Definition: metadata.php:60
Attribute-related utility methods.
getMetadataSet($set)
This function attempts to generate an associative array with metadata for all entities in the given s...
+ Here is the call graph for this function:

◆ getSource()

static SimpleSAML_Metadata_MetaDataStorageSource::getSource (   $sourceConfig)
static

This function creates a metadata source based on the given configuration.

The type of source is based on the 'type' parameter in the configuration. The default type is 'flatfile'.

Parameters
array$sourceConfigAssociative array with the configuration for this metadata source.
Returns
mixed An instance of a metadata source with the given configuration.
Exceptions
ExceptionIf the metadata source type is invalid.

Definition at line 60 of file MetaDataStorageSource.php.

References $type, and SimpleSAML\Module\resolveClass().

Referenced by metarefresh_hook_cron().

61  {
62  assert(is_array($sourceConfig));
63 
64  if (array_key_exists('type', $sourceConfig)) {
65  $type = $sourceConfig['type'];
66  } else {
67  $type = 'flatfile';
68  }
69 
70  switch ($type) {
71  case 'flatfile':
73  case 'xml':
74  return new SimpleSAML_Metadata_MetaDataStorageHandlerXML($sourceConfig);
75  case 'serialize':
77  case 'mdx':
78  case 'mdq':
79  return new \SimpleSAML\Metadata\Sources\MDQ($sourceConfig);
80  case 'pdo':
81  return new SimpleSAML_Metadata_MetaDataStorageHandlerPdo($sourceConfig);
82  default:
83  // metadata store from module
84  try {
86  $type,
87  'MetadataStore',
88  'SimpleSAML_Metadata_MetaDataStorageSource'
89  );
90  } catch (Exception $e) {
92  "Invalid 'type' for metadata source. Cannot find store '$type'.",
93  null
94  );
95  }
96  return new $className($sourceConfig);
97  }
98  }
$type
static resolveClass($id, $type, $subclass=null)
Resolve module class.
Definition: Module.php:169
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupIndexFromEntityId()

SimpleSAML_Metadata_MetaDataStorageSource::lookupIndexFromEntityId (   $entityId,
  $set 
)
private

Definition at line 217 of file MetaDataStorageSource.php.

References $entityId, $index, getMetadataSet(), and SimpleSAML\Utils\HTTP\getSelfHost().

Referenced by getMetaData().

218  {
219  assert(is_string($entityId));
220  assert(isset($set));
221 
222  $metadataSet = $this->getMetadataSet($set);
223 
224  // check for hostname
225  $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org
226 
227  foreach ($metadataSet as $index => $entry) {
228  if ($index === $entityId) {
229  return $index;
230  }
231  if ($entry['entityid'] === $entityId) {
232  if ($entry['host'] === '__DEFAULT__' || $entry['host'] === $currenthost) {
233  return $index;
234  }
235  }
236  }
237 
238  return null;
239  }
$index
Definition: metadata.php:60
getMetadataSet($set)
This function attempts to generate an associative array with metadata for all entities in the given s...
static getSelfHost()
Retrieve our own host.
Definition: HTTP.php:697
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseSources()

static SimpleSAML_Metadata_MetaDataStorageSource::parseSources (   $sourcesConfig)
static

Parse array with metadata sources.

This function accepts an array with metadata sources, and returns an array with each metadata source as an object.

Parameters
array$sourcesConfigArray with metadata source configuration.
Returns
array Parsed metadata configuration.
Exceptions
ExceptionIf something is wrong in the configuration.

Definition at line 31 of file MetaDataStorageSource.php.

Referenced by SimpleSAML_Metadata_MetaDataStorageHandler\__construct().

32  {
33  assert(is_array($sourcesConfig));
34 
35  $sources = array();
36 
37  foreach ($sourcesConfig as $sourceConfig) {
38  if (!is_array($sourceConfig)) {
39  throw new Exception("Found an element in metadata source configuration which wasn't an array.");
40  }
41 
42  $sources[] = self::getSource($sourceConfig);
43  }
44 
45  return $sources;
46  }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: