1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML11\XML\samlp; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML11\Type\SAMLAnyURIValue; |
10
|
|
|
use SimpleSAML\SAML11\XML\saml\{Action, Evidence, Subject}; |
11
|
|
|
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait}; |
12
|
|
|
use SimpleSAML\XMLSchema\Exception\{InvalidDOMElementException, MissingElementException, TooManyElementsException}; |
13
|
|
|
|
14
|
|
|
use function array_pop; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class representing a samlp:AuthorizationDecisionQuery element. |
18
|
|
|
* |
19
|
|
|
* @package simplesaml/saml11 |
20
|
|
|
*/ |
21
|
|
|
final class AuthorizationDecisionQuery extends AbstractAuthorizationDecisionQueryType implements |
22
|
|
|
SchemaValidatableElementInterface |
23
|
|
|
{ |
24
|
|
|
use SchemaValidatableElementTrait; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Convert XML into a AuthorizationDecisionQuery |
28
|
|
|
* |
29
|
|
|
* @param \DOMElement $xml The XML element we should load |
30
|
|
|
* @return static |
31
|
|
|
* |
32
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
33
|
|
|
* if the qualified name of the supplied element is wrong |
34
|
|
|
*/ |
35
|
|
|
public static function fromXML(DOMElement $xml): static |
36
|
|
|
{ |
37
|
|
|
Assert::same($xml->localName, 'AuthorizationDecisionQuery', InvalidDOMElementException::class); |
38
|
|
|
Assert::same($xml->namespaceURI, AuthorizationDecisionQuery::NS, InvalidDOMElementException::class); |
39
|
|
|
|
40
|
|
|
$resource = self::getAttribute($xml, 'Resource', SAMLAnyURIValue::class); |
41
|
|
|
|
42
|
|
|
$subject = Subject::getChildrenOfClass($xml); |
43
|
|
|
Assert::minCount($subject, 1, MissingElementException::class); |
44
|
|
|
Assert::maxCount($subject, 1, TooManyElementsException::class); |
45
|
|
|
|
46
|
|
|
$action = Action::getChildrenOfClass($xml); |
47
|
|
|
Assert::minCount($action, 1, MissingElementException::class); |
48
|
|
|
|
49
|
|
|
$evidence = Evidence::getChildrenOfClass($xml); |
50
|
|
|
Assert::maxCount($evidence, 1, TooManyElementsException::class); |
51
|
|
|
|
52
|
|
|
return new static(array_pop($subject), $resource, array_pop($evidence), $action); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|