【问题标题】:Java EE Container based Certificate authentication logout基于 Java EE 容器的证书身份验证注销
【发布时间】:2015-08-27 12:58:45
【问题描述】:

在我们的 Java EE 应用程序中,我们使用基于容器的证书身份验证。我们创建了 JAASLoginModule,它使用所有必需的方法实现了 LoginModule 接口。我们已将 Wildfly 和 TomEE 服务器配置为使用此模块进行身份验证和 ssl 通道安全,用户登录后一切顺利:

  • 用户打开浏览器和应用程序;
  • 选择证书;
  • 创建了一个 JSF 会话,现在他已登录;

注销是一个不同的故事。仅仅销毁 JSF 会话是不够的 - 注销后,如果您单击返回,浏览器将从缓存中获取证书信息,重新创建会话并让您执行相同的操作。有时甚至重新启动浏览器也无济于事。 我找不到从 JSF 托管 bean 的 LoginModule 调用注销方法的有效方法。

有什么办法可以解决这个问题?

【问题讨论】:

    标签: security jakarta-ee certificate ssl-certificate logout


    【解决方案1】:

    您的问题直接出在浏览器上,因此您需要告诉浏览器每次注销时都从您的页面“重新启动”缓存,以便它认为这是客户端第一次试图进入那个页面。与 Chrome 和 Firefox 中的私有窗口类似。

    试试这个代码:

     //...
     response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
     response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
     response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
     response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
    
     //can check userId or something likes this.In this sample, i checked with userName.
     String userName = (String) session.getAttribute("User");
     if (null == userName) {
         request.setAttribute("Error", "Session has ended.  Please login.");
         RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
         rd.forward(request, response);
    }
    

    来源:How to clear browser cache using java

    【讨论】:

    • 没有办法从服务器端在 java(或任何其他语言和/或容器恕我直言)中强制执行此操作。我做了很多研究,唯一可靠的方法是重启浏览器。
    猜你喜欢
    • 1970-01-01
    • 2014-06-09
    • 2016-10-02
    • 2011-05-08
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    • 2012-09-06
    相关资源
    最近更新 更多