66
77use DOMElement ;
88use SimpleSAML \WSSecurity \Assert \Assert ;
9- use SimpleSAML \XML \Exception \InvalidDOMElementException ;
109use SimpleSAML \XML \ExtendableAttributesTrait ;
11- use SimpleSAML \XML \XsNamespace as NS ;
10+ use SimpleSAML \XMLSchema \Exception \InvalidDOMElementException ;
11+ use SimpleSAML \XMLSchema \XML \Constants \NS ;
12+ use SimpleSAML \XMLSchema \Type \AnyURIValue ;
13+ use SimpleSAML \XMLSchema \Type \QNameValue ;
1214
1315use function sprintf ;
1416
@@ -28,28 +30,25 @@ abstract class AbstractHeaderType extends AbstractSpElement
2830 /**
2931 * AbstractHeaderType constructor.
3032 *
31- * @param string $namespace
32- * @param string |null $name
33+ * @param \SimpleSAML\XMLSchema\Type\AnyURIValue $namespace
34+ * @param \SimpleSAML\XMLSchema\Type\QNameValue |null $name
3335 * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
3436 */
3537 final public function __construct (
36- protected string $ namespace ,
37- protected ?string $ name = null ,
38+ protected AnyURIValue $ namespace ,
39+ protected ?QNameValue $ name = null ,
3840 array $ namespacedAttributes = [],
3941 ) {
40- Assert::validURI ($ namespace );
41- Assert::nullOrValidQName ($ name );
42-
4342 $ this ->setAttributesNS ($ namespacedAttributes );
4443 }
4544
4645
4746 /**
4847 * Collect the value of the Name property.
4948 *
50- * @return string |null
49+ * @return \SimpleSAML\XMLSchema\Type\QNameValue |null
5150 */
52- public function getName (): ?string
51+ public function getName (): ?QNameValue
5352 {
5453 return $ this ->name ;
5554 }
@@ -58,9 +57,9 @@ public function getName(): ?string
5857 /**
5958 * Collect the value of the Namespace property.
6059 *
61- * @return string
60+ * @return \SimpleSAML\XMLSchema\Type\AnyURIValue
6261 */
63- public function getNamespace (): string
62+ public function getNamespace (): AnyURIValue
6463 {
6564 return $ this ->namespace ;
6665 }
@@ -74,7 +73,7 @@ public function getNamespace(): string
7473 * @param \DOMElement $xml The XML element we should load.
7574 * @return static
7675 *
77- * @throws \SimpleSAML\XML \Exception\InvalidDOMElementException
76+ * @throws \SimpleSAML\XMLSchema \Exception\InvalidDOMElementException
7877 * if the qualified name of the supplied element is wrong
7978 */
8079 public static function fromXML (DOMElement $ xml ): static
@@ -97,8 +96,8 @@ public static function fromXML(DOMElement $xml): static
9796 }
9897
9998 return new static (
100- self ::getAttribute ($ xml , 'Namespace ' ),
101- self ::getOptionalAttribute ($ xml , 'Name ' , null ),
99+ self ::getAttribute ($ xml , 'Namespace ' , AnyURIValue::class ),
100+ self ::getOptionalAttribute ($ xml , 'Name ' , QNameValue::class, null ),
102101 $ namespacedAttributes ,
103102 );
104103 }
@@ -115,10 +114,10 @@ public function toXML(?DOMElement $parent = null): DOMElement
115114 $ e = $ this ->instantiateParentElement ($ parent );
116115
117116 if ($ this ->getName () !== null ) {
118- $ e ->setAttribute ('Name ' , $ this ->getName ());
117+ $ e ->setAttribute ('Name ' , $ this ->getName ()-> getValue () );
119118 }
120119
121- $ e ->setAttribute ('Namespace ' , $ this ->getNamespace ());
120+ $ e ->setAttribute ('Namespace ' , $ this ->getNamespace ()-> getValue () );
122121
123122 foreach ($ this ->getAttributesNS () as $ attr ) {
124123 $ attr ->toXML ($ e );
0 commit comments