From e6fcd7fee633ba0f0b7eb443c91d6fbe809c7b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Wed, 7 Jan 2009 08:15:10 +0000 Subject: [PATCH] Do not add asertionconsumerservice attribute when neigther name or attributes is set in metadata git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1084 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Metadata/SAMLBuilder.php | 77 +++++++++++++------------ 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index f275a79cc..998f3aa62 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -185,52 +185,53 @@ class SimpleSAML_Metadata_SAMLBuilder { $e->appendChild($t); } - - /** - * Add an AttributeConsumingService element with information as name and description and list - * of requested attributes - */ - $attributeconsumer = $this->createElement('AttributeConsumingService'); - $attributeconsumer->setAttribute('index', '0'); - - if (array_key_exists('name', $metadata)) { - if (is_array($metadata['name'])) { - foreach($metadata['name'] AS $lang => $localname) { - $t = $this->createTextElement('ServiceName', $localname); - $t->setAttribute('xml:lang', $lang); + if (array_key_exists('name', $metadata) || array_key_exists('attributes', $metadata)) { + /** + * Add an AttributeConsumingService element with information as name and description and list + * of requested attributes + */ + $attributeconsumer = $this->createElement('AttributeConsumingService'); + $attributeconsumer->setAttribute('index', '0'); + + if (array_key_exists('name', $metadata)) { + if (is_array($metadata['name'])) { + foreach($metadata['name'] AS $lang => $localname) { + $t = $this->createTextElement('ServiceName', $localname); + $t->setAttribute('xml:lang', $lang); + $attributeconsumer->appendChild($t); + } + } else { + $t = $this->createTextElement('ServiceName', $metadata['name']); + $t->setAttribute('xml:lang', 'en'); $attributeconsumer->appendChild($t); } - } else { - $t = $this->createTextElement('ServiceName', $metadata['name']); - $t->setAttribute('xml:lang', 'en'); - $attributeconsumer->appendChild($t); } - } - - - - if (array_key_exists('description', $metadata)) { - if (is_array($metadata['description'])) { - foreach($metadata['description'] AS $lang => $localname) { - $t = $this->createTextElement('ServiceDescription', $localname); - $t->setAttribute('xml:lang', $lang); + + + + if (array_key_exists('description', $metadata)) { + if (is_array($metadata['description'])) { + foreach($metadata['description'] AS $lang => $localname) { + $t = $this->createTextElement('ServiceDescription', $localname); + $t->setAttribute('xml:lang', $lang); + $attributeconsumer->appendChild($t); + } + } else { + $t = $this->createTextElement('ServiceDescription', $metadata['description']); + $t->setAttribute('xml:lang', 'en'); $attributeconsumer->appendChild($t); } - } else { - $t = $this->createTextElement('ServiceDescription', $metadata['description']); - $t->setAttribute('xml:lang', 'en'); - $attributeconsumer->appendChild($t); } - } - - if (array_key_exists('attributes', $metadata) && is_array($metadata['attributes'])) { - foreach ($metadata['attributes'] AS $attribute) { - $t = $this->createElement('RequestedAttribute'); - $t->setAttribute('Name', $attribute); - $attributeconsumer->appendChild($t); + + if (array_key_exists('attributes', $metadata) && is_array($metadata['attributes'])) { + foreach ($metadata['attributes'] AS $attribute) { + $t = $this->createElement('RequestedAttribute'); + $t->setAttribute('Name', $attribute); + $attributeconsumer->appendChild($t); + } } + $e->appendChild($attributeconsumer); } - $e->appendChild($attributeconsumer); $this->entityDescriptor->appendChild($e); -- GitLab