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

Public Member Functions

 getMetadataSet ($set)
 This function retrieves the given set of metadata. More...
 

Protected Member Functions

 __construct ($config)
 This constructor initializes the flatfile metadata storage handler with the specified configuration. More...
 

Private Member Functions

 load ($set)
 This function loads the given set of metadata from a file our metadata directory. More...
 
 generateDynamicHostedEntityID ($set)
 

Private Attributes

 $directory
 
 $cachedMetadata = array()
 

Additional Inherited Members

Detailed Description

Definition at line 12 of file MetaDataStorageHandlerFlatFile.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile::__construct (   $config)
protected

This constructor initializes the flatfile metadata storage handler with the specified configuration.

The configuration is an associative array with the following possible elements:

  • 'directory': The directory we should load metadata from. The default directory is set in the 'metadatadir' configuration option in 'config.php'.
Parameters
array$configAn associative array with the configuration for this handler.

Definition at line 41 of file MetaDataStorageHandlerFlatFile.php.

References $config, $globalConfig, and SimpleSAML_Configuration\getInstance().

42  {
43  assert('is_array($config)');
44 
45  // get the configuration
47 
48  // find the path to the directory we should search for metadata in
49  if (array_key_exists('directory', $config)) {
50  $this->directory = $config['directory'];
51  } else {
52  $this->directory = $globalConfig->getString('metadatadir', 'metadata/');
53  }
54 
55  /* Resolve this directory relative to the SimpleSAMLphp directory (unless it is
56  * an absolute path).
57  */
58  $this->directory = $globalConfig->resolvePath($this->directory).'/';
59  }
$globalConfig
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the call graph for this function:

Member Function Documentation

◆ generateDynamicHostedEntityID()

SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile::generateDynamicHostedEntityID (   $set)
private

Definition at line 127 of file MetaDataStorageHandlerFlatFile.php.

References $baseurl, and SimpleSAML\Utils\HTTP\getBaseURL().

Referenced by getMetadataSet().

128  {
129  // get the configuration
131 
132  if ($set === 'saml20-idp-hosted') {
133  return $baseurl.'saml2/idp/metadata.php';
134  } elseif ($set === 'shib13-idp-hosted') {
135  return $baseurl.'shib13/idp/metadata.php';
136  } elseif ($set === 'wsfed-sp-hosted') {
137  return 'urn:federation:'.\SimpleSAML\Utils\HTTP::getSelfHost();
138  } elseif ($set === 'adfs-idp-hosted') {
139  return 'urn:federation:'.\SimpleSAML\Utils\HTTP::getSelfHost().':idp';
140  } else {
141  throw new Exception('Can not generate dynamic EntityID for metadata of this type: ['.$set.']');
142  }
143  }
$baseurl
Definition: demo.php:25
static getBaseURL()
Retrieve the base URL of the SimpleSAMLphp installation.
Definition: HTTP.php:598
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMetadataSet()

SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile::getMetadataSet (   $set)

This function retrieves the given set of metadata.

It will return an empty array if it is unable to locate it.

Parameters
string$setThe set of metadata we are retrieving.
Returns
array An associative array with the metadata. Each element in the array is an entity, and the key is the entity id.

Definition at line 101 of file MetaDataStorageHandlerFlatFile.php.

References $entityId, array, generateDynamicHostedEntityID(), and load().

102  {
103  if (array_key_exists($set, $this->cachedMetadata)) {
104  return $this->cachedMetadata[$set];
105  }
106 
107  $metadataSet = $this->load($set);
108  if ($metadataSet === null) {
109  $metadataSet = array();
110  }
111 
112  // add the entity id of an entry to each entry in the metadata
113  foreach ($metadataSet as $entityId => &$entry) {
114  if (preg_match('/__DYNAMIC(:[0-9]+)?__/', $entityId)) {
115  $entry['entityid'] = $this->generateDynamicHostedEntityID($set);
116  } else {
117  $entry['entityid'] = $entityId;
118  }
119  }
120 
121  $this->cachedMetadata[$set] = $metadataSet;
122 
123  return $metadataSet;
124  }
load($set)
This function loads the given set of metadata from a file our metadata directory. ...
Create styles array
The data for the language used.
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22
+ Here is the call graph for this function:

◆ load()

SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile::load (   $set)
private

This function loads the given set of metadata from a file our metadata directory.

This function returns null if it is unable to locate the given set in the metadata directory.

Parameters
string$setThe set of metadata we are loading.
Returns
array An associative array with the metadata, or null if we are unable to load metadata from the given file.
Exceptions
ExceptionIf the metadata set cannot be loaded.

Definition at line 72 of file MetaDataStorageHandlerFlatFile.php.

References $metadata, and array.

Referenced by getMetadataSet().

73  {
74  $metadatasetfile = $this->directory.$set.'.php';
75 
76  if (!file_exists($metadatasetfile)) {
77  return null;
78  }
79 
80  $metadata = array();
81 
82  include($metadatasetfile);
83 
84  if (!is_array($metadata)) {
85  throw new Exception('Could not load metadata set ['.$set.'] from file: '.$metadatasetfile);
86  }
87 
88  return $metadata;
89  }
$metadata['__DYNAMIC:1__']
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

Field Documentation

◆ $cachedMetadata

SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile::$cachedMetadata = array()
private

Definition at line 29 of file MetaDataStorageHandlerFlatFile.php.

◆ $directory

SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile::$directory
private

Definition at line 21 of file MetaDataStorageHandlerFlatFile.php.


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