You are here

public function XMLSecurityDSig::locateSignature in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7

Parameters

DOMDocument $objDoc:

int $pos:

Return value

DOMNode|null

File

includes/XMLSecurityKey.php, line 885

Class

XMLSecurityDSig

Code

public function locateSignature($objDoc, $pos = 0) {
  if ($objDoc instanceof DOMDocument) {
    $doc = $objDoc;
  }
  else {
    $doc = $objDoc->ownerDocument;
  }
  if ($doc) {
    $xpath = new DOMXPath($doc);
    $xpath
      ->registerNamespace('secdsig', self::XMLDSIGNS);
    $query = ".//secdsig:Signature";
    $nodeset = $xpath
      ->query($query, $objDoc);
    $this->sigNode = $nodeset
      ->item($pos);
    $query = "./secdsig:SignedInfo";
    $nodeset = $xpath
      ->query($query, $this->sigNode);
    if ($nodeset->length > 1) {
      throw new Exception("Invalid structure - Too many SignedInfo elements found");
    }
    return $this->sigNode;
  }
  return null;
}