public function XMLSecurityDSig::processTransforms in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7
Parameters
$refNode:
DOMNode $objData:
bool $includeCommentNodes:
Return value
string
2 calls to XMLSecurityDSig::processTransforms()
- XMLSecurityDSig::addRefInternal in includes/
XMLSecurityKey.php - XMLSecurityDSig::processRefNode in includes/
XMLSecurityKey.php
File
- includes/
XMLSecurityKey.php, line 1088
Class
Code
public function processTransforms($refNode, $objData, $includeCommentNodes = true) {
$data = $objData;
$xpath = new DOMXPath($refNode->ownerDocument);
$xpath
->registerNamespace('secdsig', self::XMLDSIGNS);
$query = './secdsig:Transforms/secdsig:Transform';
$nodelist = $xpath
->query($query, $refNode);
$canonicalMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
$arXPath = null;
$prefixList = null;
foreach ($nodelist as $transform) {
$algorithm = $transform
->getAttribute("Algorithm");
switch ($algorithm) {
case 'http://www.w3.org/2001/10/xml-exc-c14n#':
case 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments':
if (!$includeCommentNodes) {
/* We remove comment nodes by forcing it to use a canonicalization
* without comments.
*/
$canonicalMethod = 'http://www.w3.org/2001/10/xml-exc-c14n#';
}
else {
$canonicalMethod = $algorithm;
}
$node = $transform->firstChild;
while ($node) {
if ($node->localName == 'InclusiveNamespaces') {
if ($pfx = $node
->getAttribute('PrefixList')) {
$arpfx = array();
$pfxlist = explode(" ", $pfx);
foreach ($pfxlist as $pfx) {
$val = trim($pfx);
if (!empty($val)) {
$arpfx[] = $val;
}
}
if (count($arpfx) > 0) {
$prefixList = $arpfx;
}
}
break;
}
$node = $node->nextSibling;
}
break;
case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315':
case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments':
if (!$includeCommentNodes) {
/* We remove comment nodes by forcing it to use a canonicalization
* without comments.
*/
$canonicalMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
}
else {
$canonicalMethod = $algorithm;
}
break;
case 'http://www.w3.org/TR/1999/REC-xpath-19991116':
$node = $transform->firstChild;
while ($node) {
if ($node->localName == 'XPath') {
$arXPath = array();
$arXPath['query'] = '(.//. | .//@* | .//namespace::*)[' . $node->nodeValue . ']';
$arXPath['namespaces'] = array();
$nslist = $xpath
->query('./namespace::*', $node);
foreach ($nslist as $nsnode) {
if ($nsnode->localName != "xml") {
$arXPath['namespaces'][$nsnode->localName] = $nsnode->nodeValue;
}
}
break;
}
$node = $node->nextSibling;
}
break;
}
}
if ($data instanceof DOMNode) {
$data = $this
->canonicalizeData($objData, $canonicalMethod, $arXPath, $prefixList);
}
return $data;
}