Skip to content

Commit b209756

Browse files
committed
Overload getXPathObj
1 parent f4b1e7c commit b209756

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/XMLSecurityDSig.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace SimpleSAML\XMLSecurity;
44

5+
use DOMXPath;
6+
use Exception;
7+
58
/**
69
* xmlseclibs.php
710
*
@@ -43,6 +46,10 @@
4346

4447
class XMLSecurityDSig extends \RobRichards\XMLSecLibs\XMLSecurityDSig
4548
{
49+
/** @var DomXPath|null */
50+
private $xPathCtx = null;
51+
52+
4653
/**
4754
* @return bool
4855
* @throws Exception
@@ -77,4 +84,29 @@ public function validateReference()
7784
}
7885
return true;
7986
}
87+
88+
89+
/**
90+
* Returns the XPathObj or null if xPathCtx is set and sigNode is empty.
91+
*
92+
* @return DOMXPath|null
93+
*/
94+
private function getXPathObj()
95+
{
96+
if (empty($this->xPathCtx) && ! empty($this->sigNode)) {
97+
$xpath = new DOMXPath($this->sigNode->ownerDocument);
98+
$xpath->registerNamespace('secdsig', self::XMLDSIGNS);
99+
$this->xPathCtx = $xpath;
100+
}
101+
return $this->xPathCtx;
102+
}
103+
104+
105+
/**
106+
* Reset the XPathObj to null
107+
*/
108+
private function resetXPathObj()
109+
{
110+
$this->xPathCtx = null;
111+
}
80112
}

0 commit comments

Comments
 (0)