ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SimpleSAML_Metadata_MetaDataStorageHandler Class Reference
+ Collaboration diagram for SimpleSAML_Metadata_MetaDataStorageHandler:

Public Member Functions

 getGenerated ($property, $set)
 This function is used to generate some metadata elements automatically. More...
 
 getList ($set='saml20-idp-remote')
 This function lists all known metadata in the given set. More...
 
 getMetaDataCurrent ($set)
 This function retrieves metadata for the current entity based on the hostname/path the request was directed to. More...
 
 getMetaDataCurrentEntityID ($set, $type='entityid')
 This function locates the current entity id based on the hostname/path combination the user accessed. More...
 
 getPreferredEntityIdFromCIDRhint ($set, $ip)
 This method will call getPreferredEntityIdFromCIDRhint() on all of the sources. More...
 
 getMetaData ($index, $set)
 This function looks up the metadata for the given entity id in the given set. More...
 
 getMetaDataConfig ($entityId, $set)
 Retrieve the metadata as a configuration object. More...
 
 getMetaDataConfigForSha1 ($sha1, $set)
 Search for an entity's metadata, given the SHA1 digest of its entity ID. More...
 

Static Public Member Functions

static getMetadataHandler ()
 This function retrieves the current instance of the metadata handler. More...
 

Protected Member Functions

 __construct ()
 This constructor initializes this metadata storage handler. More...
 

Private Attributes

 $sources
 

Static Private Attributes

static $metadataHandler = null
 

Detailed Description

Definition at line 10 of file MetaDataStorageHandler.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML_Metadata_MetaDataStorageHandler::__construct ( )
protected

This constructor initializes this metadata storage handler.

It will load and parse the configuration, and initialize the metadata source list.

Definition at line 54 of file MetaDataStorageHandler.php.

References $config, $type, array, SimpleSAML_Configuration\getInstance(), and SimpleSAML_Metadata_MetaDataStorageSource\parseSources().

55  {
57 
58  $sourcesConfig = $config->getArray('metadata.sources', null);
59 
60  // for backwards compatibility, and to provide a default configuration
61  if ($sourcesConfig === null) {
62  $type = $config->getString('metadata.handler', 'flatfile');
63  $sourcesConfig = array(array('type' => $type));
64  }
65 
66  try {
67  $this->sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesConfig);
68  } catch (Exception $e) {
69  throw new Exception(
70  "Invalid configuration of the 'metadata.sources' configuration option: ".$e->getMessage()
71  );
72  }
73  }
$type
Create styles array
The data for the language used.
static parseSources($sourcesConfig)
Parse array with metadata sources.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the call graph for this function:

Member Function Documentation

◆ getGenerated()

SimpleSAML_Metadata_MetaDataStorageHandler::getGenerated (   $property,
  $set 
)

This function is used to generate some metadata elements automatically.

Parameters
string$propertyThe metadata property which should be auto-generated.
string$setThe set we the property comes from.
Returns
string The auto-generated metadata property.
Exceptions
ExceptionIf the metadata cannot be generated automatically.

Definition at line 85 of file MetaDataStorageHandler.php.

References $baseurl, $config, SimpleSAML_Configuration\getInstance(), and getMetaDataCurrent().

86  {
87  // first we check if the user has overridden this property in the metadata
88  try {
89  $metadataSet = $this->getMetaDataCurrent($set);
90  if (array_key_exists($property, $metadataSet)) {
91  return $metadataSet[$property];
92  }
93  } catch (Exception $e) {
94  // probably metadata wasn't found. In any case we continue by generating the metadata
95  }
96 
97  // get the configuration
99  assert($config instanceof SimpleSAML_Configuration);
100 
101  $baseurl = \SimpleSAML\Utils\HTTP::getSelfURLHost().$config->getBasePath();
102 
103  if ($set == 'saml20-sp-hosted') {
104  if ($property === 'SingleLogoutServiceBinding') {
105  return \SAML2\Constants::BINDING_HTTP_REDIRECT;
106  }
107  } elseif ($set == 'saml20-idp-hosted') {
108  switch ($property) {
109  case 'SingleSignOnService':
110  return $baseurl.'saml2/idp/SSOService.php';
111 
112  case 'SingleSignOnServiceBinding':
113  return \SAML2\Constants::BINDING_HTTP_REDIRECT;
114 
115  case 'SingleLogoutService':
116  return $baseurl.'saml2/idp/SingleLogoutService.php';
117 
118  case 'SingleLogoutServiceBinding':
119  return \SAML2\Constants::BINDING_HTTP_REDIRECT;
120  }
121  } elseif ($set == 'shib13-idp-hosted') {
122  if ($property === 'SingleSignOnService') {
123  return $baseurl.'shib13/idp/SSOService.php';
124  }
125  }
126 
127  throw new Exception('Could not generate metadata property '.$property.' for set '.$set.'.');
128  }
getMetaDataCurrent($set)
This function retrieves metadata for the current entity based on the hostname/path the request was di...
$baseurl
Definition: demo.php:25
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the call graph for this function:

