|
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\SchemaViolationException; |
|
11
|
|
|
use SimpleSAML\XML\StringElementTrait; |
|
12
|
|
|
|
|
13
|
|
|
use function array_map; |
|
14
|
|
|
use function explode; |
|
15
|
|
|
use function implode; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* A ComputedKeyOpenEnum element |
|
19
|
|
|
* |
|
20
|
|
|
* @package simplesamlphp/ws-security |
|
21
|
|
|
* |
|
22
|
|
|
* @phpstan-consistent-constructor |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract class AbstractComputedKeyOpenEnum extends AbstractWstElement |
|
25
|
|
|
{ |
|
26
|
|
|
use StringElementTrait; |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param (\SimpleSAML\WSSecurity\XML\wst_200512\ComputedKeyEnum|string)[] $values |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct(array $values) |
|
33
|
|
|
{ |
|
34
|
|
|
$values = array_map( |
|
35
|
|
|
function (ComputedKeyEnum|string $v): string { |
|
36
|
|
|
return ($v instanceof ComputedKeyEnum) ? $v->value : $v; |
|
37
|
|
|
}, |
|
38
|
|
|
$values, |
|
39
|
|
|
); |
|
40
|
|
|
Assert::allValidURI($values, SchemaViolationException::class); |
|
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
$this->setContent(implode(' ', $values)); |
|
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(explode(' ', $xml->textContent)); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|