【问题标题】:What is the Default Session Timeout Value in Struts?Struts 中的默认会话超时值是多少?
【发布时间】:2017-10-30 18:51:05
【问题描述】:

我有一个 java 代码,我正在审查它是否存在安全漏洞。该代码是使用 Apache Struts 框架开发的。代码中未设置会话超时。据我所知,只要框架没有设置默认会话超时值,这表明存在过多的会话超时漏洞。

【问题讨论】:

  • 我知道这不是您要求的,但在这里您可以看到如何在全局级别和每个会话基础上设置超时:mkyong.com/servlet/…

标签: security struts java-security secure-coding


【解决方案1】:

由于您没有明确设置会话超时,您可以使用HttpSession接口的getMaxInactiveInterval()方法在struts中获取会话超时的值。

代码:

HttpSession session = ServletActionContext.getRequest().getSession();  
int timeout = session.getMaxInactiveInterval();//Returns the maximum time interval, in seconds

【讨论】:

  • 感谢罗希特的帮助。我理解你所提到的。所以问题是 session.setMaxInactiveInterval() 没有在代码中的任何地方使用。除此之外,任何 .xml 文件中都没有 。这是否意味着没有超时?
  • 应该有一个默认的超时时间,你可以使用上面的代码得到它。它与 servlet 相同,即 30 分钟
猜你喜欢
  • 2010-11-03
  • 2014-02-06
  • 2010-09-13
  • 2013-12-12
  • 2016-09-19
  • 2012-08-21
  • 2023-03-24
  • 1970-01-01
  • 2011-05-13
相关资源
最近更新 更多