【问题标题】:How to guess order of items in rampart having WS-Security response?如何猜测壁垒中具有 WS-Security 响应的项目​​顺序?
【发布时间】:2011-05-23 12:09:02
【问题描述】:

我的axis2+rampart 客户端与一些WS-Secured 服务器一起工作。服务器升级后它停止工作(JBoss 升级,WSDL 中的一些更改,但测试功能中没有)。服务器所有者声称他们的 WS-Security 配置没有更改,但现在我的客户报告:

org.apache.axis2.AxisFault: Must Understand check failed for header http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd : Security

早些时候,当axis2.xml 中的“项目”顺序不好时,我得到了这个异常。 我所要做的就是将这些项目组合起来。它们看起来像:

<parameter name="InflowSecurity">
  <action>
    <items>Signature Encrypt Timestamp</items>
...

现在这个问题又出现了。我看到答复中没有“时间戳”。我从项目中删除了它,但没有任何改变。

回复如下:

<soap:Envelope xmlns:soap="..."
    xmlns:xenc="...">
    <soap:Header>
        <wsse:Security
            xmlns:wsse="..."
            soap:mustUnderstand="1">
            <xenc:EncryptedKey xmlns:xenc="..."
                Id="EncKeyId-B8B3555394366F3F0112919826983351032">
                <xenc:EncryptionMethod Algorithm="..." />
                <ds:KeyInfo xmlns:ds="...">
                    <wsse:SecurityTokenReference
                        xmlns:wsse="...">
                        <wsse:KeyIdentifier
                            ...
                        </wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
                <xenc:CipherData>
                    <xenc:CipherValue>
                        ...
                    </xenc:CipherValue>
                </xenc:CipherData>
                <xenc:ReferenceList>
                    <xenc:DataReference URI="#EncDataId-624" />
                </xenc:ReferenceList>
            </xenc:EncryptedKey>
            <ds:Signature xmlns:ds="..."
                Id="Signature-622">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod
                        Algorithm="..." />
                    <ds:SignatureMethod Algorithm="..." />
                    <ds:Reference URI="#id-623">
                        <ds:Transforms>
                            <ds:Transform Algorithm="..." />
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="..." />
                        <ds:DigestValue>
                            ...
                        </ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>
                    ...
                </ds:SignatureValue>
                <ds:KeyInfo Id="KeyId-B8B3555394366F3F0112919826983181029">
                    <wsse:SecurityTokenReference
                        xmlns:wsse="..."
                        xmlns:wsu="..."
                        wsu:Id="STRId-B8B3555394366F3F0112919826983181030">
                        <wsse:KeyIdentifier
                            EncodingType="..."
                            ValueType="...">
                            ...
                        </wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
            </ds:Signature>
        </wsse:Security>
    </soap:Header>
    <soap:Body xmlns:ns1="..."
        xmlns:wsu="..."
        wsu:Id="id-623">
        <xenc:EncryptedData xmlns:xenc="..."
            Id="EncDataId-624" Type="...">
            <xenc:EncryptionMethod Algorithm="..." />
            <ds:KeyInfo xmlns:ds="...">
                <wsse:SecurityTokenReference
                    xmlns:wsse="...">
                    <wsse:Reference
                        xmlns:wsse="..."
                        URI="#EncKeyId-B8B3555394366F3F0112919826983351032" />
                </wsse:SecurityTokenReference>
            </ds:KeyInfo>
            <xenc:CipherData>
                <xenc:CipherValue>
                    ...
                </xenc:CipherValue>
            </xenc:CipherData>
        </xenc:EncryptedData>
    </soap:Body>
</soap:Envelope>

我的问题:

  1. 我如何才能知道安全的哪一部分确实失败了?是顺序错误、缺少某些元素、某些元素多余还是类似错误?
  2. 如果我只有签名和加密回复,我如何猜测应该将哪些项目添加到壁垒 InflowSecurity 配置?有没有办法知道我应该使用什么顺序?

【问题讨论】:

    标签: java axis2 webservice-client ws-security rampart


    【解决方案1】:

    这是一个相当老的问题,但是当我刚刚完成我穿越那片痛苦之地的旅程时,我会分享答案。

    a) 项目的顺序由底层 wss4j 库而不是壁垒强制执行。有问题的方法是来自 org.apache.ws.security.handler.WSHandler 的 checkReceiverResults()。您可能在使用扩展 WSHandler 的壁垒 WSDoAllReceiver 时遇到了问题。

    b) 好消息是 checkReceiverResults() 方法受到保护。因此,您可以扩展 WSDoAllReceiver 并覆盖该方法以使其更加宽松。我建议查看在 wss4j-1.5.8 中添加到 WSHandler 的 checkReceiverResultsAnyOrder() 实现。

    所以回答你的问题:

    您可以调试 checkReceiverResults() 方法以找出并“修复”axis2.xml 文件中项目的顺序。但这不是一个好方法,因为标头的顺序可能总是会改变(SOAP 标头中元素的顺序没有要求)。所以我的建议是调用 checkReceiverResultsAnyOrder() 而不是 checkReceiverResults()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 2014-10-12
      • 1970-01-01
      相关资源
      最近更新 更多