我也在尝试使用 Apache CXF 编写“Secure Hello World”网络服务;我应该指出,我对 Java 和 WS-* 有点陌生。
基本上,我想要做的是一个 hello-world web 服务,其中包含往返于此 web 服务的 soap 消息使用 x.509 证书签名和加密。
我已经读过the tutorial on Apache CXF site about WS-Security但;我想使用 WS-SecurityPolicy 而不是拦截器。
谁能指出我正确的方向?
最佳答案
这是一个详细介绍如何使用 Apache CXF 的博客:Adding X.509 security headers to Apache CXF SOAP calls (WS-SecurityPolicy method)
还有一个 tutorial源代码配置为使用 WS-SecurityPolicy 方法。
编辑:修复了损坏的链接,添加了教程链接。
CXF site 上现在对 WS-SecurityPolicy 的各种设置有一个很好的概述。 ,它引用了上面的链接。
简而言之(以防链接再次被炸毁),WS-SecurityPolicy 的配置类似于 CXF interceptor method除了 cxf.xml 和 cxf-servlet.xml 中的一些更改外,在 CXF wiki 上进行了描述:
cxf.xml
<jaxws:client name="{http://myport" createdFromAPI="true">
<!-- You will need to add the corresponding values to a properties file -->
<jaxws:properties>
<entry key="ws-security.callback-handler" value="client.ClientKeystorePasswordCallback"/>
<entry key="ws-security.encryption.properties" value=keystore.properties"/>
<entry key="ws-security.signature.properties" value="keystore.properties"/>
<entry key="ws-security.encryption.username" value="myservicekey"/>
</jaxws:properties>
cxf-servlet.xml
<jaxws:properties>
<entry key="ws-security.callback-handler">
<ref bean="myPasswordCallback"/>
</entry>
<entry key="ws-security.encryption.properties" value="serviceKeystore.properties"/>
<entry key="ws-security.signature.properties" value="serviceKeystore.properties"/>
<entry key="ws-security.encryption.username" value="useReqSigCert"/>
</jaxws:properties>
关于java - 使用 Apache CXF 对 SOAP 消息进行签名和加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3752075/