1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SPID\XML\saml; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML2\Constants as C; |
10
|
|
|
use SimpleSAML\SAML2\XML\saml\NameIDType; |
11
|
|
|
use SimpleSAML\SPID\Exception\ProtocolViolationException; |
12
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class representing the saml:Issuer element compliant with SPID specification. |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/saml2-module-spid |
18
|
|
|
*/ |
19
|
|
|
final class Issuer extends NameIDType |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Initialize a saml:Issuer conforming to SPID specification |
23
|
|
|
* |
24
|
|
|
* @param string $value |
25
|
|
|
* @param string $NameQualifier |
26
|
|
|
*/ |
27
|
|
|
public function __construct( |
28
|
|
|
string $value, |
29
|
|
|
string $NameQualifier, |
30
|
|
|
) { |
31
|
|
|
parent::__construct($value, $NameQualifier, null, C::NAMEID_ENTITY); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Convert XML into an Issuer |
37
|
|
|
* |
38
|
|
|
* @param \DOMElement $xml The XML element we should load |
39
|
|
|
* |
40
|
|
|
* @return static |
41
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
42
|
|
|
* @throws \SimpleSAML\SPID\Exception\ProtocolViolationException |
43
|
|
|
*/ |
44
|
|
|
public static function fromXML(DOMElement $xml): static |
45
|
|
|
{ |
46
|
|
|
Assert::same($xml->localName, 'Issuer', InvalidDOMElementException::class); |
47
|
|
|
Assert::same($xml->namespaceURI, Issuer::NS, InvalidDOMElementException::class); |
48
|
|
|
|
49
|
|
|
$format = self::getAttribute($xml, 'Format'); |
50
|
|
|
Assert::same($format, C::NAMEID_ENTITY, ProtocolViolationException::class); |
51
|
|
|
|
52
|
|
|
$nameQualifier = self::getAttribute($xml, 'NameQualifier'); |
53
|
|
|
return new static($xml->textContent, $nameQualifier); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|