Revision: 2200
Author: olavmrk
Date: Fri Mar 5 07:12:21 2010
Log: SAML2_Utils: Add the new addString()-function.
http://code.google.com/p/simplesamlphp/source/detail?r=2200
Modified:
/trunk/lib/SAML2/Assertion.php
/trunk/lib/SAML2/AttributeQuery.php
/trunk/lib/SAML2/AuthnRequest.php
/trunk/lib/SAML2/LogoutRequest.php
/trunk/lib/SAML2/Message.php
/trunk/lib/SAML2/StatusResponse.php
/trunk/lib/SAML2/Utils.php
=======================================
--- /trunk/lib/SAML2/Assertion.php Fri Mar 5 07:12:00 2010
+++ /trunk/lib/SAML2/Assertion.php Fri Mar 5 07:12:21 2010
@@ -995,9 +995,7 @@
$root->setAttribute('Version', '2.0');
$root->setAttribute('IssueInstant', gmdate('Y-m-d\TH:i:s\Z',
$this->issueInstant));
- $issuer =
$document->createElementNS(SAML2_Const::NS_SAML, 'saml:Issuer');
- $issuer->appendChild($document->createTextNode($this->issuer));
- $root->appendChild($issuer);
+ $issuer = SAML2_Utils::addString($root,
SAML2_Const::NS_SAML, 'saml:Issuer', $this->issuer);
$this->addSubject($root);
$this->addConditions($root);
@@ -1111,10 +1109,7 @@
$ac =
$document->createElementNS(SAML2_Const::NS_SAML, 'saml:AuthnContext');
$as->appendChild($ac);
- $accr =
$document->createElementNS(SAML2_Const::NS_SAML, 'saml:AuthnContextClassRef');
- $ac->appendChild($accr);
-
-
$accr->appendChild($document->createTextNode($this->authnContext));
+ SAML2_Utils::addString($ac,
SAML2_Const::NS_SAML, 'saml:AuthnContextClassRef', $this->authnContext);
}
=======================================
--- /trunk/lib/SAML2/AttributeQuery.php Mon Sep 7 02:25:30 2009
+++ /trunk/lib/SAML2/AttributeQuery.php Fri Mar 5 07:12:21 2010
@@ -162,12 +162,10 @@
$type = NULL;
}
- $attributeValue =
$root->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
- $attribute->appendChild($attributeValue);
+ $attributeValue = SAML2_Utils::addString($attribute,
SAML2_Const::NS_SAML, 'saml:AttributeValue', $value);
if ($type !== NULL) {
$attributeValue->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type',
$type);
}
-
$attributeValue->appendChild($root->ownerDocument->createTextNode($value));
}
}
=======================================
--- /trunk/lib/SAML2/AuthnRequest.php Thu Nov 12 06:43:03 2009
+++ /trunk/lib/SAML2/AuthnRequest.php Fri Mar 5 07:12:21 2010
@@ -348,9 +348,7 @@
$e->setAttribute('Comparison',
$rac['Comparison']);
}
foreach ($rac['AuthnContextClassRef'] as $accr) {
- $i =
$this->document->createElementNS(SAML2_Const::NS_SAML, 'AuthnContextClassRef');
-
$i->appendChild($this->document->createTextNode($accr));
- $e->appendChild($i);
+ SAML2_Utils::addString($e,
SAML2_Const::NS_SAML, 'AuthnContextClassRef', $accr);
}
}
=======================================
--- /trunk/lib/SAML2/LogoutRequest.php Mon Sep 7 02:25:30 2009
+++ /trunk/lib/SAML2/LogoutRequest.php Fri Mar 5 07:12:21 2010
@@ -109,9 +109,7 @@
SAML2_Utils::addNameId($root, $this->nameId);
if ($this->sessionIndex !== NULL) {
- $sessionIndex =
$this->document->createElementNS(SAML2_Const::NS_SAMLP, 'SessionIndex');
-
$sessionIndex->appendChild($this->document->createTextNode($this->sessionIndex));
- $root->appendChild($sessionIndex);
+ SAML2_Utils::addString($root, SAML2_Const::NS_SAMLP, 'SessionIndex',
$this->sessionIndex);
}
return $root;
=======================================
--- /trunk/lib/SAML2/Message.php Fri Jan 15 02:10:50 2010
+++ /trunk/lib/SAML2/Message.php Fri Mar 5 07:12:21 2010
@@ -357,9 +357,7 @@
}
if ($this->issuer !== NULL) {
- $issuer =
$this->document->createElementNS(SAML2_Const::NS_SAML, 'saml:Issuer');
-
$issuer->appendChild($this->document->createTextNode($this->issuer));
- $root->appendChild($issuer);
+ SAML2_Utils::addString($root, SAML2_Const::NS_SAML, 'saml:Issuer',
$this->issuer);
}
return $root;
=======================================
--- /trunk/lib/SAML2/StatusResponse.php Mon Sep 7 02:25:30 2009
+++ /trunk/lib/SAML2/StatusResponse.php Fri Mar 5 07:12:21 2010
@@ -181,9 +181,7 @@
}
if (!is_null($this->status['Message'])) {
- $statusMessage =
$this->document->createElementNS(SAML2_Const::NS_SAMLP, 'StatusMessage');
-
$statusMessage->appendChild($this->document->createTextNode($this->status['Message']));
- $status->appendChild($statusMessage);
+ SAML2_Utils::addString($status, SAML2_Const::NS_SAMLP, 'StatusMessage',
$this->status['Message']);
}
return $root;
=======================================
--- /trunk/lib/SAML2/Utils.php Fri Mar 5 07:12:00 2010
+++ /trunk/lib/SAML2/Utils.php Fri Mar 5 07:12:21 2010
@@ -175,8 +175,7 @@
public static function addNameId(DOMElement $node, array $nameId) {
assert('array_key_exists("Value", $nameId)');
- $xml =
$node->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:NameID');
- $node->appendChild($xml);
+ $xml = SAML2_Utils::addString($node,
SAML2_Const::NS_SAML, 'saml:NameID', $nameId['Value']);
if (array_key_exists('NameQualifier', $nameId) &&
$nameId['NameQualifier'] !== NULL) {
$xml->setAttribute('NameQualifier',
$nameId['NameQualifier']);
@@ -187,8 +186,6 @@
if (array_key_exists('Format', $nameId) && $nameId['Format']
!== NULL) {
$xml->setAttribute('Format', $nameId['Format']);
}
-
-
$xml->appendChild($node->ownerDocument->createTextNode($nameId['Value']));
}
@@ -366,5 +363,29 @@
return $ret;
}
+
+
+ /**
+ * Append string element.
+ *
+ * @param DOMElement $parent The parent element we should append the new
nodes to.
+ * @param string $namespace The namespace of the created element.
+ * @param string $name The name of the created element.
+ * @param string $value The value of the element.
+ * @return DOMElement The generated element.
+ */
+ public static function addString(DOMElement $parent, $namespace, $name,
$value) {
+ assert('is_string($namespace)');
+ assert('is_string($name)');
+ assert('is_string($value)');
+
+ $doc = $parent->ownerDocument;
+
+ $n = $doc->createElementNS($namespace, $name);
+ $n->appendChild($doc->createTextNode($value));
+ $parent->appendChild($n);
+
+ return $n;
+ }
}
--
You received this message because you are subscribed to the Google Groups
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simplesamlphp-commits?hl=en.