1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\saml; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML2\Compat\ContainerSingleton; |
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11
|
|
|
use SimpleSAML\XMLSecurity\Backend\EncryptionBackend; |
12
|
|
|
use SimpleSAML\XMLSecurity\XML\EncryptableElementInterface; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\EncryptableElementTrait; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class representing the saml:NameID element. |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/saml2 |
19
|
|
|
*/ |
20
|
|
|
final class NameID extends NameIDType implements EncryptableElementInterface |
21
|
|
|
{ |
22
|
|
|
use EncryptableElementTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Initialize a saml:NameID |
26
|
|
|
* |
27
|
|
|
* @param string $value |
28
|
|
|
* @param string|null $NameQualifier |
29
|
|
|
* @param string|null $SPNameQualifier |
30
|
|
|
* @param string|null $Format |
31
|
|
|
* @param string|null $SPProvidedID |
32
|
|
|
*/ |
33
|
|
|
public function __construct( |
34
|
|
|
string $value, |
35
|
|
|
?string $NameQualifier = null, |
36
|
|
|
?string $SPNameQualifier = null, |
37
|
|
|
?string $Format = null, |
38
|
|
|
?string $SPProvidedID = null |
39
|
|
|
) { |
40
|
|
|
parent::__construct($value, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Convert XML into an NameID |
46
|
|
|
* |
47
|
|
|
* @param \DOMElement $xml The XML element we should load |
48
|
|
|
* @return self |
49
|
|
|
* |
50
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
51
|
|
|
* if the qualified name of the supplied element is wrong |
52
|
|
|
*/ |
53
|
|
|
public static function fromXML(DOMElement $xml): static |
54
|
|
|
{ |
55
|
|
|
Assert::same($xml->localName, 'NameID', InvalidDOMElementException::class); |
56
|
|
|
Assert::same($xml->namespaceURI, NameID::NS, InvalidDOMElementException::class); |
57
|
|
|
|
58
|
|
|
$NameQualifier = self::getAttribute($xml, 'NameQualifier', null); |
59
|
|
|
$SPNameQualifier = self::getAttribute($xml, 'SPNameQualifier', null); |
60
|
|
|
$Format = self::getAttribute($xml, 'Format', null); |
61
|
|
|
$SPProvidedID = self::getAttribute($xml, 'SPProvidedID', null); |
62
|
|
|
|
63
|
|
|
return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
public function getBlacklistedAlgorithms(): ?array |
68
|
|
|
{ |
69
|
|
|
$container = ContainerSingleton::getInstance(); |
70
|
|
|
return $container->getBlacklistedEncryptionAlgorithms(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
public function getEncryptionBackend(): ?EncryptionBackend |
75
|
|
|
{ |
76
|
|
|
// return the encryption backend you want to use, |
77
|
|
|
// or null if you are fine with the default |
78
|
|
|
return null; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|