I have the following trouble. My spring application is configured in the following way:
Application context security
<http use-expressions="true" pattern="/ext/**" entry-point-ref="loginUrlAuthenticationEntryPoint">
//Others configuration
<session-management invalid-session-url="/sessionExpired">
</session-management>
</http>
My Controller:
@RequestMapping(value="/sessionExpired", method = RequestMethod.GET)
public String sessionExpired(ModelMap model, HttpSession session) {
return "login";
}
Now my problem is that in the method sessionExpired I should be able to differentiate some property of my user for example:
@RequestMapping(value="/sessionExpired", method = RequestMethod.GET)
public String sessionExpired(ModelMap model, HttpSession session) {
//Test1
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
MyUser u = (MyUser) authentication.getPrincipal();
//Test2
MyUser u = session.getAttribute("user");
if(u.isItalian())
return "loginA"
else
return "loginB"
return "login";
}
I think that sping security has already cleaned session,request and SecurityContextHolder. Then how can I solve this situation?