diff options
author | Olav Morken <olav.morken@uninett.no> | 2010-03-05 15:12:33 +0000 |
---|---|---|
committer | Olav Morken <olav.morken@uninett.no> | 2010-03-05 15:12:33 +0000 |
commit | 95d6ac3fac4122e3e6dde8e3ee184f4754330bfd (patch) | |
tree | 4ec94436db269748129e5b3351fe7c0ad294c7e6 /lib/SAML2 | |
parent | 5bb22d7734bac4e9711bca4d9f356b82585d1c52 (diff) | |
download | simplesamlphp-95d6ac3fac4122e3e6dde8e3ee184f4754330bfd.zip simplesamlphp-95d6ac3fac4122e3e6dde8e3ee184f4754330bfd.tar.gz simplesamlphp-95d6ac3fac4122e3e6dde8e3ee184f4754330bfd.tar.bz2 |
SAML2_Utils: Add the new addStrings()-function.
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2201 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/SAML2')
-rw-r--r-- | lib/SAML2/Assertion.php | 7 | ||||
-rw-r--r-- | lib/SAML2/Utils.php | 27 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lib/SAML2/Assertion.php b/lib/SAML2/Assertion.php index 4144964..de3ca91 100644 --- a/lib/SAML2/Assertion.php +++ b/lib/SAML2/Assertion.php @@ -1070,12 +1070,7 @@ class SAML2_Assertion implements SAML2_SignedElement { $ar = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AudienceRestriction'); $conditions->appendChild($ar); - foreach ($this->validAudiences as $audience) { - $a = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:Audience'); - $ar->appendChild($a); - - $a->appendChild($document->createTextNode($audience)); - } + SAML2_Utils::addStrings($ar, SAML2_Const::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences); } } diff --git a/lib/SAML2/Utils.php b/lib/SAML2/Utils.php index 42b5c55..e2ae335 100644 --- a/lib/SAML2/Utils.php +++ b/lib/SAML2/Utils.php @@ -388,4 +388,31 @@ class SAML2_Utils { return $n; } + + /** + * Append string elements. + * + * @param DOMElement $parent The parent element we should append the new nodes to. + * @param string $namespace The namespace of the created elements + * @param string $name The name of the created elements + * @param bool $localized Whether the strings are localized, and should include the xml:lang attribute. + * @param array $values The values we should create the elements from. + */ + public static function addStrings(DOMElement $parent, $namespace, $name, $localized, array $values) { + assert('is_string($namespace)'); + assert('is_string($name)'); + assert('is_bool($localized)'); + + $doc = $parent->ownerDocument; + + foreach ($values as $index => $value) { + $n = $doc->createElementNS($namespace, $name); + $n->appendChild($doc->createTextNode($value)); + if ($localized) { + $n->setAttribute('xml:lang', $index); + } + $parent->appendChild($n); + } + } + } |