|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML11\XML\samlp; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\SAML11\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\SAML11\Exception\VersionMismatchException; |
|
10
|
|
|
use SimpleSAML\SAML11\Type\SAMLAnyURIValue; |
|
11
|
|
|
use SimpleSAML\SAML11\Type\SAMLDateTimeValue; |
|
12
|
|
|
use SimpleSAML\SAML11\XML\saml\Assertion; |
|
13
|
|
|
use SimpleSAML\SAML11\XML\samlp\Status; |
|
14
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
|
15
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
|
16
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
|
17
|
|
|
use SimpleSAML\XMLSchema\Exception\MissingElementException; |
|
18
|
|
|
use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
|
19
|
|
|
use SimpleSAML\XMLSchema\Type\IDValue; |
|
20
|
|
|
use SimpleSAML\XMLSchema\Type\NCNameValue; |
|
21
|
|
|
use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue; |
|
22
|
|
|
|
|
23
|
|
|
use function array_pop; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class representing a samlp:Response element. |
|
27
|
|
|
* |
|
28
|
|
|
* @package simplesaml/saml11 |
|
29
|
|
|
*/ |
|
30
|
|
|
final class Response extends AbstractResponseType implements SchemaValidatableElementInterface |
|
31
|
|
|
{ |
|
32
|
|
|
use SchemaValidatableElementTrait; |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Convert XML into Response |
|
37
|
|
|
* |
|
38
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
39
|
|
|
* @return static |
|
40
|
|
|
* |
|
41
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
|
42
|
|
|
* if the qualified name of the supplied element is wrong |
|
43
|
|
|
* @throws \SimpleSAML\XML\Exception\TooManyElementsException |
|
44
|
|
|
* if too many child-elements of a type are specified |
|
45
|
|
|
* @throws \SimpleSAML\XML\Exception\MissingElementException |
|
46
|
|
|
* if one of the mandatory child-elements is missing |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function fromXML(DOMElement $xml): static |
|
49
|
|
|
{ |
|
50
|
|
|
Assert::same($xml->localName, 'Response', InvalidDOMElementException::class); |
|
51
|
|
|
Assert::same($xml->namespaceURI, Response::NS, InvalidDOMElementException::class); |
|
52
|
|
|
|
|
53
|
|
|
$majorVersion = self::getAttribute($xml, 'MajorVersion', NonNegativeIntegerValue::class); |
|
54
|
|
|
Assert::same($majorVersion->getValue(), '1', VersionMismatchException::class); |
|
55
|
|
|
|
|
56
|
|
|
$minorVersion = self::getAttribute($xml, 'MinorVersion', NonNegativeIntegerValue::class); |
|
57
|
|
|
Assert::same($minorVersion->getValue(), '1', VersionMismatchException::class); |
|
58
|
|
|
|
|
59
|
|
|
$status = Status::getChildrenOfClass($xml); |
|
60
|
|
|
Assert::minCount($status, 1, MissingElementException::class); |
|
61
|
|
|
Assert::maxCount($status, 1, TooManyElementsException::class); |
|
62
|
|
|
|
|
63
|
|
|
return new static( |
|
64
|
|
|
$majorVersion, |
|
65
|
|
|
$minorVersion, |
|
66
|
|
|
self::getAttribute($xml, 'ResponseID', IDValue::class), |
|
67
|
|
|
array_pop($status), |
|
68
|
|
|
self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
|
69
|
|
|
Assertion::getChildrenOfClass($xml), |
|
70
|
|
|
self::getOptionalAttribute($xml, 'InResponseTo', NCNameValue::class, null), |
|
71
|
|
|
self::getOptionalAttribute($xml, 'Recipient', SAMLAnyURIValue::class, null), |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|