1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wst_200512; |
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
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* A RequestSecurityTokenCollectionType element |
15
|
|
|
* |
16
|
|
|
* @package simplesamlphp/ws-security |
17
|
|
|
*/ |
18
|
|
|
abstract class AbstractRequestSecurityTokenCollectionType extends AbstractWstElement |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @param array<\SimpleSAML\WSSecurity\XML\wst_200512\RequestSecurityToken> $requestSecurityToken |
22
|
|
|
*/ |
23
|
|
|
final public function __construct( |
24
|
|
|
protected array $requestSecurityToken, |
25
|
|
|
) { |
26
|
|
|
Assert::minCount($requestSecurityToken, 2, MissingElementException::class); |
|
|
|
|
27
|
|
|
Assert::allIsInstanceOf( |
|
|
|
|
28
|
|
|
$requestSecurityToken, |
29
|
|
|
RequestSecurityToken::class, |
30
|
|
|
SchemaViolationException::class, |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Get the requestSecurityToken property. |
37
|
|
|
* |
38
|
|
|
* @return \SimpleSAML\WSSecurity\XML\wst_200512\RequestSecurityToken[] |
39
|
|
|
*/ |
40
|
|
|
public function getRequestSecurityToken(): array |
41
|
|
|
{ |
42
|
|
|
return $this->requestSecurityToken; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Convert XML into a class instance |
48
|
|
|
* |
49
|
|
|
* @param \DOMElement $xml The XML element we should load |
50
|
|
|
* @return static |
51
|
|
|
* |
52
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
53
|
|
|
* If the qualified name of the supplied element is wrong |
54
|
|
|
*/ |
55
|
|
|
public static function fromXML(DOMElement $xml): static |
56
|
|
|
{ |
57
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
|
|
|
|
58
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
59
|
|
|
|
60
|
|
|
return new static( |
61
|
|
|
RequestSecurityToken::getChildrenOfClass($xml), |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Convert this element to XML. |
68
|
|
|
* |
69
|
|
|
* @param \DOMElement|null $parent The element we should append this element to. |
70
|
|
|
* @return \DOMElement |
71
|
|
|
*/ |
72
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
73
|
|
|
{ |
74
|
|
|
$e = $this->instantiateParentElement($parent); |
75
|
|
|
|
76
|
|
|
foreach ($this->getRequestSecurityToken() as $r) { |
77
|
|
|
$r->toXML($e); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $e; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|