2

すべて、私は (まだ) Java/Metro 2.0 から WSE 3.0 .NET Web サービスを呼び出すことに取り組んでいます。メッセージの本文とヘッダーを暗号化し、ヘッダーに署名するように、セキュリティ要件が設定されています。サービスにリクエストを送信して応答を受け取ることはできますが、Metro は署名を検証できず、WSIT コードからエラーをスローします。私は CVS から最新の WSIT コードを入手しました。これは、大失敗しているメソッドのコード スニペットです。

com.sun.xml.ws.security.opt.impl.incoming.GenericSecuredHeader から:

private XMLStreamBuffer completeHeader;
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
        try {
            // TODO what about in-scope namespaces
            completeHeader.writeToXMLStreamWriter(w);
        } catch (Exception e) {
            throw new XMLStreamException(e);
        }
    }

ご覧のとおり、そこには TODO があります。これは、メソッドが現在の状況を処理できないことを示していると思いますが、「範囲内」の名前空間が何を意味するのかわかりません。

以下は、壊れている Web サービス応答からの XML のスニペットです。

<wsa:Action wsu:Id="Id-46282a5d-c7fa-403c-8ac9-f7df0dfdb0cf">
http://someAction</wsa:Action>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />

<Reference URI="#Id-46282a5d-c7fa-403c-8ac9-f7df0dfdb0cf">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>
/2ivNKDpYSLqPWHzrSxN/RuZ/e8=</DigestValue>
</Reference>

スタック トレース (以下に含まれる) では、参照 URI="#Id-46282a5d-c7fa-403c-8ac9-f7df0dfdb0cf" を検証できないと不平を言っています。 私がはっきりしていないのは、参照要素に名前空間属性または接頭辞がないために失敗しているのでしょうか? 親の Signature 要素から名前空間を継承することを許可する必要がありますか?それとも、StreamBuffer クラスがそれを処理できないようにすることはできますか?

対照的に、私の要求 (WSIT によって生成されたもの) からの同様の XML スニペットを次に示します。ここで、ds プレフィックスは

xmlns:ds="http://www.w3.org/2000/09/xmldsig#"

<ds:Signature xmlns:ns10="http://www.w3.org/2003/05/soap-envelope" 
xmlns:ns11="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" 
xmlns:ns12="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity" Id="_1">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<exc14n:InclusiveNamespaces PrefixList="wsse S"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>

<ds:Reference URI="#_5002">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<exc14n:InclusiveNamespaces PrefixList="S"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>
vtf9n+OcI1nT0exavD4/ZQy6jm8=</ds:DigestValue>
</ds:Reference>

Metro がこれらのブロックを生成すると、すべてに名前空間プレフィックスが付きます。

まだここまで読んでいるなら - ありがとう!スタック トレースの一部を次に示します。

Error occurred while trying to cache START_ELEMENTcom.sun.xml.stream.buffer.stax
.StreamReaderBufferProcessor$InternalNamespaceContext
[16:12:54.026] WSS1759: Following error null occured while performing canonicali
zation null
[16:12:54.026] javax.xml.stream.XMLStreamException
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.GenericSecuredHeade
r.writeTo(GenericSecuredHeader.java:303)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.StreamWriterData.wr
ite(StreamWriterData.java:101)
[16:12:54.026]  at com.sun.xml.ws.security.opt.crypto.dsig.Exc14nCanonicalizer.t
ransform(Exc14nCanonicalizer.java:153)
[16:12:54.026]  at com.sun.xml.ws.security.opt.crypto.dsig.Transform.transform(T
ransform.java:182)
[16:12:54.026]  at com.sun.xml.ws.security.opt.crypto.dsig.Reference.transform(R
eference.java:183)
[16:12:54.026]  at com.sun.xml.ws.security.opt.crypto.dsig.Reference.validate(Re
ference.java:102)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.processor.SignedInf
oProcessor.processReference(SignedInfoProcessor.java:422)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.processor.SignedInf
oProcessor.processReferences(SignedInfoProcessor.java:385)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.processor.SignedInf
oProcessor.process(SignedInfoProcessor.java:189)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.Signature.process(S
ignature.java:206)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.h
andleSecurityHeader(SecurityRecipient.java:466)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.c
acheHeaders(SecurityRecipient.java:281)
[16:12:54.026]  at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.v
alidateMessage(SecurityRecipient.java:223)
[16:12:54.026]  at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.verifyInboundMess
age(SecurityTubeBase.java:462)
[16:12:54.026]  at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processClientRe
sponsePacket(SecurityClientTube.java:412)
[16:12:54.026]  at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processResponse


javax.xml.ws.WebServiceException: com.sun.xml.wss.impl.WssSoapFaultException: WSS1722: Error occurred while validating Reference with URI: #Id-46282a5d-c7fa-403c-8ac9-f7df0dfdb0c
f
4

1 に答える 1

0

さらに調査を行った結果、これについての最初の理解は正しいと思います。StreamBuffer コードを呼び出して SOAP 応答から XML をストリーミングする Metro/WSIT コードは、名前空間のプレフィックスまたは属性を持たない要素を処理できません。フォローアップに関心のある方のために、WSIT に対する問題を提出しました。

https://wsit.dev.java.net/issues/show_bug.cgi?id=1423

于 2010-05-06T15:37:26.840 に答える