◆ getList()

SimpleSAML_Metadata_MetaDataStorageHandler::getList (   $set = 'saml20-idp-remote')

This function lists all known metadata in the given set.

It is returned as an associative array where the key is the entity id.

Parameters
string$setThe set we want to list metadata from.
Returns
array An associative array with the metadata from from the given set.

Definition at line 139 of file MetaDataStorageHandler.php.

References $key, $result, $source, array, time, and SimpleSAML\Logger\warning().

140  {
141  assert('is_string($set)');
142 
143  $result = array();
144 
145  foreach ($this->sources as $source) {
146  $srcList = $source->getMetadataSet($set);
147 
148  foreach ($srcList as $key => $le) {
149  if (array_key_exists('expire', $le)) {
150  if ($le['expire'] < time()) {
151  unset($srcList[$key]);
153  "Dropping metadata entity ".var_export($key, true).", expired ".
154  SimpleSAML\Utils\Time::generateTimestamp($le['expire'])."."
155  );
156  }
157  }
158  }
159 
160  /* $result is the last argument to array_merge because we want the content already
161  * in $result to have precedence.
162  */
163  $result = array_merge($srcList, $result);
164  }
165 
166  return $result;
167  }
$result
Attribute-related utility methods.
static warning($string)
Definition: Logger.php:179
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$source
Definition: linkback.php:22
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getMetaData()

SimpleSAML_Metadata_MetaDataStorageHandler::getMetaData (   $index,
  $set 
)

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.

Parameters
string$indexThe 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.
string$setThe set of metadata we are looking up the entity id in.
Returns
array The metadata array describing the specified entity.
Exceptions
ExceptionIf metadata for the specified entity is expired.
SimpleSAML_Error_MetadataNotFoundIf no metadata for the entity specified can be found.

Definition at line 269 of file MetaDataStorageHandler.php.

References $index, $metadata, $source, getMetaDataCurrentEntityID(), and time.

Referenced by getMetaDataConfig(), and getMetaDataCurrent().

270  {
271  assert('is_string($set)');
272 
273  if ($index === null) {
274  $index = $this->getMetaDataCurrentEntityID($set, 'metaindex');
275  }
276 
277  assert('is_string($index)');
278 
279  foreach ($this->sources as $source) {
280  $metadata = $source->getMetaData($index, $set);
281 
282  if ($metadata !== null) {
283 
284  if (array_key_exists('expire', $metadata)) {
285  if ($metadata['expire'] < time()) {
286  throw new Exception(
287  'Metadata for the entity ['.$index.'] expired '.
288  (time() - $metadata['expire']).' seconds ago.'
289  );
290  }
291  }
292 
293  $metadata['metadata-index'] = $index;
294  $metadata['metadata-set'] = $set;
295  assert('array_key_exists("entityid", $metadata)');
296  return $metadata;
297  }
298  }
299 
301  }
$index
Definition: metadata.php:60
$metadata['__DYNAMIC:1__']
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$source
Definition: linkback.php:22
getMetaDataCurrentEntityID($set, $type='entityid')
This function locates the current entity id based on the hostname/path combination the user accessed...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMetaDataConfig()

SimpleSAML_Metadata_MetaDataStorageHandler::getMetaDataConfig (   $entityId,
  $set 
)

Retrieve the metadata as a configuration object.

This function will throw an exception if it is unable to locate the metadata.

