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


Java DefaultRedirectStrategy.sendRedirect方法代碼示例

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


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

示例1: commence

import org.springframework.security.web.DefaultRedirectStrategy; //導入方法依賴的package包/類
@Override
  public void commence(HttpServletRequest request, HttpServletResponse response,
      AuthenticationException authException) throws IOException, ServletException {

//    if (LOG.isDebugEnabled()) {
//      LOG.debug("Redirigiendo a pantalla de login: " + LOGIN_FORM_URL);
//    }

    ContentNegotiationStrategy negotiationStrategy = new HeaderContentNegotiationStrategy();
    MediaTypeRequestMatcher matcher =
        new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
    matcher.setUseEquals(false);

    if (matcher.matches(request)) {
      DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
      redirectStrategy.setContextRelative(false);
      redirectStrategy.sendRedirect(request, response, LOGIN_FORM_URL);
    } else {
      response.sendError(HttpServletResponse.SC_FORBIDDEN);
    }
  }
 
開發者ID:DISID,項目名稱:springlets,代碼行數:22,代碼來源:SpringletsSecurityWebAuthenticationEntryPoint.java

示例2: handle

import org.springframework.security.web.DefaultRedirectStrategy; //導入方法依賴的package包/類
@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
    AccessDeniedException accessDeniedException) throws IOException, ServletException {

  ContentNegotiationStrategy negotiationStrategy = new HeaderContentNegotiationStrategy();
  MediaTypeRequestMatcher matcher =
      new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
  matcher.setUseEquals(false);

  if (matcher.matches(request)) {
    DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
    redirectStrategy.setContextRelative(false);
    redirectStrategy.sendRedirect(request, response, "/errores/403");
  } else {
    response.sendError(HttpServletResponse.SC_FORBIDDEN);

  }

}
 
開發者ID:DISID,項目名稱:springlets,代碼行數:20,代碼來源:SpringletsSecurityWebAccessDeniedHandlerImpl.java

示例3: onAuthenticationFailure

import org.springframework.security.web.DefaultRedirectStrategy; //導入方法依賴的package包/類
@Override
   public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
	if(exception instanceof UsernameNotFoundException
		&& exception.getAuthentication() instanceof OpenIDAuthenticationToken
           && ((OpenIDAuthenticationToken)exception.getAuthentication()).getStatus().equals(OpenIDAuthenticationStatus.SUCCESS)) {
		
		OpenIDAuthenticationToken token = (OpenIDAuthenticationToken)exception.getAuthentication();
		String url = token.getIdentityUrl();
		User user = createTemporaryUser(token, url);
		request.getSession(true).setAttribute(ModelKeys.NEW_USER, user);

		DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
		log.info("Redirecting to new user account creation page");
		super.setRedirectStrategy(redirectStrategy);
		redirectStrategy.sendRedirect(request, response, "/"+ViewNames.CREATE_ACCOUNT_PAGE);
		return;
	} else {
		super.onAuthenticationFailure(request, response, exception);
	}
}
 
開發者ID:apache,項目名稱:rave,代碼行數:21,代碼來源:OpenIDAuthenticationFailureHandler.java

示例4: redirectToSuccess

import org.springframework.security.web.DefaultRedirectStrategy; //導入方法依賴的package包/類
private void redirectToSuccess(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
    OpenIDAuthenticationToken openIDAuthentication = getOpenIdAuthenticationToken(exception);
    addOpenIdAttributesToSession(request, openIDAuthentication);
    SecurityContext securityContext = SecurityContextHolder.getContext();
    securityContext.setAuthentication(openIDAuthentication);
    HttpSession session = request.getSession(true);
    session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext);
    redirectStrategy.sendRedirect(request, response, "/");
}
 
開發者ID:dice-group,項目名稱:QRTool,代碼行數:12,代碼來源:OpenIdAuthenticationFailureHandler.java

示例5: redirectToOpenIdRegistrationUrl

import org.springframework.security.web.DefaultRedirectStrategy; //導入方法依賴的package包/類
private void redirectToOpenIdRegistrationUrl(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
    addOpenIdAttributesToSession(request, getOpenIdAuthenticationToken(exception));
    redirectStrategy.sendRedirect(request, response, openIdRegistrationUrl);
}
 
開發者ID:pillingworthz,項目名稱:ifictionary,代碼行數:7,代碼來源:OpenIDAuthenticationFailureHandler.java


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