From 8f6f31893ecfd427e53eaa8cee8ab42e07bf80db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Fri, 19 Dec 2008 11:38:55 +0000 Subject: [PATCH] Add support for adding contact persons in generated SAML 2.0 Metadata. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1068 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Metadata/SAMLBuilder.php | 41 ++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 1bf1568ea..400dbe060 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -139,6 +139,25 @@ class SimpleSAML_Metadata_SAMLBuilder { } $this->entityDescriptor->appendChild($e); + + if (array_key_exists('contacts', $metadata) && is_array($metadata['contacts']) ) { + foreach($metadata['contacts'] AS $contact) { + if (array_key_exists('contactType', $contact) && array_key_exists('EmailAddress', $contact)) { + $t = $this->createElement('ContactPerson'); + $t->setAttribute('contactType', $contact['contactType']); + + if (array_key_exists('SurName', $contact)) { + $surname = $this->createTextElement('SurName', $contact['SurName']); + $t->appendChild($surname); + } + + $email = $this->createTextElement('EmailAddress', $contact['EmailAddress']); + $t->appendChild($email); + + $this->entityDescriptor->appendChild($t); + } + } + } } @@ -183,8 +202,28 @@ class SimpleSAML_Metadata_SAMLBuilder { $t->setAttribute('Location', $metadata['SingleSignOnService']); $e->appendChild($t); } - + $this->entityDescriptor->appendChild($e); + + if (array_key_exists('contacts', $metadata) && is_array($metadata['contacts']) ) { + foreach($metadata['contacts'] AS $contact) { + if (array_key_exists('contactType', $contact) && array_key_exists('EmailAddress', $contact)) { + $t = $this->createElement('ContactPerson'); + $t->setAttribute('contactType', $contact['contactType']); + + if (array_key_exists('SurName', $contact)) { + $surname = $this->createTextElement('SurName', $contact['SurName']); + $t->appendChild($surname); + } + + $email = $this->createTextElement('EmailAddress', $contact['EmailAddress']); + $t->appendChild($email); + + $this->entityDescriptor->appendChild($t); + } + } + } + } -- GitLab