zoukankan      html  css  js  c++  java
  • 会话标识未更新

    IBM appcsan扫描安全漏洞--会话标识未更新

    appcsan修订建议:

    始终生成新的会话,供用户成功认证时登录。 防止用户操纵会话标识。 请勿接受用户浏览器登录时所提供的会话标识

    在登录验证成功之后调用下面方法

    @SuppressWarnings("unchecked")
        private void createNewSession(HttpServletRequest request, HttpServletResponse response) throws Exception {
            HttpSession oldSession = request.getSession();
            // get the content of old session.
            Enumeration<String> attributeNames = oldSession.getAttributeNames();
            Map<String, Object> attributeMap = new HashMap<String, Object>();
            while(attributeNames != null && attributeNames.hasMoreElements()){
                String attributeName = attributeNames.nextElement();
                attributeMap.put(attributeName, oldSession.getAttribute(attributeName));
            }
            oldSession.invalidate();
            HttpSession newSession = request.getSession(true);
            // put the content into the new session.
            for (String key : attributeMap.keySet()) {
                newSession.setAttribute(key, attributeMap.get(key));
            }
        }
  • 相关阅读:
    EF数据迁移完整步骤
    ajax跨域最全解决方案
    WPF控件与WPF窗体
    WPF模板是把控件MVC模式化
    对象与类型
    Java加权负载均衡策略
    db2列式存储
    linux离线安装mongodb及java调用
    python合并目录下excel数据
    python多线程迁移db2数仓9T数据
  • 原文地址:https://www.cnblogs.com/jimor/p/3418070.html
Copyright © 2011-2022 走看看