diff --git a/src/SAML2/XML/saml/AbstractBaseID.php b/src/SAML2/XML/saml/AbstractBaseID.php index bf3811a47..84a69ea2e 100644 --- a/src/SAML2/XML/saml/AbstractBaseID.php +++ b/src/SAML2/XML/saml/AbstractBaseID.php @@ -146,6 +146,7 @@ public function toXML(DOMElement $parent = null): DOMElement return $e; } + public function getBlacklistedAlgorithms(): ?array { $container = ContainerSingleton::getInstance(); diff --git a/src/SAML2/XML/saml/AbstractBaseIDType.php b/src/SAML2/XML/saml/AbstractBaseIDType.php index c4b880ef5..0305291c4 100644 --- a/src/SAML2/XML/saml/AbstractBaseIDType.php +++ b/src/SAML2/XML/saml/AbstractBaseIDType.php @@ -14,6 +14,9 @@ */ abstract class AbstractBaseIDType extends AbstractSamlElement implements BaseIdentifierInterface { + use IDNameQualifiersTrait; + + /** * Initialize a saml:BaseIDAbstractType from scratch * @@ -33,28 +36,6 @@ protected function __construct( } - /** - * Collect the value of the NameQualifier-property - * - * @return string|null - */ - public function getNameQualifier(): ?string - { - return $this->nameQualifier; - } - - - /** - * Collect the value of the SPNameQualifier-property - * - * @return string|null - */ - public function getSPNameQualifier(): ?string - { - return $this->spNameQualifier; - } - - /** * Convert this BaseID to XML. * diff --git a/src/SAML2/XML/saml/IDNameQualifiersTrait.php b/src/SAML2/XML/saml/IDNameQualifiersTrait.php new file mode 100644 index 000000000..c573f7657 --- /dev/null +++ b/src/SAML2/XML/saml/IDNameQualifiersTrait.php @@ -0,0 +1,34 @@ +nameQualifier; + } + + + /** + * Collect the value of the SPNameQualifier-property + * + * @return string|null + */ + public function getSPNameQualifier(): ?string + { + return $this->spNameQualifier; + } +} diff --git a/src/SAML2/XML/saml/NameIDType.php b/src/SAML2/XML/saml/NameIDType.php index 87c6511c2..7f55061f6 100644 --- a/src/SAML2/XML/saml/NameIDType.php +++ b/src/SAML2/XML/saml/NameIDType.php @@ -14,8 +14,9 @@ * @package simplesamlphp/saml2 */ -abstract class NameIDType extends AbstractBaseIDType +abstract class NameIDType extends AbstractSamlElement implements IdentifierInterface { + use IDNameQualifiersTrait; use StringElementTrait; @@ -30,16 +31,16 @@ abstract class NameIDType extends AbstractBaseIDType */ protected function __construct( string $value, - ?string $nameQualifier = null, - ?string $spNameQualifier = null, + protected ?string $nameQualifier = null, + protected ?string $spNameQualifier = null, protected ?string $format = null, protected ?string $spProvidedID = null, ) { + Assert::nullOrNotWhitespaceOnly($nameQualifier); + Assert::nullOrNotWhitespaceOnly($spNameQualifier); Assert::nullOrValidURI($format); // Covers the empty string Assert::nullOrNotWhitespaceOnly($spProvidedID); - parent::__construct($nameQualifier, $spNameQualifier); - $this->setContent($value); } @@ -87,7 +88,15 @@ protected function validateContent(string $content): void */ public function toXML(DOMElement $parent = null): DOMElement { - $e = parent::toXML($parent); + $e = $this->instantiateParentElement($parent); + + if ($this->getNameQualifier() !== null) { + $e->setAttribute('NameQualifier', $this->getNameQualifier()); + } + + if ($this->getSPNameQualifier() !== null) { + $e->setAttribute('SPNameQualifier', $this->getSPNameQualifier()); + } if ($this->getFormat() !== null) { $e->setAttribute('Format', $this->getFormat());