當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLSecurityKey::decryptData方法代碼示例

本文整理匯總了PHP中XMLSecurityKey::decryptData方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLSecurityKey::decryptData方法的具體用法?PHP XMLSecurityKey::decryptData怎麽用?PHP XMLSecurityKey::decryptData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLSecurityKey的用法示例。


在下文中一共展示了XMLSecurityKey::decryptData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: decryptNode

 /**
  * Decrypt this encrypted node.
  *
  * The behaviour of this function depends on the value of $replace.
  * If $replace is false, we will return the decrypted data as a string.
  * If $replace is true, we will insert the decrypted element(s) into the
  * document, and return the decrypted element(s).
  *
  * @param XMLSecurityKey $objKey  The decryption key that should be used when decrypting the node.
  * @param boolean        $replace Whether we should replace the encrypted node in the XML document with the decrypted data. The default is true.
  *
  * @return string|DOMElement  The decrypted data.
  */
 public function decryptNode($objKey, $replace = true)
 {
     if (!$objKey instanceof XMLSecurityKey) {
         throw new Exception('Invalid Key');
     }
     $encryptedData = $this->getCipherValue();
     if ($encryptedData) {
         $decrypted = $objKey->decryptData($encryptedData);
         if ($replace) {
             switch ($this->type) {
                 case self::Element:
                     $newdoc = new DOMDocument();
                     $newdoc->loadXML($decrypted);
                     if ($this->rawNode->nodeType == XML_DOCUMENT_NODE) {
                         return $newdoc;
                     }
                     $importEnc = $this->rawNode->ownerDocument->importNode($newdoc->documentElement, true);
                     $this->rawNode->parentNode->replaceChild($importEnc, $this->rawNode);
                     return $importEnc;
                 case self::Content:
                     if ($this->rawNode->nodeType == XML_DOCUMENT_NODE) {
                         $doc = $this->rawNode;
                     } else {
                         $doc = $this->rawNode->ownerDocument;
                     }
                     $newFrag = $doc->createDocumentFragment();
                     $newFrag->appendXML($decrypted);
                     $parent = $this->rawNode->parentNode;
                     $parent->replaceChild($newFrag, $this->rawNode);
                     return $parent;
                 default:
                     return $decrypted;
             }
         } else {
             return $decrypted;
         }
     } else {
         throw new Exception("Cannot locate encrypted data");
     }
 }
開發者ID:RKathees,項目名稱:is-connectors,代碼行數:53,代碼來源:XMLSecEnc.php


注:本文中的XMLSecurityKey::decryptData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。