【发布时间】:2019-09-10 10:46:22
【问题描述】:
我正在更新现有 SOAP Web 服务的客户端,因为服务提供商已对其请求中的安全标头进行了一些更改。
要求是对应该存在于请求标头中的时间戳进行数字签名,并且不应对正文进行数字签名。我正在使用 XML 配置来创建我的 SOAP 请求标头并对时间戳进行数字签名。
我基本上使用 org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor 作为拦截器。问题是 Timestamp 是在请求标头中创建的,但是 SignatureValue 和 DigestValue 标签是空的
我已推荐https://docs.spring.io/spring-ws/site/reference/html/security.html#security-wss4j-digital-signatures
版本: Spring-ws-core --> 2.0.0.RELEASE spring-ws-security --> 2.0.0.RELEASE
<bean id="wsClientSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="securementActions" value="Timestamp Signature"/>
<property name="securementSignatureKeyIdentifier" value="DirectReference" />
<property name="securementUsername" value="username" />
<property name="securementPassword" value="keystorepassword" />
<property name="securementSignatureCrypto" ref="clientCrypto"/>
<property name="securementSignatureUser" value="username" />
<property name="securementSignatureParts" value="{}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp"/>
</bean>
<bean id="clientCrypto" class="org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean">
<property name="keyStorePassword" value="keystorepassword" />
<property name="keyStoreLocation" value="file:${key.store.location}"/>
<property name="keyStoreType" value="jks" />
<property name="keyStoreProvider" value="IBMJCE" />
</bean>
虽然时间戳被添加到标头中的 wsse:Security 元素,但属于 xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 命名空间的 DigestValue 和 SignatureValue 元素是总是空的
如果我只签署正文就不会发生这种情况
我也尝试使用另一个拦截器 XwsSecurityInterceptor,但没有 Wss4jSecurityInterceptor 就无法工作,并且在与 Wss4jSecurityInterceptor 一起使用时给我相同的结果
<bean id="xwsSecurityInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="classpath:securityPolicy.xml"/>
<property name="callbackHandlers">
<list>
<ref bean="keyStoreHandler"/>
</list>
</property>
</bean>
<bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
<property name="keyStore" ref="keyStore"/>
<property name="privateKeyPassword" value="keystorepassword"/>
</bean>
<bean id="keyStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
<property name="location" value="file:${key.store.location}"/>
<property name="password" value="keystorepassword"/>
</bean>
【问题讨论】:
-
我使用的是 Websphere 8.5.5
-
在 Apache Tomcat 8.0.50 上部署了相同的应用程序,并且确实填充了签名。我现在可以将问题缩小到 WAS 8.5.5。如果有人之前遇到过这个问题,请告诉我
标签: spring spring-security spring-ws