diff --git a/src/XML/wst/AbstractRequestedSecurityTokenType.php b/src/XML/wst/AbstractRequestedSecurityTokenType.php new file mode 100644 index 00000000..40772b86 --- /dev/null +++ b/src/XML/wst/AbstractRequestedSecurityTokenType.php @@ -0,0 +1,92 @@ +setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = []; + foreach ($xml->childNodes as $child) { + if (!($child instanceof DOMElement)) { + continue; + } + + $children[] = new Chunk($child); + } + + Assert::minCount($children, 1, MissingElementInterfaceException::class); + Assert::maxCount($children, 1, TooManyElementsInterfaceException::class); + + return new static(array_pop($children)); + } + + + /** + * Add this RequestedSecurityTokenType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst/RequestedSecurityToken.php b/src/XML/wst/RequestedSecurityToken.php new file mode 100644 index 00000000..08ddf684 --- /dev/null +++ b/src/XML/wst/RequestedSecurityToken.php @@ -0,0 +1,14 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestedSecurityToken), + ); + } +} diff --git a/tests/resources/xml/wst_RequestedSecurityToken.xml b/tests/resources/xml/wst_RequestedSecurityToken.xml new file mode 100644 index 00000000..ff04ea4b --- /dev/null +++ b/tests/resources/xml/wst_RequestedSecurityToken.xml @@ -0,0 +1,3 @@ + + uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de +