隨筆 - 37  文章 - 14  trackbacks - 0
          <2007年11月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          文章分類

          相關鏈接

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          針對上篇所提的問題
          1:假設有A、B兩個應用程式,現在在瀏覽器窗口1輸入對A應用程式的請求,會跳轉到cas login窗口身份驗證;身份驗證完成后跳轉會A應用程式請求頁面
          2:在窗口2輸入對B應用程式請求,還會需要身份驗證
          3:在窗口1修改URL為對B應用程式的請求,不需求身份驗證
          首先為什么在同一個窗口修改URL就可以對B應用程式請求而不需要身份驗證
          通過查看edu.yale.its.tp.cas.client.filter.CASFilter源碼可以發現有這么一段
                  HttpSession session = ((HttpServletRequest) request).getSession();

                  // if our attribute's already present and valid, pass through the filter chain
                  CASReceipt receipt = (CASReceipt) session.getAttribute(CAS_FILTER_RECEIPT);
                  if (receipt != null && isReceiptAcceptable(receipt)) {
                          log.trace("CAS_FILTER_RECEIPT attribute was present and acceptable - passing  request through filter..");
                      fc.doFilter(request, response);
                      return;
                  }
          就是說如果在session里已存在有效的CASRecipt就不再需要身份驗證。
          那如何解決不同窗口的問題;通過查看CAS SSO原理可以發現,當CAS SERVER驗證通過后向client傳遞ST的時候也同時向USER瀏覽器里傳遞一個TGC cookies;初步判定是因為找不到這個cookies導致的問題。具體SSO原理可看“SSO原理”這篇文章
          查找cookies:在cas server的cas-servlet.xml里
              <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
                  p:cookieSecure
          ="true"
                  p:cookieMaxAge
          ="-1"
                  p:cookieName
          ="CASTGC"
                  p:cookiePath
          ="/cas" />
          這是傳送cookies到user端的bean,其中cookieMaxAge的意思是:Use the given maximum age (in seconds) for cookies created by this generator. Useful special value: -1 ... not persistent, deleted when client shuts down(沒持久化)
          cooliePath的意思:Use the given path for cookies created by this generator. The cookie is only visible to URLs in this path and below.
          摘至:spring api
          因此通過修改cookieMaxAge的值控制cookies在User客戶端持久化的存活期如;至此就解決了不同窗口請求需要再次驗證的問題了。
          posted on 2007-11-19 12:58 扭曲的鉛筆 閱讀(2812) 評論(0)  編輯  收藏 所屬分類: J2EE
          主站蜘蛛池模板: 霸州市| 营山县| 赤峰市| 平阴县| 清水县| 巴林左旗| 加查县| 昌都县| 浏阳市| 高唐县| 绥棱县| 绥阳县| 萍乡市| 家居| 昭通市| 石狮市| 治多县| 太湖县| 青海省| 闵行区| 凤山县| 宁安市| 灵山县| 新闻| 苏州市| 柘荣县| 汤阴县| 甘洛县| 唐海县| 阳高县| 松阳县| 靖西县| 丹巴县| 西乡县| 绿春县| 道孚县| 平原县| 新巴尔虎右旗| 祁连县| 五莲县| 松溪县|