|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML11\XML\samlp; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\XML\Chunk; |
|
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
|
11
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
|
12
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* SAML StatusDetail data type. |
|
16
|
|
|
* |
|
17
|
|
|
* @package simplesamlphp/saml11 |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractStatusDetailType extends AbstractSamlpElement |
|
20
|
|
|
{ |
|
21
|
|
|
use ExtendableElementTrait; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** The namespace-attribute for the xs:any element */ |
|
24
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Initialize a samlp:StatusDetail |
|
29
|
|
|
* |
|
30
|
|
|
* @param \SimpleSAML\XML\Chunk[] $details |
|
31
|
|
|
*/ |
|
32
|
|
|
final public function __construct(array $details = []) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->setElements($details); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
|
40
|
|
|
* |
|
41
|
|
|
* @return bool |
|
42
|
|
|
*/ |
|
43
|
|
|
public function isEmptyElement(): bool |
|
44
|
|
|
{ |
|
45
|
|
|
return empty($this->elements); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Convert XML into a StatusDetail |
|
51
|
|
|
* |
|
52
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
53
|
|
|
* @return static |
|
54
|
|
|
* |
|
55
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
|
56
|
|
|
* if the qualified name of the supplied element is wrong |
|
57
|
|
|
*/ |
|
58
|
|
|
public static function fromXML(DOMElement $xml): static |
|
59
|
|
|
{ |
|
60
|
|
|
Assert::same($xml->localName, 'StatusDetail', InvalidDOMElementException::class); |
|
61
|
|
|
Assert::same($xml->namespaceURI, StatusDetail::NS, InvalidDOMElementException::class); |
|
62
|
|
|
|
|
63
|
|
|
$details = []; |
|
64
|
|
|
foreach ($xml->childNodes as $detail) { |
|
65
|
|
|
if (!($detail instanceof DOMElement)) { |
|
66
|
|
|
continue; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$details[] = new Chunk($detail); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return new static($details); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Convert this StatusDetail to XML. |
|
78
|
|
|
* |
|
79
|
|
|
* @param \DOMElement|null $parent The element we are converting to XML. |
|
80
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this StatusDetail. |
|
81
|
|
|
*/ |
|
82
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
|
83
|
|
|
{ |
|
84
|
|
|
$e = $this->instantiateParentElement($parent); |
|
85
|
|
|
|
|
86
|
|
|
foreach ($this->getElements() as $detail) { |
|
87
|
|
|
$detail->toXML($e); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return $e; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|