如何解决如何在 spring-ws 安全性上手动设置时间戳
客户端和服务器没有同步时间,因此soap服务器的安全返回未授权的响应。 我将获取服务器的当前时间,并在发送 soap 请求时使用该时间(在安全标头上,创建的用户名令牌 vs)。
如何在 spring-ws 上手动设置时间戳。
我正在使用 spring ws.client.core、ws.soap.security.wss4j2(Wss4jSecurityInterceptor 和 webservicetemplate)。 WS-Usernametoken 是为了安全而发送的(现时、用户名、密码、已创建(我猜是创建的问题。我应该设置它。) 服务器是onvif设备。
解决方法
您可以执行以下操作(来源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 消息
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。