ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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 }
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static parseSources($sourcesConfig)
Parse array with metadata sources.
$config
Definition: bootstrap.php:15
$type

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

+ 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.

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...

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

+ 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.

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
$source
Definition: linkback.php:22
static warning($string)
Definition: Logger.php:177
$key
Definition: croninfo.php:18
Attribute-related utility methods.

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

+ 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.

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 if (array_key_exists('expire', $metadata)) {
284 if ($metadata['expire'] < time()) {
285 throw new Exception(
286 'Metadata for the entity ['.$index.'] expired '.
287 (time() - $metadata['expire']).' seconds ago.'
288 );
289 }
290 }
291
292 $metadata['metadata-index'] = $index;
293 $metadata['metadata-set'] = $set;
294 assert(array_key_exists('entityid', $metadata));
295 return $metadata;
296 }
297 }
298
300 }
$metadata['__DYNAMIC:1__']
getMetaDataCurrentEntityID($set, $type='entityid')
This function locates the current entity id based on the hostname/path combination the user accessed.
$index
Definition: metadata.php:60

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

Referenced by getMetaDataConfig(), and getMetaDataCurrent().

+ 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 314 of file MetaDataStorageHandler.php.

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

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

+ 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 333 of file MetaDataStorageHandler.php.

334 {
335 assert(is_string($sha1));
336 assert(is_string($set));
337
338 $result = array();
339
340 foreach ($this->sources as $source) {
341 $srcList = $source->getMetadataSet($set);
342
343 /* $result is the last argument to array_merge because we want the content already
344 * in $result to have precedence.
345 */
346 $result = array_merge($srcList, $result);
347 }
348 foreach ($result as $remote_provider) {
349 if (sha1($remote_provider['entityid']) == $sha1) {
350 $remote_provider['metadata-set'] = $set;
351
353 $remote_provider,
354 $set.'/'.var_export($remote_provider['entityid'], true)
355 );
356 }
357 }
358
359 return null;
360 }

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

+ 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.

179 {
180 return $this->getMetaData(null, $set);
181 }

References getMetaData().

Referenced by getGenerated().

+ 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.

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 }
static getSelfHost()
Retrieve our own host.
Definition: HTTP.php:697
static getSelfHostWithPath()
Retrieve our own host together with the URL path.
Definition: HTTP.php:736

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

Referenced by getMetaData().

+ 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.

41 {
42 if (self::$metadataHandler === null) {
43 self::$metadataHandler = new SimpleSAML_Metadata_MetaDataStorageHandler();
44 }
45
47 }

References $metadataHandler.

Referenced by SimpleSAML_IdP\__construct(), ilSimpleSAMLphplIdpDiscovery\__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_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(), sspmod_saml_IdP_SAML2\sendLogoutRequest(), sspmod_saml_IdP_SAML2\sendLogoutResponse(), sspmod_saml_IdP_SAML1\sendResponse(), and SimpleSAML\XML\Shib13\AuthnResponse\validate().

+ 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.

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 }

References $entityId, and $source.

Field Documentation

◆ $metadataHandler

SimpleSAML_Metadata_MetaDataStorageHandler::$metadataHandler = null
staticprivate

Definition at line 21 of file MetaDataStorageHandler.php.

Referenced by getMetadataHandler().

◆ $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: