當前位置: 首頁>>代碼示例>>Java>>正文


Java SavedRequest.getRedirectUrl方法代碼示例

本文整理匯總了Java中org.springframework.security.web.savedrequest.SavedRequest.getRedirectUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java SavedRequest.getRedirectUrl方法的具體用法?Java SavedRequest.getRedirectUrl怎麽用?Java SavedRequest.getRedirectUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.security.web.savedrequest.SavedRequest的用法示例。


在下文中一共展示了SavedRequest.getRedirectUrl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onAuthenticationSuccess

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
    SavedRequest savedRequest = this.requestCache.getRequest(request, response);
    if(savedRequest == null) {
        //super.onAuthenticationSuccess(request, response, authentication);
        handle(request, response, authentication);
        super.clearAuthenticationAttributes(request);
    } else {
        String targetUrlParameter = this.getTargetUrlParameter();
        if(!this.isAlwaysUseDefaultTargetUrl() && (targetUrlParameter == null || !StringUtils.hasText(request.getParameter(targetUrlParameter)))) {
            this.clearAuthenticationAttributes(request);
            String targetUrl = savedRequest.getRedirectUrl();
            this.logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
            //this.getRedirectStrategy().sendRedirect(request, response, targetUrl);
        } else {
            this.requestCache.removeRequest(request, response);
            //super.onAuthenticationSuccess(request, response, authentication);
            handle(request, response, authentication);
            super.clearAuthenticationAttributes(request);
        }
    }
}
 
開發者ID:luotuo,項目名稱:springboot-security-wechat,代碼行數:22,代碼來源:MyAuthenticationSuccessHandler.java

示例2: loginSuccess

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
/**
 * 如果是訪問受限頁麵後,跳轉到登錄頁的,則在targetUrl保存之前受限頁麵的路徑,供頁麵調用
 *
 * @param request
 * @param response
 * @return
 */
@RequestMapping(value = "/login/success", method = RequestMethod.GET)
public @ResponseBody  JSONObject loginSuccess(HttpServletRequest request, HttpServletResponse response) {
	SavedRequest savedRequest = requestCache.getRequest(request, response);
	String targetUrl = null;
	if (savedRequest != null) {
		targetUrl = savedRequest.getRedirectUrl();
	}
	Map<String, Object> result = new HashMap<>();
	result.put("success", true);
	result.put("targetUrl", targetUrl);
	UserDetails userDetails = UserDetailsUtil.getCurrentUser();
	result.put("userDetails",userDetails);

	if(userDetails!=null) {
		SessionInfo sessionInfo = new SessionInfo();
		sessionInfo.setUsername(userDetails.getUsername());
		request.getSession().setAttribute("sessionInfo", sessionInfo);
		result.put("sessionInfo",sessionInfo);
	}
	return JsonUtil.getSuccessJsonObject(result);
}
 
開發者ID:fier-liu,項目名稱:FCat,代碼行數:29,代碼來源:SecurityController.java

示例3: getTargetUrlFromSavedRequest

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
private String getTargetUrlFromSavedRequest(HttpServletRequest request,
        SavedRequest savedRequest) {
    String targetUrl = null;
    if (savedRequest != null) {
        // get saved absolute target URL
        targetUrl = savedRequest.getRedirectUrl();
        String url = targetUrl.toLowerCase(Locale.ENGLISH);
        // assert that there is no down-grade to HTTP if current request is HTTPS
        if (request.isSecure() && !url.startsWith("https:")) {
            // convert to relative URL
            targetUrl = convertToRelativeUrl(request, targetUrl);
        }
        if (targetUrl == null) {
            LOGGER.debug(
                    "Target URL from saved request could not be converted to a relative URL: {}",
                    savedRequest.getRedirectUrl());
        } else {
            LOGGER.debug("Found target URL in saved request: {}", targetUrl);
        }
    }
    return targetUrl;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:23,代碼來源:CommunoteAuthenticationSuccessHandler.java

示例4: handle

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
/**
 * First check for a <code>SavedRequest</code> and if none exists continue
 * as per {@link AbstractAuthenticationTargetUrlRequestHandler}.
 */
protected void handle(HttpServletRequest request,
        HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {
    SavedRequest savedRequest = new HttpSessionRequestCache().getRequest(
            request, response);
    String targetUrl = savedRequest.getRedirectUrl();
    System.out.println("requested url: " + targetUrl);

    if (targetUrl == null) {
        targetUrl = determineTargetUrl(request, response);
    }

    if (response.isCommitted()) {
        logger.debug("Response has already been committed. Unable to redirect to "
                + targetUrl);
        return;
    }

    getRedirectStrategy().sendRedirect(request, response, targetUrl);
}
 
開發者ID:OneDecision,項目名稱:one-decision,代碼行數:25,代碼來源:RedirectingAuthenticationSuccessHandler.java

示例5: onAuthenticationSuccess

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {

 	SavedRequest savedRequest = 
 		    new HttpSessionRequestCache().getRequest(request, response);
 	
    if (savedRequest == null) {
          return;
     }
    HttpSession session = request.getSession();
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);

     
     // Use the DefaultSavedRequest URL
     String targetUrl = savedRequest.getRedirectUrl();
     logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl);
     response.sendRedirect(targetUrl);
 }
 
開發者ID:eteration,項目名稱:glassmaker,代碼行數:18,代碼來源:OAuth2AuthenticationFilter.java

示例6: onAuthenticationSuccess

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
@Override
public void onAuthenticationSuccess(HttpServletRequest request,
									HttpServletResponse response, Authentication authentication)
		throws IOException, ServletException {
	// 獲取用戶權限
	Collection<? extends GrantedAuthority> authCollection = authentication
			.getAuthorities();
	if (authCollection.isEmpty()) {
		return;
	}

	// 認證成功後,獲取用戶信息並添加到session中
	UserDetails userDetails = (UserDetails) authentication.getPrincipal();
	MangoUser user = userService.getUserByName(userDetails.getUsername());
	request.getSession().setAttribute("user", user);

	String url = null;
	// 從別的請求頁麵跳轉過來的情況,savedRequest不為空
	SavedRequest savedRequest = requestCache.getRequest(request, response);
	if (savedRequest != null) {
		url = savedRequest.getRedirectUrl();
	}

	// 直接點擊登錄頁麵,根據登錄用戶的權限跳轉到不同的頁麵
	if (url == null) {
		for (GrantedAuthority auth : authCollection) {
			url = authDispatcherMap.get(auth.getAuthority());
		}
		getRedirectStrategy().sendRedirect(request, response, url);
	}

	super.onAuthenticationSuccess(request, response, authentication);

}
 
開發者ID:honghailiang,項目名稱:SpringMango,代碼行數:35,代碼來源:MyAuthenticationSuccessHandler.java

示例7: signInAdapter

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
@Bean
public SignInAdapter signInAdapter(UserDetailsService userDetailsService) {
	RequestCache requestCache = new HttpSessionRequestCache();
	return (userId, connection, request) -> {
		UserDetails userDetails = userDetailsService.loadUserByUsername(userId);
		Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
		SecurityContextHolder.getContext().setAuthentication(authentication);
		SavedRequest savedRequest = requestCache.getRequest(request.getNativeRequest(HttpServletRequest.class), request.getNativeResponse(HttpServletResponse.class));
		return savedRequest == null ? null : savedRequest.getRedirectUrl();
	};
}
 
開發者ID:codenergic,項目名稱:theskeleton,代碼行數:12,代碼來源:SocialConfig.java

示例8: determineTargetUrl

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
@Override
protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) {
	if (isAlwaysUseDefaultTargetUrl())
		return getDefaultTargetUrl();
	
	String targetUrl = null;

	if (getTargetUrlParameter() != null) {
		targetUrl = request.getParameter(getTargetUrlParameter());
	}
	
	SavedRequest savedRequest = requestCache.getRequest(request, response);
	if (savedRequest != null && !StringUtils.hasText(targetUrl)) {
		targetUrl = savedRequest.getRedirectUrl();
	}
	
	if (useReferer && !StringUtils.hasText(targetUrl)) {
		targetUrl = request.getHeader("Referer");
	}
	
	if (StringUtils.hasText(targetUrl)) {
		try {
			request.setAttribute("target", targetUrl);
			return getDefaultTargetUrl() + "?" + getTargetUrlParameter() + "=" + URLEncoder.encode(targetUrl, "UTF-8");
		} catch (Exception e) {}
	}
	
	return getDefaultTargetUrl();
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:30,代碼來源:UniTimeAuthenticationSuccessHandler.java

示例9: getSavedRequestUrl

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
/**
 * Ritorna la richiesta che era stata salvata da Spring Security prima del login, bloccata perchè l'utente non era autenticato
 * @return la url originale completa di http://, oppure null se non c'è in sessione
 */
public String getSavedRequestUrl() {
	SavedRequest savedRequest = (SavedRequest) httpSession.getAttribute(SAVED_REQUEST);
	if (savedRequest!=null) {
		return savedRequest.getRedirectUrl();
	}
	log.debug("No saved request found in session");
	return null;
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:13,代碼來源:YadaSecurityUtil.java

示例10: extractOriginalUrl

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
private String extractOriginalUrl(NativeWebRequest request) {
	HttpServletRequest nativeReq = request.getNativeRequest(HttpServletRequest.class);
	HttpServletResponse nativeRes = request.getNativeResponse(HttpServletResponse.class);
	SavedRequest saved = requestCache.getRequest(nativeReq, nativeRes);
	if (saved == null) {
		return null;
	}
	requestCache.removeRequest(nativeReq, nativeRes);
	removeAutheticationAttributes(nativeReq.getSession(false));
	return saved.getRedirectUrl();
}
 
開發者ID:Itema-as,項目名稱:dawn-marketplace-server,代碼行數:12,代碼來源:SimpleSignInAdapter.java

示例11: loginUsrView

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
/**
 * 로그인 화면으로 들어간다
 * 
 * @param targetUrl
 * @param loginVO
 */ 
@RequestMapping(value = "/uat/uia/loginUsr.do")
public String loginUsrView(
		HttpServletRequest request, 
		@RequestParam(value="targetUrl", required=false) String targetUrl,
		@ModelAttribute LoginVO loginVO, 
		HttpServletResponse response,
		ModelMap model) {

	if (ComponentChecker.hasComponent("mberManageService")) {
		model.addAttribute("useMemberManage", "true");
	}

	// 접속 기기에 따라서 모바일용/일반웹용 처음 페이지를 다르게 호출한다.
	String requestUrl = null;
	SavedRequest savedRequest = requestCache.getRequest(request, response);
	if ( targetUrl != null ) {
   		model.addAttribute("targetUrl", targetUrl);
   		LOG.debug("targetUrl = " + targetUrl);
   		
       	requestUrl = targetUrl;
       } else if( savedRequest != null ) {
       	requestUrl = savedRequest.getRedirectUrl();
       	LOG.debug("savedRequestUrl = " + requestUrl);

       } else  {
       	requestUrl = request.getRequestURI();
       }
       
	if( requestUrl.startsWith("http://m.aramsoft.co.kr") 
		|| 	requestUrl.indexOf(".mdo") != -1 ) {
   		return "aramframework/mbl/uat/uia/LoginUsr";
   	} else {
       	return "aramframework/com/uat/uia/LoginUsr";
   	}
}
 
開發者ID:aramsoft,項目名稱:aramcomp,代碼行數:42,代碼來源:LoginController.java

示例12: getRedirectUrl

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
protected String getRedirectUrl(HttpServletRequest request) {
  HttpSession session = request.getSession(false);
  if(session != null) {
      SavedRequest savedRequest = (SavedRequest) session.getAttribute(SpringInternals.SAVED_REQUEST);
      if(savedRequest != null) {
          return savedRequest.getRedirectUrl();
      }
  }
  return null;
}
 
開發者ID:opendatakit,項目名稱:aggregate,代碼行數:11,代碼來源:CommonServletBase.java

示例13: onAuthenticationSuccess

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws ServletException, IOException {
    SavedRequest savedRequest = requestCache.getRequest(request, response);

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

        return;
    }

    // fall back to SimpleUrl actions only if no targetUrlParameter
    if (savedRequest == null) {
        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);
}
 
開發者ID:opendatakit,項目名稱:aggregate,代碼行數:28,代碼來源:TargetUrlRequestAwareAuthenticationSuccessHandler.java

示例14: getRedirectUrl

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
private String getRedirectUrl()
{
    String redirectUrl = null;

    HttpSession session = ((ServletWebRequest) RequestCycle.get().getRequest())
            .getContainerRequest().getSession(false);
    if (session != null) {
        SavedRequest savedRequest = (SavedRequest) session
                .getAttribute("SPRING_SECURITY_SAVED_REQUEST");
        if (savedRequest != null) {
            redirectUrl = savedRequest.getRedirectUrl();
        }
    }

    // There is some kind of bug that logs the user out again if the redirect page is
    // the context root and if that does not end in a slash. To avoid this, we add a slash
    // here. This is rather a hack, but I have no idea why this problem occurs. Figured this
    // out through trial-and-error rather then by in-depth debugging.
    String baseUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(""));
    if (baseUrl.equals(redirectUrl)) {
        redirectUrl += "/";
    }

    // In case there was a URL fragment in the original URL, append it again to the redirect
    // URL.
    if (redirectUrl != null && isNotBlank(form.urlfragment)) {
        redirectUrl += "#" + form.urlfragment;
    }

    return redirectUrl;
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:32,代碼來源:LoginPage.java

示例15: getTargetUrl

import org.springframework.security.web.savedrequest.SavedRequest; //導入方法依賴的package包/類
private String getTargetUrl(HttpServletRequest request, HttpServletResponse response) {
    SavedRequest savedRequest = requestCache.getRequest(request, response);
    if (savedRequest == null || WebUtils.isAjax(savedRequest)) {
        return "/";
    }
    requestCache.removeRequest(request, response);
    return savedRequest.getRedirectUrl();
}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:9,代碼來源:AjaxAuthenticationSuccessHandler.java


注:本文中的org.springframework.security.web.savedrequest.SavedRequest.getRedirectUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。