ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 hint.cidr 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.

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
143 if (!array_key_exists('host', $entry)) {
144 continue;
145 }
146
147 if ($hostPath === $entry['host']) {
148 if ($type === 'entityid') {
149 return $entry['entityid'];
150 } else {
151 return $index;
152 }
153 }
154 }
155
156 // no entries matched, we should return null
157 return null;
158 }
getMetadataSet($set)
This function attempts to generate an associative array with metadata for all entities in the given s...
$index
Definition: metadata.php:60
$type

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

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

Reimplemented in SimpleSAML_Metadata_MetaDataStorageHandlerSerialize.

Definition at line 246 of file MetaDataStorageSource.php.

247 {
248
249 assert('is_string($index)');
250 assert('isset($set)');
251
252 $metadataSet = $this->getMetadataSet($set);
253
254 if (array_key_exists($index, $metadataSet)) {
255 return $metadataSet[$index];
256 }
257
258 $indexlookup = $this->lookupIndexFromEntityId($index, $set);
259 if (isset($indexlookup) && array_key_exists($indexlookup, $metadataSet)) {
260 return $metadataSet[$indexlookup];
261 }
262
263 return null;
264 }

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

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

Reimplemented in SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile, SimpleSAML_Metadata_MetaDataStorageHandlerPdo, SimpleSAML_Metadata_MetaDataStorageHandlerSerialize, SimpleSAML_Metadata_MetaDataStorageHandlerXML, and SimpleSAML\Metadata\Sources\MDQ.

Definition at line 112 of file MetaDataStorageSource.php.

113 {
114 return array();
115 }

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

+ 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 hint.cidr 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 174 of file MetaDataStorageSource.php.

175 {
176
177 $metadataSet = $this->getMetadataSet($set);
178
179 foreach ($metadataSet as $index => $entry) {
180
181 if (!array_key_exists('hint.cidr', $entry)) {
182 continue;
183 }
184 if (!is_array($entry['hint.cidr'])) {
185 continue;
186 }
187
188 foreach ($entry['hint.cidr'] as $hint_entry) {
189 if (SimpleSAML\Utils\Net::ipCIDRcheck($hint_entry, $ip)) {
190 if ($type === 'entityid') {
191 return $entry['entityid'];
192 } else {
193 return $index;
194 }
195 }
196 }
197 }
198
199 // no entries matched, we should return null
200 return null;
201 }
Attribute-related utility methods.

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

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

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 }
static resolveClass($id, $type, $subclass=null)
Resolve module class.
Definition: Module.php:252

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

Referenced by metarefresh_hook_cron(), and parseSources().

+ 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 207 of file MetaDataStorageSource.php.

208 {
209 assert('is_string($entityId)');
210 assert('isset($set)');
211
212 $metadataSet = $this->getMetadataSet($set);
213
214 // check for hostname
215 $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org
216
217 foreach ($metadataSet as $index => $entry) {
218 if ($index === $entityId) {
219 return $index;
220 }
221 if ($entry['entityid'] === $entityId) {
222 if ($entry['host'] === '__DEFAULT__' || $entry['host'] === $currenthost) {
223 return $index;
224 }
225 }
226 }
227
228 return null;
229 }
static getSelfHost()
Retrieve our own host.
Definition: HTTP.php:699
if( $source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22

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

Referenced by getMetaData().

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

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 }
static getSource($sourceConfig)
This function creates a metadata source based on the given configuration.

References getSource().

Referenced by SimpleSAML_Metadata_MetaDataStorageHandler\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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