WS-Trust和WS-SecureConversation

WS-Security基于已建立的用于加密以及XML加密和签名的行业标准,为Web服务应用程序提供了一套全面的安全功能。 对于许多应用程序来说,WS-Security的功能是必不可少的,但是它们可能会付出巨大的性能成本。 本系列之前的文章探讨了常见的WS-Security配置如何影响主要的开放源Java™Web服务堆栈(Apache Axis2,Metro和Apache CXF)的性能。

WS-Security性能成本的主要部分来自非对称加密的广泛使用。 如“ Axis2 WS-Security签名和加密 ”中所述,非对称加密是一种有用的工具,因为它可与密钥对配合使用。 该对中的每个密钥都可以用于加密另一个密钥可以解密的消息。 密钥对的所有者可以使一个密钥公开可用,以便任何人都可以使用它对发送给所有者的消息进行安全加密,还可以解密来自所有者的消息(从而验证发送者的身份)。 非对称加密的缺点是,与基于仅涉及交易的各方所知的单个秘密密钥的简单对称加密相比,它需要更大的密钥大小和更多的处理开销。

WS-SecureConversation是一个标准,该标准允许将对称加密用于客户端和服务器之间正在进行的消息交换,从而消除了不对称加密增加的开销。 为了支持安全交换使用对称加密所需的秘密密钥信息,WS-SecureConversation建立在WS-Security和另一个标准WS-Trust上。 WS-Trust本身以WS-Security为基础,为发布和使用安全性令牌的Web服务定义了一个接口。

WS-信任

WS-Trust结合了两个相关功能。 第一个功能是支持使用安全令牌-特别是安全令牌的发行,更新和取消。 第二个功能是支持代理信任关系。 这两个功能可能看起来有所不同,但是它们相互关联,因为必须信任安全令牌,并且必须以某种形式的令牌表示信任。

WS-Trust的核心是一组用于发布,续订,取消和验证安全性令牌的消息。 客户端可以通过调用称为安全令牌服务(STS)的特定类型的SOAP Web服务来交换这些消息。 它们也可以通过其他方式传递(例如,在对另一个服务的请求的安全标头中)。

STS基础

STS是一种Web服务,可实现由WS-Trust规范定义的简单接口。 该接口允许客户端使用安全性令牌来提交针对几种类型的操作的请求。 因为STS是Web服务,所以可以在请求和响应消息中直接使用WS-Security,并且可以使用WS-SecurityPolicy指定客户端提供的凭据类型或消息上所需的任何其他安全处理。

最基本的操作是发行新令牌的操作。 清单1显示了为此目的对STS的请求的编辑示例,其中删除了各种标头,仅列出了请求正文。 (稍后您将看到一个包含标头的示例。)清单1中的请求是针对一种称为安全上下文令牌(SCT)的特定令牌的,该令牌由WS-SecureConversation使用:

清单1.从STS请求安全令牌
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    ...
  </soap:Header>
  <soap:Body xmlns:wsu=".../oasis-200401-wss-wssecurity-utility-1.0.xsd"
      wsu:Id="Id-7059772">
    <wst:RequestSecurityToken
        xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
      <wst:RequestType>http://.../ws-sx/ws-trust/200512/Issue</wst:RequestType>
      <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
          <wsa:Address>http://localhost:8800/cxf-seismicsc-signencr/</wsa:Address>
        </wsa:EndpointReference>
      </wsp:AppliesTo>
      <wst:Lifetime xmlns:wsu=".../oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <wsu:Created>2010-05-12T10:33:22.774Z</wsu:Created>
        <wsu:Expires>2010-05-12T10:38:22.774Z</wsu:Expires>
      </wst:Lifetime>
      <wst:TokenType
      >http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/sct</wst:TokenType>
      <wst:KeySize>128</wst:KeySize>
      <wst:Entropy>
        <wst:BinarySecret Type="http://docs.oasis-open.org/ws-sx/ws-trust/200512/Nonce"
        >kIYFB/u430k3PlOPfUtJ5A==</wst:BinarySecret>
      </wst:Entropy>
      <wst:ComputedKeyAlgorithm
      >http://.../ws-sx/ws-trust/200512/CK/PSHA1</wst:ComputedKeyAlgorithm>
    </wst:RequestSecurityToken>
  </soap:Body>
