当前位置: 首页>>代码示例>>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;未经允许,请勿转载。