java - 使用 Apache CXF 对 SOAP 消息进行签名和加密

标签 java web-services cxf

我也在尝试使用 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/

相关文章:

java - 对象列表中的整数总和

java - 带数组的 Web 服务请求

java - 使用 REST 服务调用 SOAP 服务

php - 结合 servlet 和 "normal"网络服务器

java - 与CXF 2.4.10相关的Spring初始化失败

jax-ws - Apache CXF JAX-RS 服务缺少 XML 文档启动

java - 如何检查空格后面是否有某个字符?

java - 如何使用 Hibernate 保存价格信息

java - 如何使用 Java 将错误消息移动到 Azure 死信队列?

maven - 运行未修改的原型(prototype) CXF JAX RS 项目时出错