java - 如何延长 SOAP 标头消息时间戳的过期时间
问题描述
有没有办法延长 SOAP 消息头时间戳的生存时间(到期时间)以防止“WSSecurityException:消息已过期”异常。默认设置为 300 秒(5 分钟)。我们想把它延长到 10 分钟。
我们有一个 java ee(jdk 1.8.0_77) 服务,它使用 SOAP 消息与 android 客户端进行通信。它在 Jboss Wildfly 10.0.0 上运行。服务器,并使用 Apache CXF(版本 3.1.4)WS 安全性来处理消息。wss4j 安全策略是版本 2.1.4 我们有 wsdl 文件、自定义 WS-Security Endpoint(server-endpoint-config.xml 文件)和我们的 Schema.xsd 文件。我不知道这些文件的哪些部分是相关的,所以如果有人需要更多信息,我会提供它们。我尝试使用扩展 WSS4JInInterceptor 的自定义拦截器,但是这部分代码永远不会被执行。
@WebService
(
portName = "HelloPort",
serviceName = "BampayService",
wsdlLocation = "WEB-INF/BampayService.wsdl",
targetNamespace = "http://bampay.bamcard.ba/",
endpointInterface = "ba.bamcard.bampay.Hello"
)
@EndpointConfig
(
configFile = "WEB-INF/server-endpoint-config.xml",
configName = "Custom WS-Security Endpoint"
)
@InInterceptors(// I added this part
interceptors = {"ba.bamcard.helpers.MyInterceptor"}
)
和 MyInterceptor 的代码
public class MyInterceptor extends WSS4JInInterceptor {
@Override
public int decodeTimeToLive(RequestData reqData, boolean timestamp) {
// return super.decodeTimeToLive(reqData, timestamp);
return 600;
}
}
如果需要,我很乐意提供任何其他信息。如果有人可以帮助我,我将不胜感激。
解决方案
将此属性添加到您想要的服务器端安全设置中的值。
ws-security.timestamp.timeToLive
如果您认为您看到客户端和服务器之间的时钟偏差是错误原因的一部分,那么您还需要考虑将来发送带有时间戳的消息的客户端。
ws-security.timestamp.futureTimeToLive
推荐阅读
- android - ViewPager2 在慢速设备上或调试时不显示正确的片段
- django - django rest框架在发送到浏览器之前计算/修改结果
- html - 弹性项目之间的白色边框
- android - 如何创建和管理多标签 Android 应用程序?
- android - 在android编程中使用什么意图打开钱包应用程序
- django - 在 Django 中根据端点设置不同的 CORS 规则
- asp.net-core - 如何在 Identityserver 4 中强制注销另一个用户?
- php - 类 App\PageStatus (DateTime?) 的对象无法转换为 int
- delphi - Delphi在非常简单的程序上获取流读取错误
- c - 当我使用 c 使用指针数组乘以 2 个矩阵时,我得到了错误的答案