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\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:AuthenticationQuery element. |
18
|
|
|
* |
19
|
|
|
* @package simplesaml/saml11 |
20
|
|
|
*/ |
21
|
|
|
final class AuthenticationQuery extends AbstractAuthenticationQueryType implements SchemaValidatableElementInterface |
22
|
|
|
{ |
23
|
|
|
use SchemaValidatableElementTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Convert XML into a AuthenticationQuery |
27
|
|
|
* |
28
|
|
|
* @param \DOMElement $xml The XML element we should load |
29
|
|
|
* @return static |
30
|
|
|
* |
31
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
32
|
|
|
* if the qualified name of the supplied element is wrong |
33
|
|
|
*/ |
34
|
|
|
public static function fromXML(DOMElement $xml): static |
35
|
|
|
{ |
36
|
|
|
Assert::same($xml->localName, 'AuthenticationQuery', InvalidDOMElementException::class); |
37
|
|
|
Assert::same($xml->namespaceURI, AuthenticationQuery::NS, InvalidDOMElementException::class); |
38
|
|
|
|
39
|
|
|
$authenticationMethod = self::getAttribute($xml, 'AuthenticationMethod', SAMLAnyURIValue::class); |
40
|
|
|
|
41
|
|
|
$subject = Subject::getChildrenOfClass($xml); |
42
|
|
|
Assert::minCount($subject, 1, MissingElementException::class); |
43
|
|
|
Assert::maxCount($subject, 1, TooManyElementsException::class); |
44
|
|
|
|
45
|
|
|
return new static(array_pop($subject), $authenticationMethod); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|