You are here

private function XMLSecurityDSig::canonicalizeData in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

Parameters

DOMNode $node:

string $canonicalmethod:

null|array $arXPath:

null|array $prefixList:

Return value

string

3 calls to XMLSecurityDSig::canonicalizeData()
XMLSecurityDSig::canonicalizeSignedInfo in src/XMLSecurityKey.php
XMLSecurityDSig::processTransforms in src/XMLSecurityKey.php
XMLSecurityDSig::sign in src/XMLSecurityKey.php

File

src/XMLSecurityKey.php, line 932

Class

XMLSecurityDSig

Namespace

Drupal\miniorange_saml

Code

private function canonicalizeData($node, $canonicalmethod, $arXPath = null, $prefixList = null) {
  $exclusive = false;
  $withComments = false;
  switch ($canonicalmethod) {
    case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315':
      $exclusive = false;
      $withComments = false;
      break;
    case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments':
      $withComments = true;
      break;
    case 'http://www.w3.org/2001/10/xml-exc-c14n#':
      $exclusive = true;
      break;
    case 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments':
      $exclusive = true;
      $withComments = true;
      break;
  }
  if (is_null($arXPath) && $node instanceof DOMNode && $node->ownerDocument !== null && $node
    ->isSameNode($node->ownerDocument->documentElement)) {

    /* Check for any PI or comments as they would have been excluded */
    $element = $node;
    while ($refnode = $element->previousSibling) {
      if ($refnode->nodeType == XML_PI_NODE || $refnode->nodeType == XML_COMMENT_NODE && $withComments) {
        break;
      }
      $element = $refnode;
    }
    if ($refnode == null) {
      $node = $node->ownerDocument;
    }
  }
  return $node
    ->C14N($exclusive, $withComments, $arXPath, $prefixList);
}