1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wsdl; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Chunk; |
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class representing the Definitions element. |
14
|
|
|
* |
15
|
|
|
* @package simplesamlphp/ws-security |
16
|
|
|
*/ |
17
|
|
|
final class Definitions extends AbstractDefinitions |
18
|
|
|
{ |
19
|
|
|
/** @var string */ |
20
|
|
|
final public const LOCALNAME = 'definitions'; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Initialize a Definitions element. |
25
|
|
|
* |
26
|
|
|
* @param \DOMElement $xml The XML element we should load. |
27
|
|
|
* @return static |
28
|
|
|
* |
29
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
30
|
|
|
* if the qualified name of the supplied element is wrong |
31
|
|
|
*/ |
32
|
|
|
public static function fromXML(DOMElement $xml): static |
33
|
|
|
{ |
34
|
|
|
Assert::same($xml->localName, static::LOCALNAME, InvalidDOMElementException::class); |
35
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
36
|
|
|
|
37
|
|
|
$import = Import::getChildrenOfClass($xml); |
38
|
|
|
$types = Types::getChildrenOfClass($xml); |
39
|
|
|
$message = Message::getChildrenOfClass($xml); |
40
|
|
|
$portType = PortType::getChildrenOfClass($xml); |
41
|
|
|
$binding = Binding::getChildrenOfClass($xml); |
42
|
|
|
$service = Service::getChildrenOfClass($xml); |
43
|
|
|
|
44
|
|
|
$children = []; |
45
|
|
|
foreach ($xml->childNodes as $child) { |
46
|
|
|
if (!($child instanceof DOMElement)) { |
47
|
|
|
continue; |
48
|
|
|
} elseif ($child->namespaceURI === static::NS) { |
49
|
|
|
// Only other namespaces are allowed |
50
|
|
|
continue; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$children[] = new Chunk($child); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return new static( |
57
|
|
|
self::getOptionalAttribute($xml, 'targetNamespace'), |
58
|
|
|
self::getOptionalAttribute($xml, 'name'), |
59
|
|
|
$import, |
60
|
|
|
$types, |
61
|
|
|
$message, |
62
|
|
|
$portType, |
63
|
|
|
$binding, |
64
|
|
|
$service, |
65
|
|
|
$children, |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|