Skip to content
Snippets Groups Projects
Commit 95d6ac3f authored by Olav Morken's avatar Olav Morken
Browse files

SAML2_Utils: Add the new addStrings()-function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2201 44740490-163a-0410-bde0-09ae8108e29a
parent 5bb22d77
No related branches found
No related tags found
No related merge requests found
...@@ -1070,12 +1070,7 @@ class SAML2_Assertion implements SAML2_SignedElement { ...@@ -1070,12 +1070,7 @@ class SAML2_Assertion implements SAML2_SignedElement {
$ar = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AudienceRestriction'); $ar = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AudienceRestriction');
$conditions->appendChild($ar); $conditions->appendChild($ar);
foreach ($this->validAudiences as $audience) { SAML2_Utils::addStrings($ar, SAML2_Const::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
$a = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:Audience');
$ar->appendChild($a);
$a->appendChild($document->createTextNode($audience));
}
} }
} }
......
...@@ -388,4 +388,31 @@ class SAML2_Utils { ...@@ -388,4 +388,31 @@ class SAML2_Utils {
return $n; 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);
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment