【问题标题】:How to set timestamp manually on spring-ws security如何在 spring-ws 安全性上手动设置时间戳
【发布时间】:2021-04-13 09:21:18
【问题描述】:
客户端和服务器没有同步时间,因此肥皂服务器的安全返回未经授权的响应。
我将获取服务器的当前时间,并在发送肥皂请求时使用该时间(在安全标头上,创建的用户名令牌与)。
如何在 spring-ws 上手动设置时间戳。
我正在使用 spring ws.client.core、ws.soap.security.wss4j2(Wss4jSecurityInterceptor 和 WebServiceTemplate)。
WS-Usernametoken 是为了安全而发送的(随机数、用户名、密码、已创建(我猜是已创建的问题。我应该设置它。)
服务器是onvif设备。
【问题讨论】:
标签:
java
spring
spring-ws
ws-security
【解决方案1】:
您可以执行以下操作(来源此处here)
<bean class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="validationActions" value="Timestamp"/>
<property name="timestampStrict" value="true"/>
<property name="timeToLive" value="10"/>
简而言之,您可以执行以下操作
- 调用 %SOAP.Security.Timestamp 的 Create() 类方法
set ts=##class(%SOAP.Security.Timestamp).Create()
- 调用 Web 客户端或 Web 服务的 SecurityOut 属性的 AddSecurityElement() 方法
do client.SecurityOut.AddSecurityElement(ts)e
- 发送 SOAP 消息