<%-- JSP全站自动生成HTML下载新闻系统 V3.1 作者:JSP天空网站长 曹进 QQ:173241393 --%> 使用XML-Encryption实现安全SOAP消息
 
用户名:
密码:
终身会员
  首页 网络文摘 技术专题 下载中心 JSP培训 公司产品 JSP虚拟主机 技术论坛 会员 JSP免费空间  
  技术文摘: JSP基础 | JSP高级 | JSP环境 | JAVA基础 | JAVA高级 | JAVA工具 | JAVA数据库 | WEB框架 | XML相关 | JAVA考试 | J2EE相关 | J2ME相关 |
  视频下载: 程序设计数据库相关教程计算机基础教程图形图像网络技术网络安全时空书库EasyShop虚拟主机JSP培训技术论坛
  书籍教程: JSP教程Java教程图像软件XML教程数据库教程网页教程工具软件服务器相关ASP教程PHP教程CGI教程.NET教程
  代码下载: ASP代码下载JSP代码下载PHP代码下载CGI代码下载Flash代码C/C++/VCPowerBuilderDelphiVisualBasicVisualFoxpro
您的位置: 首页 -> 文章分类 -> WEB框架 -> 使用XML-Encryption实现安全SOAP消息
 文摘搜索
 
 文摘资源分类
 
 文摘总排行榜TOP10
 
 最新更新文摘TOP10
 

使用XML-Encryption实现安全SOAP消息

[来源]管理员   [作者]网络文摘   [时间]2006-02-16
推荐等级: 点击:

自1977年以来,使用最为广泛的加密算法是数据加密标准(Data Encryption Standard,DES)。但是事实表明,由于近几年计算能力的极大提高,DES可以在一天之内被攻破。所以2001年,联邦政府引入了一个新的标准:高级加密标准(Advanced Encryption Standard,AES)。DES和AES使用的都是对称密钥加密算法。顾名思义,其加密和解密是使用同一个密码块进行的。在一个客户-服务器环境中,如何创建、分发用于加密和解密消息的密钥并对其达成协议是首要的问题。

  XML-Encryption指定EncryptedKey机制,使用RSA――一种公钥加密体制――来加密密钥。我们需要记住,在非对称加密中,我们使用公钥来加密,而使用私钥来解密。所以,密钥由消息发送方创建,并使用接收方的公钥进行加密。然后用于加密的密钥会包含在消息中。接收方根据KeyInfo元素得出解密密钥(私钥)。

  让我们来详细看一下由WebLogic Server 9.0所生成的示例消息:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <wsse:Security
      xmlns:wsse="…/oasis-200401-wss-wssecurity-secext-1.0.xsd"
      soapenv:mustUnderstand="1">
       <ns1:EncryptedKey Id="encrypt"
           xmlns:ns1="http://www.w3.org/2001/04/xmlenc#">
       <ns1:EncryptionMethod Algorithm="…#rsa-1_5"/>
       <ns2:KeyInfo xmlns:ns2="…/xmldsig#">
         <wsse:SecurityTokenReference wsu:Id="Dk8Xm"
             xmlns:wsu="…/oasis-200401-wss-wssecurity-utility-1.0.xsd"
             xmlns:wsse="…/oasis-200401-wss-wssecurity-secext1.0.xsd">
             <ns2:X509Data>
                <ns2:X509IssuerSerial>
                   <ns2:X509IssuerName>CN=CertGenCAB…C=US</ns2:X509IssuerName>
                   <ns2:X509SerialNumber>-</ns2:X509SerialNumber>
                </ns2:X509IssuerSerial>
             </ns2:X509Data>
          </wsse:SecurityTokenReference>
       </ns2:KeyInfo>
       <ns1:CipherData>
            <ns1:CipherValue>aSMjPEHitl/2doflGwDQ==</ns1:CipherValue>
       </ns1:CipherData>
       <ns1:ReferenceList>
           <ns1:DataReference URI="#Dk8Zw31"/>
       </ns1:ReferenceList>
     </ns1:EncryptedKey>
    </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <ns1:EncryptedData Id=" Dk8Zw31" Type="…#Content"
         MimeType="text/xml" Encoding="UTF-8" xmlns:ns1="…/xmlenc#">
         <ns1:EncryptionMethod Algorithm="…#tripledescbc"/>
         <ns1:CipherData>
            <ns1:CipherValue>2HIkjvUdSL9qpqhP</ns1:CipherValue>
         </ns1:CipherData>
       </ns1:EncryptedData>
   </soapenv:Body>
</soapenv:Envelope>

  SecurityTokenReference元素指定接收方的X509证书的X509IssuerSerial。接收方应该能够从密钥库查找相应的私钥来执行解密操作。除了X509IssuerSerial,X509证书的Subject Key Identifier (SKID)也可以用来描述用于加密的密钥。

<wsse:SecurityTokenReference>
  <wsse:KeyIdentifier
    ValueType="...#X509SubjectKeyIdentifier">
      Xeg55vRyK3ZhAEhEf+YT0z986L0=
  </wsse:KeyIdentifier>
</wsse:SecurityTokenReference>

  如果X509证书中包含SKID,WebLogic Server 9.0就总会在SecurityTokenReference中生成KeyIdentifier。而如果X509证书中没有SKID,那么就会在SecurityTokenReference中使用X509IssuerSerial。

  只要响应消息需要加密,客户端就会将它的公钥作为请求消息的一部分发送,以便服务器使用其中的密钥来加密响应消息。

<soapenv:Envelope
   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
     <wsse:Security
       xmlns:wsse=".../oasis-200401 wss-wssecurity-secext-1.0.xsd"
       soapenv:mustUnderstand="1">
       <wsse:BinarySecurityToken wsu:Id="encrypt-token"
          xmlns:wsu="…/oasis-200401-wss-wssecurity-utility-1.0.xsd"
          ValueType="…#X509v3"
          EncodingType="…#Base64Binary">BZEWX…
       </wsse:BinarySecurityToken>
     </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
       <m:encryptResponse xmlns:m="http://dev2dev.bea.com">
          <m:s>Only response message isencrypted!</m:s>
       </m:encryptResponse>
   </soapenv:Body>
</soapenv:Envelope>

[收藏][打印][关闭]
在线咨询服务 在线咨询服务 在线咨询服务 在线咨询服务
Copyright©2005-2006陕西思远数码科技有限责任公司 服务电话:029-88212987 传真:029-88278265 售后服务QQ:173241393
地址:陕西省西安市吉祥路186号太白新苑C座2104 陕ICP备05004508号