Parameters
string$entityIdThe entity ID we are looking up.
string$setThe metadata set we are searching.
Returns
SimpleSAML_Configuration The configuration object representing the metadata.
Exceptions
SimpleSAML_Error_MetadataNotFoundIf no metadata for the entity specified can be found.

Definition at line 315 of file MetaDataStorageHandler.php.

References $entityId, $metadata, getMetaData(), and SimpleSAML_Configuration\loadFromArray().

316  {
317  assert('is_string($entityId)');
318  assert('is_string($set)');
319 
320  $metadata = $this->getMetaData($entityId, $set);
321  return SimpleSAML_Configuration::loadFromArray($metadata, $set.'/'.var_export($entityId, true));
322  }
$metadata['__DYNAMIC:1__']
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22
getMetaData($index, $set)
This function looks up the metadata for the given entity id in the given set.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the call graph for this function:

◆ getMetaDataConfigForSha1()

SimpleSAML_Metadata_MetaDataStorageHandler::getMetaDataConfigForSha1 (   $sha1,
  $set 
)

Search for an entity's metadata, given the SHA1 digest of its entity ID.

Parameters
string$sha1The SHA1 digest of the entity ID.
string$setThe metadata set we are searching.
Returns
null|SimpleSAML_Configuration The metadata corresponding to the entity, or null if the entity cannot be found.

Definition at line 334 of file MetaDataStorageHandler.php.

References $result, $source, array, and SimpleSAML_Configuration\loadFromArray().

335  {
336  assert('is_string($sha1)');
337  assert('is_string($set)');
338 
339  $result = array();
340 
341  foreach ($this->sources as $source) {
342  $srcList = $source->getMetadataSet($set);
343 
344  /* $result is the last argument to array_merge because we want the content already
345  * in $result to have precedence.
346  */
347  $result = array_merge($srcList, $result);
348  }
349  foreach ($result as $remote_provider) {
350 
351  if (sha1($remote_provider['entityid']) == $sha1) {
352  $remote_provider['metadata-set'] = $set;
353 
355  $remote_provider,
356  $set.'/'.var_export($remote_provider['entityid'], true)
357  );
358  }
359  }
360 
361  return null;
362  }
$result
Create styles array
The data for the language used.
$source
Definition: linkback.php:22
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the call graph for this function:

◆ getMetaDataCurrent()

SimpleSAML_Metadata_MetaDataStorageHandler::getMetaDataCurrent (   $set)

This function retrieves metadata for the current entity based on the hostname/path the request was directed to.

It will throw an exception if it is unable to locate the metadata.

Parameters
string$setThe set we want metadata from.
Returns
array An associative array with the metadata.

Definition at line 178 of file MetaDataStorageHandler.php.

References getMetaData().

Referenced by getGenerated().

179  {
180  return $this->getMetaData(null, $set);
181  }
getMetaData($index, $set)
This function looks up the metadata for the given entity id in the given set.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMetaDataCurrentEntityID()

SimpleSAML_Metadata_MetaDataStorageHandler::getMetaDataCurrentEntityID (   $set,
  $type = 'entityid' 
)

This function locates the current entity id based on the hostname/path combination the user accessed.

It will throw an exception if it is unable to locate the entity id.

Parameters
string$setThe set we look for the entity id in.
string$typeDo you want to return the metaindex or the entityID. [entityid|metaindex]
Returns
string The entity id which is associated with the current hostname/path combination.
Exceptions
ExceptionIf no default metadata can be found in the set for the current host.

Definition at line 194 of file MetaDataStorageHandler.php.

References $entityId, $index, $source, $type, SimpleSAML\Utils\HTTP\getSelfHost(), and SimpleSAML\Utils\HTTP\getSelfHostWithPath().

Referenced by getMetaData().

