本文整理匯總了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);
}
}
示例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);
}
}
示例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);
}
}
示例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, "/");
}
示例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);
}