1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wsa_200508; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\WSSecurity\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
11
|
|
|
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait}; |
12
|
|
|
|
13
|
|
|
use function array_pop; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* A ProblemAction |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/ws-security |
19
|
|
|
*/ |
20
|
|
|
final class ProblemAction extends AbstractProblemActionType implements SchemaValidatableElementInterface |
21
|
|
|
{ |
22
|
|
|
use SchemaValidatableElementTrait; |
|
|
|
|
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Convert XML into a class instance |
26
|
|
|
* |
27
|
|
|
* @param \DOMElement $xml The XML element we should load |
28
|
|
|
* @return static |
29
|
|
|
* |
30
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
31
|
|
|
* If the qualified name of the supplied element is wrong |
32
|
|
|
*/ |
33
|
|
|
public static function fromXML(DOMElement $xml): static |
34
|
|
|
{ |
35
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
36
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
37
|
|
|
|
38
|
|
|
$action = Action::getChildrenOfClass($xml); |
39
|
|
|
Assert::maxCount( |
40
|
|
|
$action, |
41
|
|
|
1, |
42
|
|
|
'No more than one Action element allowed in <wsa:ProblemAction>.', |
43
|
|
|
TooManyElementsException::class, |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
$soapAction = SoapAction::getChildrenOfClass($xml); |
47
|
|
|
Assert::maxCount( |
48
|
|
|
$soapAction, |
49
|
|
|
1, |
50
|
|
|
'No more than one SoapAction element allowed in <wsa:ProblemAction>.', |
51
|
|
|
TooManyElementsException::class, |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
return new static(array_pop($action), array_pop($soapAction), self::getAttributesNSFromXML($xml)); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|