Пользовательский бин формы входа в Spring Security Failurehandler - PullRequest
0 голосов
/ 19 сентября 2018

Версия: Spring Security 4.2.3

Мне нужны некоторые дополнительные значения, такие как «Form Action» со страницы входа в систему Jsp.Можно ли получить компонент формы "logonForm" в пользовательских SuccessHandler или FailureHandler.Я попытался Autowired, и это не помогло.Есть предложения?

Пользовательский логин JSP

 <form:form action="userLogon" commandName="logonForm" >  
 <input type="hidden" name="action" id="action"/>

FailureHandler

public class MyAppAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler  {
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
@Autowired(required=false)
@Qualifier("logonForm")
private LogonForm logonForm;

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    setUseForward(true); // ensure it is a server forward than client redirect

    if (authException != null) {
        String userId = logonForm.getUserId();

1 Ответ

0 голосов
/ 20 сентября 2018

Оказалось проще, значения полей логина были доступны из API:

String userId = request.getParameter("userId");
String action= request.getParameter("action");
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...