</soap:Envelope>

清单1请求主体显示了用于大多数对STS的请求的基本<wst:RequestSecurityToken>元素。 必需的<wst:RequestType>子元素标识此请求的特定类型,在本例中为Issue请求。 其余子元素是Issue请求的可选参数,标识:

  • 使用请求的令牌( <wsp:AppliesTo>元素)访问的服务端点
  • 令牌有效的时间跨度( <wst:Lifetime>元素)
  • 令牌的类型( <wst:TokenType>元素)
  • 请求的密钥大小(以位为单位)( <wst:KeySize>元素)
  • 客户端提供的熵数据,用于生成密钥( <wst:Entropy>元素)
  • 生成密钥的算法( <wst:ComputedKeyAlgorithm>元素)

如果接收到该请求的STS批准了任何必需的客户端提供的凭据,并同意该请求的条款,则它将在对Issue请求的响应中返回安全令牌。 清单2显示了一个成功Issue请求的示例,再次删除了标题:

清单2.来自STS的带有安全令牌的响应
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    ...
  </soap:Header>
  <soap:Body xmlns:wsu=".../oasis-200401-wss-wssecurity-utility-1.0.xsd"
      wsu:Id="Id-4824957">
    <wst:RequestSecurityTokenResponseCollection
        xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
      <wst:RequestSecurityTokenResponse>
        <wst:RequestedSecurityToken>
          <wsc:SecurityContextToken
              xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
              xmlns:wsu=".../oasis-200401-wss-wssecurity-utility-1.0.xsd"
              wsu:Id="sctId-A167EB2B526E0894DA12736604029099">
            <wsc:Identifier>A167EB2B526E0894DA12736604029098</wsc:Identifier>
          </wsc:SecurityContextToken>
        </wst:RequestedSecurityToken>
        <wst:RequestedAttachedReference>
          <wsse:SecurityTokenReference
            xmlns:wsse=".../oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsse:Reference xmlns:wsse=".../oasis-200401-wss-wssecurity-secext-1.0.xsd"
                URI="#sctId-A167EB2B526E0894DA12736604029099"
                ValueType=".../ws-sx/ws-secureconversation/200512/sct"/>
          </wsse:SecurityTokenReference>
        </wst:RequestedAttachedReference>
        <wst:RequestedUnattachedReference>
          <wsse:SecurityTokenReference
            xmlns:wsse=".../oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsse:Reference xmlns:wsse=".../oasis-200401-wss-wssecurity-secext-1.0.xsd"
            URI="A167EB2B526E0894DA12736604029098"
            ValueType=".../ws-sx/ws-secureconversation/200512/sct"/>
          </wsse:SecurityTokenReference>
        </wst:RequestedUnattachedReference>
        <wst:Lifetime xmlns:wsu=".../oasis-200401-wss-wssecurity-utility-1.0.xsd">
          <wsu:Created>2010-05-12T10:33:22.909Z</wsu:Created>
          <wsu:Expires>2010-05-12T10:38:22.909Z</wsu:Expires>
        </wst:Lifetime>
        <wst:RequestedProofToken>
          <wst:ComputedKey
          >http://docs.oasis-open.org/ws-sx/ws-trust/200512/CK/PSHA1</wst:ComputedKey>
        </wst:RequestedProofToken>
        <wst:Entropy>
          <wst:BinarySecret Type="http://docs.oasis-open.org/ws-sx/ws-trust/200512/Nonce"
          >DpkK6qcELTO8dlPdDHMi2A==</wst:BinarySecret>
        </wst:Entropy>
      </wst:RequestSecurityTokenResponse>
    </wst:RequestSecurityTokenResponseCollection>
  </soap:Body>