195  {
196  assert('is_string($set)');
197 
198  // first we look for the hostname/path combination
199  $currenthostwithpath = \SimpleSAML\Utils\HTTP::getSelfHostWithPath(); // sp.example.org/university
200 
201  foreach ($this->sources as $source) {
202  $index = $source->getEntityIdFromHostPath($currenthostwithpath, $set, $type);
203  if ($index !== null) {
204  return $index;
205  }
206  }
207 
208  // then we look for the hostname
209  $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org
210 
211  foreach ($this->sources as $source) {
212  $index = $source->getEntityIdFromHostPath($currenthost, $set, $type);
213  if ($index !== null) {
214  return $index;
215  }
216  }
217 
218  // then we look for the DEFAULT entry
219  foreach ($this->sources as $source) {
220  $entityId = $source->getEntityIdFromHostPath('__DEFAULT__', $set, $type);
221  if ($entityId !== null) {
222  return $entityId;
223  }
224  }
225 
226  // we were unable to find the hostname/path in any metadata source
227  throw new Exception(
228  'Could not find any default metadata entities in set ['.$set.'] for host ['.$currenthost.' : '.
229  $currenthostwithpath.']'
230  );
231  }
$type
$index
Definition: metadata.php:60
static getSelfHost()
Retrieve our own host.
Definition: HTTP.php:699
static getSelfHostWithPath()
Retrieve our own host together with the URL path.
Definition: HTTP.php:738
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22
$source
Definition: linkback.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMetadataHandler()

static SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler ( )
static

This function retrieves the current instance of the metadata handler.

The metadata handler will be instantiated if this is the first call to this function.

Returns
SimpleSAML_Metadata_MetaDataStorageHandler The current metadata handler instance.

Definition at line 40 of file MetaDataStorageHandler.php.

Referenced by ilSimpleSAMLphplIdpDiscovery\__construct(), SimpleSAML_IdP\__construct(), SimpleSAML_XHTML_IdPDisco\__construct(), sspmod_saml_Auth_Source_SP\authenticate(), SimpleSAML\XML\Shib13\AuthnRequest\createRedirect(), sspmod_saml_IdP_SAML2\getAssociationConfig(), sspmod_saml_Auth_Source_SP\getIdPMetadata(), sspmod_adfs_IdP_ADFS\getLogoutURL(), sspmod_saml_IdP_SAML2\getLogoutURL(), sspmod_statistics_Statistics_FieldPresentation_Entity\getPresentation(), SimpleSAML\XML\Shib13\AuthnResponse\getSessionIndex(), SimpleSAML_IdP\getSPName(), sspmod_consent_Auth_Process_Consent\process(), sspmod_saml_Auth_Source_SP\reauthenticate(), sspmod_adfs_IdP_ADFS\receiveAuthnRequest(), sspmod_saml_IdP_SAML1\receiveAuthnRequest(), sspmod_saml_IdP_SAML2\receiveAuthnRequest(), sspmod_saml_IdP_SAML2\receiveLogoutMessage(), SAML2\HTTPArtifact\send(), sspmod_saml_IdP_SAML2\sendLogoutRequest(), sspmod_adfs_IdP_ADFS\sendLogoutResponse(), sspmod_saml_IdP_SAML2\sendLogoutResponse(), sspmod_saml_IdP_SAML1\sendResponse(), and SimpleSAML\XML\Shib13\AuthnResponse\validate().

41  {
42  if (self::$metadataHandler === null) {
43  self::$metadataHandler = new SimpleSAML_Metadata_MetaDataStorageHandler();
44  }
45 
46  return self::$metadataHandler;
47  }
+ Here is the caller graph for this function:

◆ getPreferredEntityIdFromCIDRhint()

SimpleSAML_Metadata_MetaDataStorageHandler::getPreferredEntityIdFromCIDRhint (   $set,
  $ip 
)

This method will call getPreferredEntityIdFromCIDRhint() on all of the sources.

Parameters
string$setWhich set of metadata we are looking it up in.
string$ipIP address
Returns
string The entity id of a entity which have a CIDR hint where the provided IP address match.

Definition at line 244 of file MetaDataStorageHandler.php.

References $entityId, and $source.

245  {
246  foreach ($this->sources as $source) {
247  $entityId = $source->getPreferredEntityIdFromCIDRhint($set, $ip);
248  if ($entityId !== null) {
249  return $entityId;
250  }
251  }
252 
253  return null;
254  }
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22
$source
Definition: linkback.php:22

Field Documentation

◆ $metadataHandler

SimpleSAML_Metadata_MetaDataStorageHandler::$metadataHandler = null
staticprivate

Definition at line 21 of file MetaDataStorageHandler.php.

◆ $sources

SimpleSAML_Metadata_MetaDataStorageHandler::$sources
private

Definition at line 30 of file MetaDataStorageHandler.php.


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