Как получить доступ к HttpServletRequest в пользовательском AuthenticationProvider. Я пытался сделать это
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
String username = (String) httpReq.getAttribute("j_username");
ИЛИ
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
HttpServletRequest httpReq = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
String username = (String) httpReq.getAttribute("j_username");
я получаю нулевое имя пользователя
но RequestContextHolder.getRequestAttributes (); возвращает ноль.
Я хочу сослаться на контекст запроса, передать его или заставить Spring сделать свое волшебство, чтобы я мог ссылаться на него.
Я также даю RequestContextListener в моем файле web.xml
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
. Я искал форум безопасности, но до сих пор ничего не нашел.
Заранее спасибо.