<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sky's blog

    我和我追逐的夢

    常用鏈接

    統計

    其他鏈接

    友情鏈接

    最新評論

    resin的session id reuse特性(2)--分析問題

        上文中詳細描述了問題的表現情況,由于這個特性嚴重影響到目前為公司設計的一套前臺統一認證方案,因此不得不特別關注。好在resin的源代碼是公開的,直接從resin的官網將resin的源代碼拿下來,看resin到底是如何處理的。

    首先找到com.caucho.server.http.HttpRequest,發現是extends AbstractHttpRequest
     在AbstractHttpRequest中找到方法
      public HttpSession getSession(boolean create)

            發現調用
    _session = createSession(create, hasOldSession);
        這里有一段注釋解釋了重用jsessonid的行為:
            Must accept old ids because different applications in the same server must share the same cookie
            But, if the session group doesn't match, then create a new session.

      在createSession方法中找到
      manager.createSession(id, now, this, _isSessionIdFromCookie);

     
      打開com.caucho.server.session.SessionManager的createSession()方法,
      發現有注釋: @param oldId the id passed to the request.  Reuse if possible.
     
      看代碼:
      String id = oldId;

        
    if (id == null || id.length() < 4 ||
            
    ! isInSessionGroup(id) || ! reuseSessionId(fromCookie)) {
          id 
    = createSessionId(request, true);
        }

        SessionImpl session 
    = create(id, now, true);

     
            我們關注! reuseSessionId(fromCookie)這句,打開看函數
       /**
       * True if the server should reuse the current session id if the
       * session doesn't exist.
       
    */
      
    public boolean reuseSessionId(boolean fromCookie)
      {
        
    int reuseSessionId = _reuseSessionId;
       
        
    return reuseSessionId == TRUE || fromCookie && reuseSessionId == COOKIE;
      }

      注:非常不喜歡resin的這種代碼風格,一般我寧可寫成下面的這種,看代碼時容易理解
      return (reuseSessionId == TRUE) || (fromCookie && (reuseSessionId == COOKIE));
            再看
     
    /**
       * True if the server should reuse the current session id if the
       * session doesn't exist.
       
    */
      
    public void setReuseSessionId(String reuse)
        
    throws ConfigException
      {
        
    if (reuse == null)
          _reuseSessionId 
    = COOKIE;
        
    else if (reuse.equalsIgnoreCase("true"||
             reuse.equalsIgnoreCase(
    "yes"||
             reuse.equalsIgnoreCase(
    "cookie"))
          _reuseSessionId 
    = COOKIE;
        
    else if (reuse.equalsIgnoreCase("false"|| reuse.equalsIgnoreCase("no"))
          _reuseSessionId 
    = FALSE;
        
    else if (reuse.equalsIgnoreCase("all"))
          _reuseSessionId 
    = TRUE;
        
    else
          
    throw new ConfigException(L.l("'{0}' is an invalid value for reuse-session-id.  'true' or 'false' are the allowed values.",
                        reuse));
      }
          并且可以看到默認值為COOKIE
    private int _reuseSessionId = COOKIE;
       
        翻一下resin的文檔,可以發現在resin.conf的<session-config>有reuse-session-id這個配置項,resin文檔的說明如下:
       
        "reuse-session-id defaults to true so that Resin can share the session id amongst different web-apps."
       
        默認情況下reuse-session-id設置為true,setReuseSessionId("true")會使得_reuseSessionId=COOKIE,而reuseSessionId()方法中的表達式可以簡化:
        (reuseSessionId == TRUE) || (fromCookie && (reuseSessionId == COOKIE));
        -->  (COOKIE == TRUE) || (fromCookie && (COOKIE == COOKIE))
        --> (false) || (fromCookie && true)
        --> fromCookie
        因此默認情況下jsessionid用cookie傳遞就可以做到重用,否則就要生成新的jsessionid.
       
        按照這個思路,只要將reuse-session-id配置項設置為"all",就可以做到即使使用url rewrite也可以重用jsessionid.
        ok,問題解決

    posted on 2007-12-28 12:01 sky ao 閱讀(1695) 評論(0)  編輯  收藏 所屬分類: web

    主站蜘蛛池模板: 亚欧日韩毛片在线看免费网站| 在线观看亚洲电影| 91精品免费久久久久久久久| 亚洲国产精品热久久| 污污网站免费观看| 久久青青草原亚洲av无码app | 在线aⅴ亚洲中文字幕| 免费A级毛片无码免费视| 亚洲综合欧美色五月俺也去| 国产在线a不卡免费视频| j8又粗又长又硬又爽免费视频| 色久悠悠婷婷综合在线亚洲| 国产色爽免费无码视频| 亚洲自偷自偷精品| 9久9久女女免费精品视频在线观看| 亚洲午夜精品一区二区麻豆| 国产成人精品123区免费视频| 美女被免费网站视频在线| 国产亚洲欧洲Aⅴ综合一区 | 免费国产成人午夜在线观看| 亚洲国产精品一区二区久| 白白国产永久免费视频| 一级特黄特色的免费大片视频| 国产亚洲精品a在线无码| 2021精品国产品免费观看| 亚洲av无码专区在线观看下载| 亚洲av无码乱码在线观看野外 | 24小时日本在线www免费的| 特级毛片全部免费播放| 亚洲av无码专区国产乱码在线观看 | 中文字幕日本人妻久久久免费| 亚洲欧洲日本天天堂在线观看| 在线观看无码的免费网站| 亚洲天堂免费在线视频| 亚洲妓女综合网99| 亚洲乱码国产一区网址| 91免费播放人人爽人人快乐| 特黄特色大片免费| 亚洲av日韩av综合| 亚洲中文字幕第一页在线| 免费观看成人毛片a片2008|