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

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

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

    空間站

    北極心空

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      15 Posts :: 393 Stories :: 160 Comments :: 0 Trackbacks

    acegi的登陸過程

    先來無事看看acegi的登陸過濾器 寫下來當作備忘吧
    主要的類是AuthenticationProcessingFilter 繼承了AbstractProcessingFilter 這要的邏輯都在后面這個類中
    讓我們看看核心代碼吧
    Java代碼 復制代碼
    1. public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,   
    2.         ServletException {   
    3.     if (!(request instanceof HttpServletRequest)) {   
    4.         throw new ServletException("Can only process HttpServletRequest");   
    5.     }   
    6.   
    7.     if (!(response instanceof HttpServletResponse)) {   
    8.         throw new ServletException("Can only process HttpServletResponse");   
    9.     }   
    10.   
    11.     HttpServletRequest httpRequest = (HttpServletRequest) request;   
    12.     HttpServletResponse httpResponse = (HttpServletResponse) response;   
    13.   
    14.     if (requiresAuthentication(httpRequest, httpResponse)) {   
    15.         if (logger.isDebugEnabled()) {   
    16.             logger.debug("Request is to process authentication");   
    17.         }   
    18.   
    19.         Authentication authResult;   
    20. /下面才是重點 上面都是些基本檢查   
    21.         try {   
    22.             onPreAuthentication(httpRequest, httpResponse);   
    23.             authResult = attemptAuthentication(httpRequest);//這個方法就是去登陸了 就是調用dao檢查用戶名密碼 登陸不成功將拋出異常   
    24.         }   
    25.         catch (AuthenticationException failed) {   
    26.             // Authentication failed   
    27.             unsuccessfulAuthentication(httpRequest, httpResponse, failed);   
    28.   
    29.             return;   
    30.         }   
    31.   
    32.         // Authentication success   
    33.         if (continueChainBeforeSuccessfulAuthentication) {   
    34.             chain.doFilter(request, response);   
    35.         }   
    36.   
    37.         successfulAuthentication(httpRequest, httpResponse, authResult);   
    38.   
    39.         return;   
    40.     }   
    41.   
    42.     chain.doFilter(request, response);   
    43. }  


    看一些登陸成功后 做些什么
    Java代碼 復制代碼
    1.     protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response,   
    2.             Authentication authResult) throws IOException {   
    3.         if (logger.isDebugEnabled()) {   
    4.             logger.debug("Authentication success: " + authResult.toString());   
    5.         }   
    6.   
    7. //把用戶信息保存到SecurityContextHolder中1980   
    8. SecurityContextHolder.getContext().setAuthentication(authResult);   
    9.   
    10.         if (logger.isDebugEnabled()) {   
    11.             logger.debug("Updated SecurityContextHolder to contain the following Authentication: '" + authResult + "'");   
    12.         }   
    13. //轉到目標頁面 即登陸成功頁面   
    14.         String targetUrl = determineTargetUrl(request);   
    15.   
    16.         if (logger.isDebugEnabled()) {   
    17.             logger.debug("Redirecting to target URL from HTTP Session (or default): " + targetUrl);   
    18.         }   
    19.   
    20.         onSuccessfulAuthentication(request, response, authResult);   
    21.   
    22.         rememberMeServices.loginSuccess(request, response, authResult);   
    23.   
    24.         // Fire event   
    25.         if (this.eventPublisher != null) {   
    26.             eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));   
    27.         }   
    28.   
    29.         sendRedirect(request, response, targetUrl);   
    30.     }  
    posted on 2008-06-19 10:36 蘆葦 閱讀(872) 評論(0)  編輯  收藏 所屬分類: SpringJAVA
    主站蜘蛛池模板: 深夜特黄a级毛片免费播放| 又色又污又黄无遮挡的免费视 | 国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 | 国产精品免费视频观看拍拍| 中文字幕免费视频精品一| 国产精品久久免费| 亚洲国产精品视频| 亚洲导航深夜福利| 无码毛片一区二区三区视频免费播放 | 永久免费看mv网站入口| 日韩亚洲人成在线综合日本| 亚洲综合一区国产精品| 免费无码H肉动漫在线观看麻豆| 成人影片麻豆国产影片免费观看 | 四虎影视www四虎免费| 亚洲av午夜成人片精品网站 | 叮咚影视在线观看免费完整版| 少妇高潮太爽了在线观看免费| 亚洲综合日韩久久成人AV| 亚洲欧美成人av在线观看| 久久久久久一品道精品免费看| 破了亲妺妺的处免费视频国产| 亚洲高清在线mv| 免费看无码特级毛片| 国产综合亚洲专区在线| 色偷偷亚洲男人天堂| 在线不卡免费视频| 亚洲成_人网站图片| 四虎免费影院ww4164h| 亚洲国产成人久久综合碰碰动漫3d| 免费精品久久久久久中文字幕| 好爽…又高潮了免费毛片| 2020久久精品亚洲热综合一本 | 亚洲一区二区在线免费观看| 国产在线精品一区免费香蕉| 亚洲国产中文v高清在线观看| 国产偷国产偷亚洲高清在线| 国产精品黄页在线播放免费| 亚洲av综合av一区二区三区| 国产国产人免费人成免费视频| 国产亚洲精品美女2020久久|