diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index a41931cce655cfa61bb7ce8df54abd35ca026fb8..b14a26f3064f0536e8a590a3e2182cb532f70b11 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -168,15 +168,6 @@ class SAMLBuilder */ private function addExtensions(Configuration $metadata, RoleDescriptor $e): void { - if ($metadata->hasValue('tags')) { - $a = new Attribute(); - $a->setName('tags'); - foreach ($metadata->getArray('tags') as $tag) { - $a->addAttributeValue(new AttributeValue($tag)); - } - $e->setExtensions(array_merge($e->getExtensions(), [$a])); - } - if ($metadata->hasValue('hint.cidr')) { $a = new Attribute(); $a->setName('hint.cidr'); diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 92d7a5e6eb978ddec552bf55d54a28cc3500d3fe..3b79cd0e6835fbf41bf11c84df50996d93f8cd6d 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -147,11 +147,6 @@ class SAMLParser */ private array $registrationInfo; - /** - * @var array - */ - private array $tags; - /** * This is an array of elements that may be used to validate this element. * @@ -198,7 +193,6 @@ class SAMLParser // process Extensions element, if it exists $ext = self::processExtensions($entityElement, $parentExtensions); $this->scopes = $ext['scope']; - $this->tags = $ext['tags']; $this->entityAttributes = $ext['EntityAttributes']; $this->registrationInfo = $ext['RegistrationInfo']; @@ -494,19 +488,12 @@ class SAMLParser private function addExtensions(array &$metadata, array $roleDescriptor): void { Assert::keyExists($roleDescriptor, 'scope'); - Assert::keyExists($roleDescriptor, 'tags'); $scopes = array_merge($this->scopes, array_diff($roleDescriptor['scope'], $this->scopes)); if (!empty($scopes)) { $metadata['scope'] = $scopes; } - $tags = array_merge($this->tags, array_diff($roleDescriptor['tags'], $this->tags)); - if (!empty($tags)) { - $metadata['tags'] = $tags; - } - - if (!empty($this->registrationInfo)) { $metadata['RegistrationInfo'] = $this->registrationInfo; } @@ -749,7 +736,6 @@ class SAMLParser $ext = self::processExtensions($element); $ret['scope'] = $ext['scope']; - $ret['tags'] = $ext['tags']; $ret['EntityAttributes'] = $ext['EntityAttributes']; $ret['UIInfo'] = $ext['UIInfo']; $ret['DiscoHints'] = $ext['DiscoHints']; @@ -888,7 +874,6 @@ class SAMLParser { $ret = [ 'scope' => [], - 'tags' => [], 'EntityAttributes' => [], 'RegistrationInfo' => [], 'UIInfo' => [], @@ -1003,29 +988,6 @@ class SAMLParser $ret['DiscoHints']['GeolocationHint'] = $e->getGeolocationHint(); } } - - if (!($e instanceof Chunk)) { - continue; - } - - if ($e->getLocalName() === 'Attribute' && $e->getNamespaceURI() === Constants::NS_SAML) { - $attribute = $e->getXML(); - - $name = $attribute->getAttribute('Name'); - $xmlUtils = new Utils\XML(); - $values = array_map( - [$xmlUtils, 'getDOMText'], - $xmlUtils->getDOMChildren($attribute, 'AttributeValue', '@saml2') - ); - - if ($name === 'tags') { - foreach ($values as $tagname) { - if (!empty($tagname)) { - $ret['tags'][] = $tagname; - } - } - } - } } return $ret; } diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index d1718342762697b537e04fdfacbd0895b4548ff3..348afcbe6407588a7470b17bf5508f03887d8c6f 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -258,71 +258,6 @@ class XML } - /** - * This function finds direct descendants of a DOM element with the specified - * localName and namespace. They are returned in an array. - * - * This function accepts the same shortcuts for namespaces as the isDOMNodeOfType function. - * - * @param \DOMNode $element The element we should look in. - * @param string $localName The name the element should have. - * @param string $namespaceURI The namespace the element should have. - * - * @return array Array with the matching elements in the order they are found. An empty array is - * returned if no elements match. - * @throws \InvalidArgumentException If $element is not an instance of DOMElement, $localName is not a string or - * $namespaceURI is not a string. - */ - public function getDOMChildren(DOMNode $element, string $localName, string $namespaceURI): array - { - $ret = []; - - for ($i = 0; $i < $element->childNodes->length; $i++) { - /** @var \DOMNode $child */ - $child = $element->childNodes->item($i); - - // skip text nodes and comment elements - if ($child instanceof DOMText || $child instanceof DOMComment) { - continue; - } - - if ($this->isDOMNodeOfType($child, $localName, $namespaceURI) === true) { - $ret[] = $child; - } - } - - return $ret; - } - - - /** - * This function extracts the text from DOMElements which should contain only text content. - * - * @param \DOMElement $element The element we should extract text from. - * - * @return string The text content of the element. - * @throws \SimpleSAML\Error\Exception If the element contains a non-text child node. - * - */ - public function getDOMText(DOMElement $element): string - { - $txt = ''; - - for ($i = 0; $i < $element->childNodes->length; $i++) { - /** @var \DOMElement $child */ - $child = $element->childNodes->item($i); - if (!($child instanceof DOMText)) { - throw new Error\Exception($element->localName . ' contained a non-text child node.'); - } - - $txt .= $child->wholeText; - } - - $txt = trim($txt); - return $txt; - } - - /** * This function checks if the DOMElement has the correct localName and namespaceURI. * diff --git a/tests/lib/SimpleSAML/Utils/XMLTest.php b/tests/lib/SimpleSAML/Utils/XMLTest.php index 83b0896758f407b06e24afaf439f57b4d56487d1..6291fd9578c29b1bf179a3e0efbac68a647f5c5c 100644 --- a/tests/lib/SimpleSAML/Utils/XMLTest.php +++ b/tests/lib/SimpleSAML/Utils/XMLTest.php @@ -128,121 +128,6 @@ class XMLTest extends TestCase } - /** - * @test - */ - public function testGetDomTextBasic(): void - { - $xmlUtils = new Utils\XML(); - - $data = 'root value'; - $dom = new DOMDocument(); - $element = $dom->appendChild(new \DOMElement('root')); - $element->appendChild(new DOMText($data)); - - $res = $xmlUtils->getDOMText($element); - $expected = $data; - - $this->assertEquals($expected, $res); - } - - - /** - * @test - */ - public function testGetDomTextMulti(): void - { - $xmlUtils = new Utils\XML(); - - $data1 = 'root value 1'; - $data2 = 'root value 2'; - $dom = new DOMDocument(); - $element = $dom->appendChild(new DOMElement('root')); - $element->appendChild(new DOMText($data1)); - $element->appendChild(new DOMText($data2)); - - $res = $xmlUtils->getDOMText($element); - $expected = $data1 . $data2 . $data1 . $data2; - - $this->assertEquals($expected, $res); - } - - - /** - * @test - */ - public function testGetDomTextIncorrectType(): void - { - $xmlUtils = new Utils\XML(); - - $this->expectException(Error\Exception::class); - $dom = new DOMDocument(); - $element = $dom->appendChild(new DOMElement('root')); - $element->appendChild(new DOMComment('')); - - $xmlUtils->getDOMText($element); - } - - - /** - * @test - */ - public function testGetDomChildrenBasic(): void - { - $xmlUtils = new Utils\XML(); - - $name = 'name'; - $namespace_uri = 'ns'; - $dom = new DOMDocument(); - $element = new DOMElement($name, 'value', $namespace_uri); - $dom->appendChild($element); - - $res = $xmlUtils->getDOMChildren($dom, $name, $namespace_uri); - $expected = [$element]; - - $this->assertEquals($expected, $res); - } - - - /** - * @test - */ - public function testGetDomChildrenIncorrectType(): void - { - $xmlUtils = new Utils\XML(); - - $dom = new DOMDocument(); - $text = new DOMText('text'); - $comment = new DOMComment('comment'); - $dom->appendChild($text); - $dom->appendChild($comment); - - $res = $xmlUtils->getDOMChildren($dom, 'name', 'ns'); - - $this->assertEmpty($res); - } - - - /** - * @test - */ - public function testGetDomChildrenIncorrectName(): void - { - $xmlUtils = new Utils\XML(); - - $name = 'name'; - $bad_name = 'bad name'; - $namespace_uri = 'ns'; - $dom = new DOMDocument(); - $element = new DOMElement($name, 'value', $namespace_uri); - $dom->appendChild($element); - - $res = $xmlUtils->getDOMChildren($dom, $bad_name, $namespace_uri); - - $this->assertEmpty($res); - } - - /** * @test */