org.springframework.security.web.RedirectStrategy Java Examples
The following examples show how to use
org.springframework.security.web.RedirectStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomAuthenticationFailureHandler.java From spring-boot with Apache License 2.0 | 5 votes |
/** * 打印必要的错误信息后,继续执行。spring security 出现如下异常,控制台不打印信息,无法指定发生了哪种类型的错误 * * @param request * @param response * @param exception * @throws IOException * @throws ServletException */ @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { log.error("spring security Authentication Fail : {}", exception.getMessage()); // spring security 不打印异常信息,无法定位错误,这里打印出来 // 不打印,通过 下面的 sendRedirect 传递信息 // exception.printStackTrace(); RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); redirectStrategy.sendRedirect(request, response, "/myerror?error=" + exception.getMessage()); setDefaultFailureUrl("/myerror?error" + exception.getMessage()); // setRedirectStrategy(redirectStrategy); // //根据错误情况,做不同的处理 // //也可以设置 setDefaultFailureUrl("/url3"); 进行跳转 // if (exception.getClass().isAssignableFrom(UsernameNotFoundException.class)) { // log.info("用户名没找到"); // // setDefaultFailureUrl("/url3"); // } else if (exception.getClass().isAssignableFrom(DisabledException.class)) { // log.info("用户无效"); // // setDefaultFailureUrl("/url3"); // } else if (exception.getClass().isAssignableFrom(BadCredentialsException.class)) { // log.info("用户无效或被锁定"); // // setDefaultFailureUrl("/url1"); // } else if (exception.getClass().isAssignableFrom(SessionAuthenticationException.class)) { // log.info("登录会话过多"); // exception.printStackTrace(); // setDefaultFailureUrl("/url3"); // } else if (exception.getClass().isAssignableFrom(InvalidCookieException.class)) { // log.info("RememberMe 异常 ,cookies 失效或格式不对"); // } //继续按照默认的流程执行,根据错误情况,进行跳转 // super.onAuthenticationFailure(request, response, exception); }
Example #2
Source File: TwoFactorAuthenticationFilter.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
public TwoFactorAuthenticationFilter( AuthenticationSettings authenticationSettings, TwoFactorAuthenticationService twoFactorAuthenticationService, RedirectStrategy redirectStrategy, UserAccountService userAccountService) { this.authenticationSettings = requireNonNull(authenticationSettings); this.twoFactorAuthenticationService = requireNonNull(twoFactorAuthenticationService); this.redirectStrategy = requireNonNull(redirectStrategy); this.userAccountService = requireNonNull(userAccountService); }
Example #3
Source File: CustomAuthenticationFailureHandler.java From oauth-server with Apache License 2.0 | 5 votes |
@Override public void onAuthenticationFailure( HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { String username = request.getParameter("username"); HttpSession session = request.getSession(false); if (session != null) { session.setAttribute("username", username); session.setAttribute("SPRING_SECURITY_LAST_EXCEPTION", exception.getMessage()); if (exception instanceof CustomAuthenticationException) { session.setAttribute("SPRING_SECURITY_LAST_EXCEPTION_PARAMS", ((CustomAuthenticationException) exception).getParameters()); } } String message = null; if (exception != null) { message = exception.getMessage(); } UserE user = userService.queryByLoginField(username); if (user != null && LoginException.USERNAME_NOT_FOUND_OR_PASSWORD_IS_WRONG.value().equalsIgnoreCase(message)) { loginRecord.loginError(user.getId()); } RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); redirectStrategy.sendRedirect(request, response, loginPath + "?username=" + username); }
Example #4
Source File: LoginFailuresCountingHandler.java From recaptcha-spring-boot-starter with Apache License 2.0 | 5 votes |
@Override public void setRedirectStrategy(RedirectStrategy redirectStrategy) { if (!RecaptchaAwareRedirectStrategy.class.isAssignableFrom(redirectStrategy.getClass())) { throw new IllegalArgumentException("Invalid redirect strategy. Redirect strategy must be an instance of " + RecaptchaAwareRedirectStrategy.class.getName() + " but is " + redirectStrategy); } super.setRedirectStrategy(redirectStrategy); }
Example #5
Source File: PlatformAuthenticationSuccessHandler.java From abixen-platform with GNU Lesser General Public License v2.1 | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #6
Source File: Pac4jExceptionFilter.java From artifact-listener with Apache License 2.0 | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #7
Source File: MySimpleUrlAuthenticationSuccessHandler.java From tutorials with MIT License | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #8
Source File: MySimpleUrlAuthenticationSuccessHandler.java From tutorials with MIT License | 4 votes |
public void setRedirectStrategy(RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #9
Source File: MySimpleUrlAuthenticationSuccessHandler.java From tutorials with MIT License | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #10
Source File: MySimpleUrlAuthenticationSuccessHandler.java From tutorials with MIT License | 4 votes |
public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #11
Source File: MySimpleUrlAuthenticationSuccessHandler.java From tutorials with MIT License | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #12
Source File: MySimpleUrlAuthenticationSuccessHandler.java From tutorials with MIT License | 4 votes |
public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #13
Source File: MolgenisChangePasswordFilter.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
public MolgenisChangePasswordFilter(UserService userService, RedirectStrategy redirectStrategy) { this.userService = userService; this.redirectStrategy = redirectStrategy; }
Example #14
Source File: MolgenisWebAppSecurityConfig.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
@Bean public RedirectStrategy redirectStrategy() { return new DefaultRedirectStrategy(); }
Example #15
Source File: WallRideSecurityConfiguration.java From wallride with Apache License 2.0 | 4 votes |
@Override protected void configure(HttpSecurity http) throws Exception { RedirectStrategy redirectStrategy = new BlogLanguageRedirectStrategy(); SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setRedirectStrategy(redirectStrategy); successHandler.setDefaultTargetUrl("/"); SimpleUrlAuthenticationFailureHandler failureHandler = new SimpleUrlAuthenticationFailureHandler("/login?failed"); failureHandler.setRedirectStrategy(redirectStrategy); SimpleUrlLogoutSuccessHandler logoutSuccessHandler = new SimpleUrlLogoutSuccessHandler(); logoutSuccessHandler.setRedirectStrategy(redirectStrategy); logoutSuccessHandler.setDefaultTargetUrl("/"); // @formatter:off http.antMatcher("/**") .authorizeRequests() .accessDecisionManager(accessDecisionManager) // .expressionHandler(securityExpressionHandler) .antMatchers("/settings/**").hasRole("VIEWER") .antMatchers("/comments/**").hasRole("VIEWER") .and() .formLogin() .loginPage("/login").permitAll() .loginProcessingUrl("/login") .successHandler(successHandler) .failureHandler(failureHandler) .and() .logout() .logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET")) .logoutSuccessHandler(logoutSuccessHandler) .and() .rememberMe() .tokenRepository(persistentTokenRepository) .and() .headers() .frameOptions().disable() .cacheControl().disable() .httpStrictTransportSecurity().disable() .and() .csrf() .disable() .exceptionHandling() .accessDeniedPage("/login"); // @formatter:on }
Example #16
Source File: PlatformAuthenticationSuccessHandler.java From abixen-platform with GNU Lesser General Public License v2.1 | 4 votes |
public void setRedirectStrategy(RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #17
Source File: MySimpleUrlAuthenticationSuccessHandler.java From spring-boot with Apache License 2.0 | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #18
Source File: MySimpleUrlAuthenticationSuccessHandler.java From spring-boot with Apache License 2.0 | 4 votes |
public void setRedirectStrategy(final RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #19
Source File: CustomAuthenticationSuccessHandler.java From spring-boot with Apache License 2.0 | 4 votes |
public void setRedirectStrategy(RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #20
Source File: CustomAuthenticationSuccessHandler.java From spring-boot with Apache License 2.0 | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return redirectStrategy; }
Example #21
Source File: SecurityConfiguration.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
@Bean public RedirectStrategy redirectStrategy() { return new XForwardedAwareRedirectStrategy(); }
Example #22
Source File: WebSecurityConfig.java From jeesupport with MIT License | 4 votes |
@Bean public RedirectStrategy redirectStrategy(){ return new DefaultRedirectStrategy(); }
Example #23
Source File: MySimpleUrlAuthenticationFailureHandler.java From springboot-security-wechat with Apache License 2.0 | 4 votes |
protected RedirectStrategy getRedirectStrategy() { return this.redirectStrategy; }
Example #24
Source File: MySimpleUrlAuthenticationFailureHandler.java From springboot-security-wechat with Apache License 2.0 | 4 votes |
public void setRedirectStrategy(RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #25
Source File: RedirectAuthenticationFailureHandler.java From pizzeria with MIT License | 4 votes |
public void setRedirectStrategy(RedirectStrategy redirectStrategy) { this.redirectStrategy = redirectStrategy; }
Example #26
Source File: RedirectAuthenticationFailureHandler.java From pizzeria with MIT License | 4 votes |
public RedirectStrategy getRedirectStrategy() { return redirectStrategy; }