@Override
  public void onAuthenticationSuccess(
      HttpServletRequest request, HttpServletResponse response, Authentication authentication)
      throws ServletException, IOException {
    SavedRequest savedRequest = requestCache.getRequest(request, response);

    if (savedRequest == null) {
      super.onAuthenticationSuccess(request, response, authentication);

      return;
    }
    String targetUrlParameter = getTargetUrlParameter();
    if (isAlwaysUseDefaultTargetUrl()
        || (targetUrlParameter != null
            && StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
      requestCache.removeRequest(request, response);
      super.onAuthenticationSuccess(request, response, authentication);

      return;
    }

    clearAuthenticationAttributes(request);

    // Use the DefaultSavedRequest URL
    String targetUrl = savedRequest.getRedirectUrl();
    logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
    getRedirectStrategy().sendRedirect(request, response, targetUrl);
  }
  @Override
  public void onAuthenticationSuccess(
      HttpServletRequest request, HttpServletResponse response, Authentication authentication)
      throws ServletException, IOException {
    SavedRequest savedRequest = requestCache.getRequest(request, response);

    if (savedRequest == null) {
      clearAuthenticationAttributes(request);
      return;
    }
    String targetUrlParam = getTargetUrlParameter();
    if (isAlwaysUseDefaultTargetUrl()
        || (targetUrlParam != null && StringUtils.hasText(request.getParameter(targetUrlParam)))) {
      requestCache.removeRequest(request, response);
      clearAuthenticationAttributes(request);
      return;
    }

    clearAuthenticationAttributes(request);
  }
  @Override
  public void onAuthenticationSuccess(
      HttpServletRequest request, HttpServletResponse response, Authentication authentication)
      throws ServletException, IOException {
    Object principal = authentication.getPrincipal();
    IUserDetailsVOWrapper userDetailsVOWrapper =
        (principal instanceof IUserDetailsVOWrapper) ? (IUserDetailsVOWrapper) principal : null;
    UserDetailsVO userDetailsVO = userDetailsVOWrapper.getUserDetailsVO();
    if (userDetailsVO != null) {

      //			if (request.getServletContext().getFilterRegistration("areaFilter") != null) { // TODO
      //				AreaDetailsManager.setCurrAreaDetailsVO(request.getSession(),
      // AreaDetailsManager.getCityAreaDetailsVO(userDetailsVO.getAreaCd()));
      //			}

      //			userDetailsVO.setIp(HttpUtil.getRemoteAddr(request));
      //			userDetailsVO.setAdvertisingMedia(GlobalVars.getAdvertisingMedia(request));

      //			if (casAvailable) {
      //    			if (authentication instanceof CasAuthenticationToken) {
      //    				CasAuthenticationToken cat = (CasAuthenticationToken) authentication;
      ////    				userDetailsVO.setLoginAcctNo(cat.getAssertion().getPrincipal().getName());
      //    			} else if (authentication instanceof CasAssertionAuthenticationToken) {
      //    				CasAssertionAuthenticationToken casat = (CasAssertionAuthenticationToken)
      // authentication;
      ////    				userDetailsVO.setLoginAcctNo(casat.getAssertion().getPrincipal().getName());
      //    			}
      //			}
    }

    if ("ssoFrame".equalsIgnoreCase(request.getParameter("type"))) { // /loginCheck
      RequestCache requestCache =
          ReflectUtil.getFieldValue(this, "requestCache", RequestCache.class);
      SavedRequest savedRequest = requestCache.getRequest(request, response);
      if (savedRequest == null) {
        if (!response.isCommitted()) {
          String targetUrl = determineTargetUrl(request, response);
          DefaultRedirectStrategy redirectStrategy =
              (DefaultRedirectStrategy) this.getRedirectStrategy();
          String redirectUrl =
              (String)
                  ReflectUtil.invokeMethod(
                      redirectStrategy,
                      "calculateRedirectUrl",
                      new Object[] {request.getContextPath(), targetUrl});
          redirectUrl = response.encodeRedirectURL(redirectUrl);

          HttpSession session = request.getSession(true);
          String ssoAuto = (String) session.getAttribute("_SECURITY_SSO_AUTO"); // 自动登录
          if (Boolean.parseBoolean(ssoAuto)) {
            session.removeAttribute("_SECURITY_SSO_AUTO");
            String callbackUrl = (String) session.getAttribute("_SECURITY_SSO_CALLBACK_URL");
            session.removeAttribute("_SECURITY_SSO_CALLBACK_URL");

            redirectStrategy.sendRedirect(
                request, response, StringUtil.defaultIfBlank(callbackUrl, redirectUrl));
          } else {
            redirectStrategy.sendRedirect(
                request, response, ssoFrameTargetUrl + "?targetUrl=" + redirectUrl);
          }
        }

        clearAuthenticationAttributes(request);
      } else {
        requestCache.removeRequest(request, response);
        clearAuthenticationAttributes(request);
        this.getRedirectStrategy()
            .sendRedirect(
                request,
                response,
                ssoFrameTargetUrl + "?targetUrl=" + savedRequest.getRedirectUrl());
      }
    } else if (isAjaxRequest(request)) {
      this.onAuthenticationSuccessForAjax(request, response, authentication);
    } else {
      super.onAuthenticationSuccess(request, response, authentication);
    }

    EapContext.publish("#login.success", authentication);
  }