1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wst_200502; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\WSSecurity\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
11
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
12
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
13
|
|
|
use SimpleSAML\XML\SerializableElementInterface; |
14
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
15
|
|
|
|
16
|
|
|
use function array_pop; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class defining the CancelTargetType element |
20
|
|
|
* |
21
|
|
|
* @package simplesamlphp/ws-security |
22
|
|
|
*/ |
23
|
|
|
abstract class AbstractCancelTargetType extends AbstractWstElement |
24
|
|
|
{ |
25
|
|
|
use ExtendableElementTrait; |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** The namespace-attribute for the xs:any element */ |
28
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::OTHER; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* AbstractCancelTargetType constructor |
33
|
|
|
* |
34
|
|
|
* @param \SimpleSAML\XML\SerializableElementInterface $child |
35
|
|
|
*/ |
36
|
|
|
final public function __construct( |
37
|
|
|
SerializableElementInterface $child, |
38
|
|
|
) { |
39
|
|
|
$this->setElements([$child]); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Create an instance of this object from its XML representation. |
45
|
|
|
* |
46
|
|
|
* @param \DOMElement $xml |
47
|
|
|
* @return static |
48
|
|
|
* |
49
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
50
|
|
|
* if the qualified name of the supplied element is wrong |
51
|
|
|
*/ |
52
|
|
|
public static function fromXML(DOMElement $xml): static |
53
|
|
|
{ |
54
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
55
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
56
|
|
|
|
57
|
|
|
$children = self::getChildElementsFromXML($xml); |
58
|
|
|
Assert::minCount($children, 1, MissingElementException::class); |
59
|
|
|
Assert::maxCount($children, 1, TooManyElementsException::class); |
60
|
|
|
|
61
|
|
|
return new static( |
62
|
|
|
array_pop($children), |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Add this CancelTargetType to an XML element. |
69
|
|
|
* |
70
|
|
|
* @param \DOMElement|null $parent The element we should append this username token to. |
71
|
|
|
* @return \DOMElement |
72
|
|
|
*/ |
73
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
74
|
|
|
{ |
75
|
|
|
$e = parent::instantiateParentElement($parent); |
76
|
|
|
|
77
|
|
|
foreach ($this->getElements() as $child) { |
78
|
|
|
if (!$child->isEmptyElement()) { |
79
|
|
|
$child->toXML($e); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $e; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|