簡體   English   中英

java - Apache CXF將簽名證書作為BinarySecurityToken添加到WS-security頭中

[英]java - Apache CXF add signing certificate as BinarySecurityToken into WS-security header

我正在使用WSDL,我需要在發出SOAP請求時使用我的客戶端證書簽署Timestamp和SOAP-body。

我的簽名證書必須在消息中表示為BinarySecurityToken,並包含在SOAP頭中,如下所示:

<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="true">
        <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs
.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-15730854BE4465A46D14538884282111">MIIFO.......56Q==</wss
e:BinarySecurityToken>
        <wsu:Timestamp wsu:Id="TS-1">
            <wsu:Created>2016-03-16T09:53:48.201Z</wsu:Created>
            <wsu:Expires>2016-03-16T09:58:48.201Z</wsu:Expires>
        </wsu:Timestamp>
        .......

我正在使用WSS4JOutInterceptor來自定義我的請求,但無法找到如何將簽名證書包含在請求中的方法:

// for outgoing messages: Signature and Timestamp validation
        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.TIMESTAMP);
        outProps.put(WSHandlerConstants.USER, "sss");
        outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientKeystorePasswordCallbackHandler.class.getName());
        outProps.put(WSHandlerConstants.SIG_PROP_FILE, "client_sec.properties");
        outProps.put(WSHandlerConstants.SIG_KEY_ID, "X509KeyIdentifier");
        outProps.put(WSHandlerConstants.SIGNATURE_PARTS, "{}{http://schemas.xmlsoap.org/soap/envelope/}Body;{}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp}");

誰能建議我怎么做?

好的,這里作為要求的答案。 :-)

正如我在評論中提到的,您應該將SIG_KEY_ID的值更改為outProps.put(WSHandlerConstants.SIG_KEY_ID,“DirectReference”);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM