Spring 使用Wss4jSecurityInterceptor的SOAP请求中的空SignatureValue和DigestValue
我正在更新现有SOAP Web服务的客户机,因为服务提供商已经对请求中的安全头进行了一些更改 要求对时间戳进行数字签名,该时间戳应出现在请求头中,而正文不应进行数字签名。我正在使用XMLConfig创建SOAP请求头并对时间戳进行数字签名 我基本上使用org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor作为拦截器。问题是在请求头中创建时间戳,但SignatureValue和DigestValue标记为空 我已经提到 版本: Spring ws-core-->2.0.0.0版本 spring ws-security-->2.0.0.0版本Spring 使用Wss4jSecurityInterceptor的SOAP请求中的空SignatureValue和DigestValue,spring,spring-security,spring-ws,Spring,Spring Security,Spring Ws,我正在更新现有SOAP Web服务的客户机,因为服务提供商已经对请求中的安全头进行了一些更改 要求对时间戳进行数字签名,该时间戳应出现在请求头中,而正文不应进行数字签名。我正在使用XMLConfig创建SOAP请求头并对时间戳进行数字签名 我基本上使用org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor作为拦截器。问题是在请求头中创建时间戳,但SignatureValue和DigestValue标记为空 我已经提到
<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元素中,但是DigestValue和SignatureValue元素属于xmlns:ds=”http://www.w3.org/2000/09/xmldsig#“命名空间始终为空
如果我只在尸体上签名,这就不会发生
我还尝试过使用另一个拦截器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>
在参考了许多IBM支持帖子后,我终于找到了解决方案,并收到了关于实施的QA签准。我必须用WAS服务器本身的配置替换所有用于创建SSL上下文的spring mvc配置。您可以使用脚本或使用WAS控制台手动配置所有这些配置 步骤:
- 在ur applications web.xml中添加一个条目。请参阅本文
- 下面的链接将逐步指导您如何配置请求有效负载,使其在WAS服务器上具有签名的时间戳。
它主要集中在:
- 策略集创建:这将指定要在此消息部分中签名或加密的一个或多个元素。在本例中,它是标头中的时间戳
- 客户端策略集绑定。如果您是提供商,则必须参考提供商策略集绑定部分。这涉及创建配置SSL上下文所需的信任库和密钥库。还具有您可能需要的任何代理设置的配置
- 最后,获取需要调用服务中特定操作的服务的JNDI引用
请注意:此解决方案的版本为8.5.5.16,spring-3.0.5.RELEASE和spring-ws-2.0.0.RELEASE不支持在SOAP服务请求的请求有效负载中签名时间戳。希望这对别人有帮助 我使用的是WebSphere8.5.5,在ApacheTomcat8.0.50上部署了相同的应用程序,签名确实会被填充。我现在可以缩小WAS 8.5.5的问题范围。如果有人之前遇到过这个问题,请告诉我