File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 4343
4444class XMLSecurityDSig extends \RobRichards \XMLSecLibs \XMLSecurityDSig
4545{
46+ /**
47+ * @return bool
48+ * @throws Exception
49+ */
50+ public function validateReference ()
51+ {
52+ $ sigNode = $ this ->sigNode ;
53+ $ docElem = $ sigNode ->ownerDocument ->documentElement ;
54+
55+ // enveloped signature, remove it
56+ if (!$ docElem ->isSameNode ($ sigNode )) {
57+ if ($ sigNode ->parentNode !== null ) {
58+ $ sigNode ->parentNode ->removeChild ($ sigNode );
59+ }
60+ }
61+ $ xpath = $ this ->getXPathObj ();
62+ $ query = "./secdsig:SignedInfo[1]/secdsig:Reference " ;
63+ $ nodeset = $ xpath ->query ($ query , $ sigNode );
64+ if ($ nodeset ->length < 1 ) {
65+ throw new Exception ("Reference nodes not found " );
66+ }
67+
68+ /* Initialize/reset the list of validated nodes. */
69+ $ this ->validatedNodes = [];
70+
71+ foreach ($ nodeset as $ refNode ) {
72+ if (!$ this ->processRefNode ($ refNode )) {
73+ /* Clear the list of validated nodes. */
74+ $ this ->validatedNodes = null ;
75+ throw new Exception ("Reference validation failed " );
76+ }
77+ }
78+ return true ;
79+ }
4680}
You can’t perform that action at this time.
0 commit comments