I've got a spring MVC app that uses spring security and most of the time calling:
Will give me back the currently logged in user. However, I have come across some cases where the Authentication object is null and the only way I can access the logged in user is by going through the session like so:Code:(XactAnalysisUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
This is kind of a hacky way of doing it and I wanted to know if anyone can tell me why the securityContext doesn't get populated in certain cases? The only controller that currently doesn't work is my AjaxController which handles any ajax calls from the jsp pages and mostly returns json to jquery ajax calls. Thanks for any help.Code:((SecurityContext)session.getAttribute("SPRING_SECURITY_CONTEXT")).getAuthentication().getPrincipal();


Reply With Quote
