Set a redirect into a custom Authentication Failure Handler with Spring -


Which way to set a redirect in a Custom AuthenticationFailureHandler in the spring?

Is it possible call for a controller

is the code like this:

  @Component public class MyAuthenticationFailureHandler SimpleUrlAuthenticationFailureHandler {@Override Public Zero onAuthenticationFailure (HttpServletRequest extends request, HttpServletResponse response, AuthenticationException exception) IOException, ServletException {super.onAuthenticationFailure (request, response, exception) throws; If (exception.getClass () .isAssignableFrom (CustomUsernameNotFoundException.class)) {// TODO Set Redirection}}}  

You are calling super.onAuthenticationFailure , which will allow a redirect for the configured URL. The response is already committed and you can not decide to redirect somewhere else.

You can configure SimpleUrlAuthenticationFailureHandler to redirect to a URL and if you are not going to redirect only yourself to one of the super method calls

Alternatively, applying directly to AuthenticationFailureHandler and applying all the arguments you want in the failure method. Once things like to avoid getting beyond a certain level of complexity, if one (one condition) {

 // Redirect to IDP} Other Redirects on the {// registration page}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -