Esempio n. 1
0
 function __doRequest($request, $location, $action, $version, $one_way = 0)
 {
     if (!$this->xmlDSigAdapter) {
         return parent::__doRequest($request, $location, $action, $version, $one_way);
     }
     // Some WS providers use NS1 for his own use and conflicts with the signature calc
     $request = str_replace(array(':ns1', 'ns1:'), array(':wns1', 'wns1:'), $request);
     $dom = new DOMDocument();
     $dom->loadXML($request);
     $body = $dom->getElementsByTagNameNS($dom->documentElement->namespaceURI, 'Body')->item(0);
     $firstElement = $body->firstChild;
     /* Not necessary since ext/Soap don't add Text nodes between Elements
        foreach($body->childNodes as $node){
            if ($node->nodeType === XML_ELEMENT_NODE) {
                $firstElement = $node;
                break;
            }
        }
        */
     $newData = new DOMDocument();
     $newData->loadXML($firstElement->C14N());
     $this->xmlDSigAdapter->sign($newData);
     /* DOM mode for add the signed node
        $firstElement->appendChild($dom->importNode($newData->firstChild->lastChild, true));
        $request = $dom->saveXML();
        */
     /* Compatibility mode for add signed node without lost namespaces declaration */
     $newBody = '<SOAP-ENV:Body>' . $newData->C14N() . '</SOAP-ENV:Body>';
     $request = preg_replace('#<SOAP-ENV:Body>.*</SOAP-ENV:Body>#', $newBody, $request);
     if ($this->debugMode) {
         $this->lastRequest = $request;
     }
     return parent::__doRequest($request, $location, $action, $version, $one_way);
 }
Esempio n. 2
0
 public function testManipulatedSignature()
 {
     $data = new DOMDocument();
     $data->load(__DIR__ . '/_files/basic-doc-signed.xml');
     $xpath = new DOMXPath($data);
     $xpath->registerNamespace('s', 'urn:envelope');
     $xpath->query('//s:Value')->item(0)->nodeValue = 'wrong test';
     $this->assertFalse($this->adapter->verify($data));
 }