I have a custom UserDetails implementation that has a shopping cart property.
class MyUserDetails implement UserDetails {
private Cart cart;
// getters & setters + other properties....
}
I want anonymous users to be a instance of MyUserDetails too, so far I have gotten it working otherwise, but all anonymousUsers have the same shopping cart!
@Override
protected void configure(HttpSecurity http) throws Exception {
MyUserDetails anonymousUser = new MyUserDetails();
anonymousUser.setUsername("anonymousUser");
http.anonymous().principal(anonymousUser);
...
}
How would I be able to return a new instance of MyUserDetails for anonymous users for each session?