Spring Security AuthenticationSuccessHandler空请求对象

时间:2018-10-09 16:11:49

标签: spring security

我已经配置了spring安全性,用于使用AuthenticationSuccessHandler对android应用程序进行身份验证,以添加如下所示的其他参数

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {

    User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    com.icloud.micro.mongo.model.User userSession = userRepository.findByUsername(user.getUsername());
    HttpSession session = request.getSession();
    session.setAttribute("user", userSession);
    session.setAttribute("username", user.getUsername());
    System.out.println("USERA "+request.getCookies().clone()[0].getName());//Debug Line

    redirectStrategy.sendRedirect(request, response, "/rest/test");
}

当我通过改型发送卷曲请求或请求时,调试行会给我NullPointerException,但在邮递员请求中工作正常,并输出JSESSIONID作为结果。

任何人都可以告诉我此请求失败的原因。

0 个答案:

没有答案