|
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
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* SAML BaseID data type. |
|
12
|
|
|
* |
|
13
|
|
|
* @package simplesamlphp/saml2 |
|
14
|
|
|
*/ |
|
15
|
|
|
abstract class AbstractBaseIDType extends AbstractSamlElement implements BaseIdentifierInterface |
|
16
|
|
|
{ |
|
17
|
|
|
use IDNameQualifiersTrait; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Initialize a saml:BaseIDAbstractType from scratch |
|
22
|
|
|
* |
|
23
|
|
|
* @param string|null $nameQualifier |
|
24
|
|
|
* The security or administrative domain that qualifies the identifier. |
|
25
|
|
|
* This attribute provides a means to federate identifiers from disparate user stores without collision. |
|
26
|
|
|
* @param string|null $spNameQualifier |
|
27
|
|
|
* Further qualifies an identifier with the name of a service provider or affiliation of providers. This |
|
28
|
|
|
* attribute provides an additional means to federate identifiers on the basis of the relying party or parties. |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function __construct( |
|
31
|
|
|
protected ?string $nameQualifier = null, |
|
32
|
|
|
protected ?string $spNameQualifier = null, |
|
33
|
|
|
) { |
|
34
|
|
|
Assert::nullOrNotWhitespaceOnly($nameQualifier); |
|
35
|
|
|
Assert::nullOrNotWhitespaceOnly($spNameQualifier); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Convert this BaseID to XML. |
|
41
|
|
|
* |
|
42
|
|
|
* @param \DOMElement $parent The element we are converting to XML. |
|
43
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this BaseID. |
|
44
|
|
|
*/ |
|
45
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
|
46
|
|
|
{ |
|
47
|
|
|
$e = $this->instantiateParentElement($parent); |
|
48
|
|
|
|
|
49
|
|
|
if ($this->getNameQualifier() !== null) { |
|
50
|
|
|
$e->setAttribute('NameQualifier', $this->getNameQualifier()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
if ($this->getSPNameQualifier() !== null) { |
|
54
|
|
|
$e->setAttribute('SPNameQualifier', $this->getSPNameQualifier()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $e; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|