Exemplo n.º 1
0
 public function EncryptBody($siteKey, $objKey, $token)
 {
     $enc = new XMLSecEnc();
     foreach ($this->envelope->childNodes as $node) {
         if ($node->namespaceURI == $this->soapNS && $node->localName == 'Body') {
             break;
         }
     }
     $enc->setNode($node);
     /* encrypt the symmetric key */
     $enc->encryptKey($siteKey, $objKey, false);
     $enc->type = XMLSecEnc::Content;
     /* Using the symmetric key to actually encrypt the data */
     $encNode = $enc->encryptNode($objKey);
     $guid = XMLSecurityDSig::generateGUID();
     $encNode->setAttribute('Id', $guid);
     $refNode = $encNode->firstChild;
     while ($refNode && $refNode->nodeType != XML_ELEMENT_NODE) {
         $refNode = $refNode->nextSibling;
     }
     if ($refNode) {
         $refNode = $refNode->nextSibling;
     }
     if ($this->addEncryptedKey($encNode, $enc, $token)) {
         $this->AddReference($enc->encKey, $guid);
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $name
  * @param DOMNode $node
  * @param string $type
  * @throws Exception
  */
 public function addReference($name, $node, $type)
 {
     if (!$node instanceof DOMNode) {
         throw new Exception('$node is not of type DOMNode');
     }
     $curencdoc = $this->encdoc;
     $this->_resetTemplate();
     $encdoc = $this->encdoc;
     $this->encdoc = $curencdoc;
     $refuri = XMLSecurityDSig::generateGUID();
     $element = $encdoc->documentElement;
     $element->setAttribute("Id", $refuri);
     $this->references[$name] = array("node" => $node, "type" => $type, "encnode" => $encdoc, "refuri" => $refuri);
 }
Exemplo n.º 3
0
 public function addMessageID($id = null)
 {
     /* Add the WSA MessageID or return existing ID */
     if (!is_null($this->messageID)) {
         return $this->messageID;
     }
     if (empty($id)) {
         $id = XMLSecurityDSig::generateGUID('uuid:');
     }
     $header = $this->locateHeader();
     $nodeID = $this->soapDoc->createElementNS(self::WSANS, self::WSAPFX . ':MessageID', $id);
     $header->appendChild($nodeID);
     $this->messageID = $id;
 }