blob: 2f5e9ae915bfe967ec8c5f32ed760220e3da0fcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
/**
* Class for handling SAML2 metadata extensions.
*
* @package simpleSAMLphp
* @version $Id$
*/
class SAML2_XML_md_Extensions {
/**
* Get a list of Extensions in the given element.
*
* @param DOMElement $parent The element that may contain the md:Extensions element.
* @return array Array of extensions.
*/
public static function getList(DOMElement $parent) {
$ret = array();
foreach (SAML2_Utils::xpQuery($parent, './saml_metadata:Extensions/*') as $node) {
if ($node->namespaceURI === SAML2_XML_shibmd_Scope::NS && $node->localName === 'Scope') {
$ret[] = new SAML2_XML_shibmd_Scope($node);
} elseif ($node->namespaceURI === SAML2_XML_mdattr_EntityAttributes::NS && $node->localName === 'EntityAttributes') {
$ret[] = new SAML2_XML_mdattr_EntityAttributes($node);
} else {
$ret[] = new SAML2_XML_Chunk($node);
}
}
return $ret;
}
/**
* Add a list of Extensions to the given element.
*
* @param DOMElement $parent The element we should add the extensions to.
* @param array $extensions List of extension objects.
*/
public static function addList(DOMElement $parent, array $extensions) {
if (empty($extensions)) {
return;
}
$extElement = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:Extensions');
$parent->appendChild($extElement);
foreach ($extensions as $ext) {
$ext->toXML($extElement);
}
}
}
|