<element name="Confidentiality"> <complexType> <sequence> <element name="KeyWrappingAlgorithm" type="secpol:AlgorithmType" minOccurs="0" maxOccurs="1"/> <element name="Target" type="secpol:ConfidentialityTargetType" minOccurs="1" maxOccurs="unbounded"/> <element name="KeyInfo" type="secpol:KeyInfoType"/> </sequence> </complexType> </element>
KeyWrappingAlgorithm指定包装对称密钥的算法。EncryptionAlgorithm指定用于对目标执行加密的算法。Target元素则提供了对消息中的特定块进行加密的细节。它对应于消息中的EncryptedData块。可以有一个或多个Target。KeyInfo指定用于加密的密钥。如果不定义SupportedTokens元素,Confidentiality断言就成为抽象。
我们进一步来看看断言定义是如何转换为SOAP消息布局的。下面是一个包含wsse:Security头部的SOAP消息片段:
<soapenv:Header> <wsse:Security> <xenc:EncryptedKey> <xenc:EncryptionMethod Algorithm="…#rsa1_5"/> <ds:KeyInfo> <wsse:SecurityTokenReference>...</wsse:SecurityTokenReference> </ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue>…</xenc:CipherValue> </xenc:CipherData> <xenc:ReferenceList> <xenc:DataReference URI="#id"/> </xenc:ReferenceList> </xenc:EncryptedKey> </wsse:Security> </soapenv:Header>
Security头部中的EncryptedKey元素包含了用于加密和解密的对称密钥。对称密钥本身由另一个密钥加密。KeyWrappingAlgorithm断言在EncryptedKey中定义了EncryptionMethod元素。在该示例中,对称密钥是通过RSA加密方法保护起来的。即,消息发送方使用接收方的公钥加密对称密钥,而接收方则使用自己的私钥解密对称密钥。对称密钥被解密之后,接收方使用该密钥来解密被加密的消息部分。被加密的消息部分定义在Target断言中,且最终将在EncryptedKey中的ReferenceList元素中进行转换。KeyInfo断言对应于EncryptedKey中的KeyInfo元素。接收方使用KeyInfo元素解密私钥,然后再用解密后的私钥来解密被加密的对称密钥(定义在EncryptedKey的CipherData元素中)。
原文出处:http://dev2dev.bea.com/blog/jlee/archive/2005/10/wls_wssecurityp_3.html