</soap:Envelope>

清单2响应示出了<wst:RequestSecurityTokenResponseCollection>元件缠绕的单个<wst:RequestSecurityTokenResponse>元素,这反过来又包裹响应令牌的信息。 因为请求是针对SCT的(如值所示)

<wst:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</wst:TokenType>

清单1请求消息中),响应提供:

  • 实际的SCT(包装在<wst:RequestedSecurityToken>元素中)
  • 一些参考结构( <wst:RequestedAttachedReference><wst:RequestedUnattachedReference>
  • 令牌有效的时间跨度( <wst:Lifetime>元素)
  • 证明令牌( <wst:RequestedProofToken>元素)
  • 服务器提供的熵数据,用于生成密钥( <wst:Entropy>元素)

证明令牌的内容定义了用作对称加密基础的共享机密值。 在这种情况下,该共享秘密值是使用定义的算法通过组合客户端和服务器提供的熵值而生成的。

其他选择

除了Issue请求类型之外,您还可以向STS发出ValidateRenewCancel请求。 这些请求都需要引用或提供以前发行的令牌。 它们允许客户端验证令牌,或请求延长或终止令牌的有效时间跨度。

当仅返回单个令牌时,来自STS的响应可以直接使用<wst:RequestSecurityTokenResponse>元素,而不是将其包装在<wst:RequestSecurityTokenCollection>元素中,如清单2所示。 对STS的请求可以使用<wst:RequestSecurityTokenCollection>元素,该元素包装任意数量的<wst:RequestSecurityToken>元素。

WS-Trust还允许在SOAP消息头中直接传输安全性令牌,而不是通过STS Web服务接口。 当从与服务不在同一位置的STS获得令牌时,这是共享令牌的唯一方法。

WS-SecureConversation

WS-SecureConversation建立在WS-Trust上,使用STS来管理SCT。 SCT表示在消息交换所涉及的各方之间共享的上下文,并且在此共享上下文中的信息允许各方使用对称加密来保护消息。

具体来说,上下文为消息交换所涉及的各方提供了共享的秘密值(如清单2响应消息所示)。 共享密钥本身可以是用于在交换中对消息进行对称加密的密钥,但是首选方法是使用共享密钥作为基础值,以派生在交换中使用的实际密钥。 这听起来像是不必要的复杂性,但目的是使监视消息交换的任何人都难以破解密钥。

STS和服务

WS-SecureConversation理论上可以用于多方消息交换,但是最常见的用法是客户端与单个服务器进行通信。 在此配置中使用时,向客户端提供SCT的STS与服务器位于同一位置,并在同一端点地址处进行访问。 这意味着服务器上的Web服务代码需要一种方法来区分针对STS的消息和针对服务本身的消息。 在请求上使用的操作可达到该目的。

图1说明了位于同一地点的STS配置和消息交换:

图1.与服务并置的WS-SecureConversation STS
WS-SecureConversation STS与服务并置

当客户端要开始与服务器交换消息时,客户端首先联系STS并建立上下文。 该消息(如图1中的消息1 所示 )指定了动作http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT 。 响应(消息2)将SCT提供给客户端。 然后在消息3中引用此上下文,该消息指定与实际服务应用程序关联的任何操作。 在此时间段内,SCT在从客户端到服务的任何连续消息中均有效。 消息3和4使用基于共享密钥的对称加密,客户端和服务之间的所有后续消息也是如此。 服务应用程序使用客户端提供的上下文引用直接从STS所保存的上下文访问共享密钥。

WS-Policy配置

WS-SecureConversation使用的WS-Policy和WS-SecurityPolicy配置与本系列先前文章中介绍的基本WS-Security处理所使用的配置相似。 一个很大的不同是,当使用WS-SecureConversation时,该策略必须涵盖两个单独的交换-客户端与STS之间的交换,以及客户端与实际服务之间的交换。 在策略描述中,这是通过使用嵌套策略与STS进行交换来处理的,而策略的主体适用于客户端与服务之间的交换。

清单3显示了用于本文示例的策略:

清单3.示例WS-SecureConversation策略
<wsp:Policy wsu:Id="SecConv"
    xmlns:wsu=".../oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
    xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
  <wsp:ExactlyOne>
    <wsp:All>
      <wsap:UsingAddressing xmlns:wsap="http://www.w3.org/2006/05/addressing/wsdl"/>
      <sp:SymmetricBinding>
        <wsp:Policy>
          <sp:ProtectionToken>
            <wsp:Policy>
              <sp:SecureConversationToken sp:IncludeToken=".../AlwaysToRecipient">
                <wsp:Policy>
                  <sp:RequireDerivedKeys/>
                  <sp:BootstrapPolicy>
                    <wsp:Policy>
                      <sp:AsymmetricBinding>
                        <wsp:Policy>
                          <sp:InitiatorToken>
                            <wsp:Policy>
                              <sp:X509Token sp:IncludeToken=".../AlwaysToRecipient">
                                <wsp:Policy>
                                  <sp:RequireThumbprintReference/>
                                </wsp:Policy>
                              </sp:X509Token>
                            </wsp:Policy>
                          </sp:InitiatorToken>
                          <sp:RecipientToken>
                            <wsp:Policy>
                              <sp:X509Token sp:IncludeToken=".../IncludeToken/Never">
                                <wsp:Policy>
                                  <sp:RequireThumbprintReference/>
                                </wsp:Policy>
                              </sp:X509Token>
                            </wsp:Policy>
                          </sp:RecipientToken>
                          <sp:AlgorithmSuite>
                            <wsp:Policy>
                              <sp:TripleDesRsa15/>
                            </wsp:Policy>
                          </sp:AlgorithmSuite>
                          <sp:IncludeTimestamp/>
                          <sp:OnlySignEntireHeadersAndBody/>
                        </wsp:Policy>
                      </sp:AsymmetricBinding>
                      <sp:SignedParts>
                        <sp:Body/>
                        <sp:Header Name="To" Namespace=".../addressing"/>
                        <sp:Header Name="From" Namespace=".../addressing"/>
                        <sp:Header Name="FaultTo" Namespace=".../addressing"/>
                        <sp:Header Name="ReplyTo" Namespace=".../addressing"/>
                        <sp:Header Name="MessageID" Namespace=".../addressing"/>
                        <sp:Header Name="RelatesTo" Namespace=".../addressing"/>
                        <sp:Header Name="Action" Namespace=".../addressing"/>
                      </sp:SignedParts>
                      <sp:Trust13>
                        <wsp:Policy>
                          <sp:MustSupportIssuedTokens/>
                          <sp:RequireClientEntropy/>
                          <sp:RequireServerEntropy/>
                        </wsp:Policy>
                      </sp:Trust13>
                    </wsp:Policy>
                  </sp:BootstrapPolicy>
                </wsp:Policy>
              </sp:SecureConversationToken>
            </wsp:Policy>
          </sp:ProtectionToken>
          <sp:AlgorithmSuite>
            <wsp:Policy>
              <sp:Basic128Rsa15/>
            </wsp:Policy>
          </sp:AlgorithmSuite>
        </wsp:Policy>
      </sp:SymmetricBinding>
      <sp:EncryptedParts>
        <sp:Body/>
      </sp:EncryptedParts>
    </wsp:All>
  </wsp:ExactlyOne>
</wsp:Policy>

清单3中 ,外部策略指定使用对称加密( <sp:SymmetricBinding> )对正在交换的消息正文进行加密(位于列表底部附近的<sp:EncryptedParts>设置)。 在对称加密策略内部, <sp:ProtectionToken>和嵌套的<sp:SecureConversationToken>元素表示将使用WS-SecureConversation来执行对称加密。

访问STS时应用的策略由嵌套在<sp:SecureConversationToken><sp:BootstrapPolicy> (以粗体显示)定义。 此策略仅使用X.509证书指定消息正文和地址标头的签名,这与本系列先前的WS-Security文章中看到的签名类型相同。

请注意,使用此策略时,不会加密客户端和STS之间交换的消息。 这样可以很容易地看到发生了什么,但是对于实际使用,您想要通过使用TLS / SSL传输加密或WS-Security加密来保护交换。

信息交流

清单4显示了消息1和2的标头,分别是对STS的请求和对客户端的响应。 (您已经在清单1清单2中看到了这些消息的主体。)

清单4. STS请求和响应的标题
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>

    <Action xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-32320445"
      >http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/SCT</Action>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-2673180"
      >urn:uuid:24ce01d5-3c17-4df6-ad89-2fc0720152cd</MessageID>
    <To xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-5132526"
      >http://localhost:8800/cxf-seismicsc-signencr/</To>
    ...
    <wsse:Security xmlns:wsse="...wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
      <wsse:BinarySecurityToken xmlns:wsse="...wssecurity-secext-1.0.xsd"
        xmlns:wsu="...wssecurity-utility-1.0.xsd"
        EncodingType="...soap-message-security-1.0#Base64Binary"
        ValueType="...x509-token-profile-1.0#X509v3"
        wsu:Id="CertId-CF15C330C32618BF4912736604028486"
        >MIICo...8/0n33w==</wsse:BinarySecurityToken>
      <wsu:Timestamp xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-7">
        <wsu:Created>2010-05-12T10:33:22.831Z</wsu:Created>
        <wsu:Expires>2010-05-12T10:38:22.831Z</wsu:Expires>
      </wsu:Timestamp>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-8">
        <ds:SignedInfo>
          ...
          <ds:Reference URI="#Id-7059772">
            ...
          </ds:Reference>
          ...
          <ds:Reference URI="#Timestamp-7">
            ...
          </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>TYIbt...V0dd8=</ds:SignatureValue>
        <ds:KeyInfo Id="KeyId-CF15C330C32618BF4912736604028487">
          <wsse:SecurityTokenReference xmlns:wsse="...wssecurity-secext-1.0.xsd"
            xmlns:wsu="...wssecurity-utility-1.0.xsd"
            wsu:Id="STRId-CF15C330C32618BF4912736604028488">
            <wsse:Reference xmlns:wsse="...wssecurity-secext-1.0.xsd"
            URI="#CertId-CF15C330C32618BF4912736604028486"
            ValueType="...x509-token-profile-1.0#X509v3"/>
          </wsse:SecurityTokenReference>
        </ds:KeyInfo>
      </ds:Signature>
    </wsse:Security>
  </soap:Header>
  <soap:Body xmlns:wsu="..." wsu:Id="Id-7059772">
    ...
  </soap:Body>
</soap:Envelope>

soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <Action xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-33522601"
      >http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/SCT</Action>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-9229531"
      >urn:uuid:d9d1b9b2-a864-446b-ab81-3176f868046e</MessageID>
    <To xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-25551189"
      >http://www.w3.org/2005/08/addressing/anonymous</To>
    <RelatesTo xmlns="http://www.w3.org/2005/08/addressing"
      xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-32148925"
      >urn:uuid:24ce01d5-3c17-4df6-ad89-2fc0720152cd</RelatesTo>
    <wsse:Security xmlns:wsse="...wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
      <wsu:Timestamp xmlns:wsu=
        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssecurity-utility-1.0.xsd" 
        wsu:Id="Timestamp-7">
        <wsu:Created>2010-05-12T10:33:22.913Z</wsu:Created>
        <wsu:Expires>2010-05-12T10:38:22.913Z</wsu:Expires>
      </wsu:Timestamp>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-8">
        <ds:SignedInfo>
          ...
          <ds:Reference URI="#Id-4824957">
            ...
          </ds:Reference>
          ...
          <ds:Reference URI="#Timestamp-7">
            ...
          </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>tr1tx...GY4wk=</ds:SignatureValue>
        <ds:KeyInfo Id="KeyId-A167EB2B526E0894DA127366040291811">
          <wsse:SecurityTokenReference xmlns:wsse="...wssecurity-secext-1.0.xsd"
            xmlns:wsu="...wssecurity-utility-1.0.xsd"
            wsu:Id="STRId-A167EB2B526E0894DA127366040291812">
            <wsse:KeyIdentifier EncodingType="...soap-message-security-1.0#Base64Binary"
            ValueType="...soap-message-security-1.1#ThumbprintSHA1"
            >uYn3PK2wXheN2lLZr4n2mJjoWE0=</wsse:KeyIdentifier>
          </wsse:SecurityTokenReference>
        </ds:KeyInfo>
      </ds:Signature>
    </wsse:Security>
  </soap:Header>
  <soap:Body xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-4824957">
    ...
  </soap:Body>
</soap:Envelope>

清单4中 ,您可以看到证书从客户端发送到服务器,并且证书引用返回到客户端,每个方向的证书都用于验证时间戳和消息正文的签名。 使用此策略配置,客户端证书需要由STS信任,并且STS证书必须存在于客户端的信任库中。

清单5显示了使用WS-SecureConversation在客户端和服务之间进行的(大量编辑的)消息交换:

清单5.对服务的请求和对客户端的响应
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <Action xmlns="http://www.w3.org/2005/08/addressing">urn:matchQuakes</Action>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing"
      >urn:uuid:c724a446-4375-4e8a-a318-fd3c84510eae</MessageID>
    ...
    <wsse:Security xmlns:wsse="...wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
      <wsc:SecurityContextToken xmlns:wsc=".../ws-secureconversation/200512"
        xmlns:wsu="...wssecurity-utility-1.0.xsd"
        wsu:Id="sctId-A167EB2B526E0894DA12736604029099">
        <wsc:Identifier>A167EB2B526E0894DA12736604029098</wsc:Identifier>
      </wsc:SecurityContextToken>
      <wsc:DerivedKeyToken xmlns:wsc=".../ws-secureconversation/200512"
        xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="derivedKeyId-9">
        <wsse:SecurityTokenReference xmlns:wsse="...wssecurity-secext-1.0.xsd">
          <wsse:Reference xmlns:wsse="..." URI="#sctId-A167EB2B526E0894DA12736604029099"
          ValueType="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512/sct"/>
        </wsse:SecurityTokenReference>
        <wsc:Offset>0</wsc:Offset>
        <wsc:Length>16</wsc:Length>
        <wsc:Nonce>AyUGKYBNNQstD9EmZUJqlA==</wsc:Nonce>
      </wsc:DerivedKeyToken>
      <wsc:DerivedKeyToken xmlns:wsc=".../ws-secureconversation/200512"
        xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="derivedKeyId-11">
        ...
      </wsc:DerivedKeyToken>
      <xenc:ReferenceList xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        <xenc:DataReference URI="#EncDataId-12"/>
      </xenc:ReferenceList>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-10">
        <ds:SignedInfo>
          ...
          <ds:Reference URI="#Id-28812627">
            ...
          </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>6NHo8Si1ntZIb2Ivg3S/n1+2uzI=</ds:SignatureValue>
        <ds:KeyInfo Id="KeyId-CF15C330C32618BF4912736604029689">
          <wsse:SecurityTokenReference xmlns:wsse="..." xmlns:wsu="..."
          wsu:Id="STRId-CF15C330C32618BF49127366040296810">
            <wsse:Reference xmlns:wsse="..." URI="#derivedKeyId-9"/>
          </wsse:SecurityTokenReference>
        </ds:KeyInfo>
      </ds:Signature>
    </wsse:Security>
  </soap:Header>
  <soap:Body xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-28812627">
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" ...>
      <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <wsse:SecurityTokenReference xmlns:wsse="...wssecurity-secext-1.0.xsd">
          <wsse:Reference xmlns:wsse="..." URI="#derivedKeyId-11"/>
        </wsse:SecurityTokenReference>
      </ds:KeyInfo>
      <xenc:CipherData>
        <xenc:CipherValue>+krS8lGA...CKSN0fwKR36Q==</xenc:CipherValue>
      </xenc:CipherData>
    </xenc:EncryptedData>
  </soap:Body>
</soap:Envelope>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <Action xmlns="http://www.w3.org/2005/08/addressing"
      >http://ws.sosnoski.com/seismic/wsdl/SeismicInterface/quakeResponse</Action>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing"
      >urn:uuid:c3aa0671-8751-4d6b-8d4c-0e37ce3e394a</MessageID>
    <To xmlns="http://www.w3.org/2005/08/addressing"
      >http://www.w3.org/2005/08/addressing/anonymous</To>
    <RelatesTo xmlns="http://www.w3.org/2005/08/addressing"
      >urn:uuid:c724a446-4375-4e8a-a318-fd3c84510eae</RelatesTo>
    <wsse:Security xmlns:wsse="...wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
      <wsc:DerivedKeyToken xmlns:wsc="...ws-secureconversation/200512"
      ...
      </wsc:DerivedKeyToken>
      <wsc:DerivedKeyToken xmlns:wsc="...ws-secureconversation/200512"
      ...
      </wsc:DerivedKeyToken>
      <xenc:ReferenceList xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        <xenc:DataReference URI="#EncDataId-12"/>
      </xenc:ReferenceList>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-10">
        <ds:SignedInfo>
          ...
          <ds:Reference URI="#Id-10766816">
            ...
          </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>rU6YoV7BiO0qSQjWw2vwCp9R+fg=</ds:SignatureValue>
        <ds:KeyInfo Id="KeyId-A167EB2B526E0894DA127366040304813">
          <wsse:SecurityTokenReference xmlns:wsse="...wssecurity-secext-1.0.xsd" ...>
            <wsse:Reference xmlns:wsse="..." URI="#derivedKeyId-9"/>
          </wsse:SecurityTokenReference>
        </ds:KeyInfo>
      </ds:Signature>
    </wsse:Security>
  </soap:Header>
  <soap:Body xmlns:wsu="...wssecurity-utility-1.0.xsd" wsu:Id="Id-10766816">
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" ...>
      <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <wsse:SecurityTokenReference xmlns:wsse="...wssecurity-secext-1.0.xsd">
          <wsse:Reference xmlns:wsse="..." URI="#derivedKeyId-11"/>
        </wsse:SecurityTokenReference>
      </ds:KeyInfo>
      <xenc:CipherData>
        <xenc:CipherValue>Cl0iUu...TJ6WkZl2A==</xenc:CipherValue>
      </xenc:CipherData>
    </xenc:EncryptedData>
  </soap:Body>
</soap:Envelope>

清单5中 ,每个消息的头中都包含SecurityContextToken 。 它由<wsc:DerivedKeyToken>元素引用,该元素提供用于导出实际用于对数据进行签名和加密的秘密密钥的参数。

有什么帮助?

既然您已经了解了WS-Trust和WS-SecureConversation的基础知识,那么该系列的下一篇文章将探讨WS-SecureConversation在Apache Axis2,Metro和Apache CXF Web服务堆栈上提供的性能提升。 在获得性能结果的过程中,您还将看到在三个堆栈上配置WS-SecureConversation的详细信息。


翻译自: https://www.ibm.com/developerworks/security/library/j-jws15/index.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值