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\SchemaViolationException; |
12
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
13
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* A RequestSecurityTokenResponseCollectionType element |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/ws-security |
19
|
|
|
*/ |
20
|
|
|
abstract class AbstractRequestSecurityTokenResponseCollectionType extends AbstractWstElement |
21
|
|
|
{ |
22
|
|
|
use ExtendableAttributesTrait; |
23
|
|
|
|
24
|
|
|
/** @var string|\SimpleSAML\XML\XsNamespace */ |
25
|
|
|
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param array<\SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse> $requestSecurityTokenResponse |
30
|
|
|
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes |
31
|
|
|
*/ |
32
|
|
|
final public function __construct( |
33
|
|
|
protected array $requestSecurityTokenResponse, |
34
|
|
|
array $namespacedAttributes, |
35
|
|
|
) { |
36
|
|
|
Assert::minCount($requestSecurityTokenResponse, 1, MissingElementException::class); |
37
|
|
|
Assert::allIsInstanceOf( |
38
|
|
|
$requestSecurityTokenResponse, |
39
|
|
|
RequestSecurityTokenResponse::class, |
40
|
|
|
SchemaViolationException::class, |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
$this->setAttributesNS($namespacedAttributes); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get the requestSecurityTokenResponse property. |
49
|
|
|
* |
50
|
|
|
* @return \SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse[] |
51
|
|
|
*/ |
52
|
|
|
public function getRequestSecurityTokenResponse(): array |
53
|
|
|
{ |
54
|
|
|
return $this->requestSecurityTokenResponse; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Convert XML into a class instance |
60
|
|
|
* |
61
|
|
|
* @param \DOMElement $xml The XML element we should load |
62
|
|
|
* @return static |
63
|
|
|
* |
64
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
65
|
|
|
* If the qualified name of the supplied element is wrong |
66
|
|
|
*/ |
67
|
|
|
public static function fromXML(DOMElement $xml): static |
68
|
|
|
{ |
69
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
70
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
71
|
|
|
|
72
|
|
|
return new static( |
73
|
|
|
RequestSecurityTokenResponse::getChildrenOfClass($xml), |
74
|
|
|
self::getAttributesNSFromXML($xml), |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Convert this element to XML. |
81
|
|
|
* |
82
|
|
|
* @param \DOMElement|null $parent The element we should append this element to. |
83
|
|
|
* @return \DOMElement |
84
|
|
|
*/ |
85
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
86
|
|
|
{ |
87
|
|
|
$e = $this->instantiateParentElement($parent); |
88
|
|
|
|
89
|
|
|
foreach ($this->getRequestSecurityTokenResponse() as $r) { |
90
|
|
|
$r->toXML($e); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
94
|
|
|
$attr->toXML($e); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $e; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|