简体   繁体   中英

How to enable SignatureConfirmation element in an Apache CXF SOAP server

I have a soap client and also a soap server both using CXF. I have message signing working correctly. When I point my soap client at a different SOAP server using an IBM SOAP appliance, the reply messages contain the element SignatureConfirmation. I want to ensure that my CXF based SOAP server gives the same results as third-party SOAP servers do, so how do I configure my server to enable that element?

Here is how I set up my server:

signingProps.put(WSHandlerConstants.ACTION, "Timestamp Signature"); 
signingProps.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"); 
signingProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial"); 

Properties keyStoreProps = new Properties(); 
keyStoreProps.put(LocalCryptoProvider.WS_CRYPTO_PROVIDER, 
    LocalCryptoProvider.class.getName()); 
keyStoreProps.put(LocalCryptoProvider.KEYSTORE_OBJECT, keyStore); 

WSS4JOutInterceptor outSigner = new WSS4JOutInterceptor(signingProps); 
cxfFactory.getOutInterceptors().add(new SAAJOutInterceptor()); 
cxfFactory.getOutInterceptors().add(outSigner); 

该操作应为“ enableSignatureConfirmation”,它将负责在响应中添加签名确认元素。

signingProps.put(WSHandlerConstants.ACTION, "enableSignatureConfirmation");

I found the right answer.

In the properties map passed to the WSS4JOutInterceptor and WSS4JInInterceptor add ENABLE_SIGNATURE_CONFIRMATION, ie

signingProps.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true" );

This needs to be set on both the client and the server or it won't work. Also if you enable signature confirmation on the client, but not on the server, then the client will throw an exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM