コード例 #1
0
ファイル: WSSESoap.php プロジェクト: bostalowski/exacttarget
 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($enc, $token)) {
         $this->addReference($enc->encKey, $guid);
     }
 }
コード例 #2
0
 public function add509Cert($cert, $isPEMFormat = true)
 {
     $data = XMLSecurityDSig::get509XCert($cert, $isPEMFormat);
     if ($xpath = $this->getXPathObj()) {
         $query = "./secdsig:KeyInfo";
         $nodeset = $xpath->query($query, $this->sigNode);
         $keyInfo = $nodeset->item(0);
         if (!$keyInfo) {
             $inserted = false;
             $keyInfo = $this->createNewSignNode('KeyInfo');
             if ($xpath = $this->getXPathObj()) {
                 $query = "./secdsig:Object";
                 $nodeset = $xpath->query($query, $this->sigNode);
                 if ($sObject = $nodeset->item(0)) {
                     $sObject->parentNode->insertBefore($keyInfo, $sObject);
                     $inserted = true;
                 }
             }
             if (!$inserted) {
                 $this->sigNode->appendChild($keyInfo);
             }
         }
         $x509DataNode = $this->createNewSignNode('X509Data');
         $keyInfo->appendChild($x509DataNode);
         $x509CertNode = $this->createNewSignNode('X509Certificate', $data);
         $x509DataNode->appendChild($x509CertNode);
     }
 }