The requirement is that when the JSP page is submitted with action as "test/login",then below method will call and it check the validity and if it success, it must redirect to CustomSuccess hanlder, but it is not working.
Controller:
@RequestMapping("test/login")
public String login(Map<String, Object> model, HttpServletRequest request) {
String userName = (String) request.getParameter("username");
String password = (String) request.getParameter("password");
Authentication authentication =authenticationProvider.authenticate(new UsernamePasswordAuthenticationToken(userName, password));
}
Configuration:
protected void configure(HttpSecurity http) throws Exception {
.authorizeRequests()
.antMatchers("/test/**"))
.permitAll()
.and()
.formLogin()
.loginPage("/login")
.failureHandler(mainSuccessHandler)
.permitAll()
}
Handler:
@Bean(name = "mainSuccessHandler")
public AuthenticationSuccessHandler mainSuccessHandler(
@Qualifier("defaultSuccessHandler") AuthenticationSuccessHandler defaultSuccessHandler
CustomAuthenticationSuccessHandler result = new CustomAuthenticationSuccessHandler();
result.addAuthenticationFailureHandler(anyRefererRequestMather(), defaultSuccessHandler);
return result;
}