繁体   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