Using Spring SecurityContextPersistenceFilter with Vaadin

I’m using Spring Security with my Vaadin application. For the authentication process I use

Authentication request = new UsernamePasswordAuthenticationToken(name, password); Authentication result = userAuthenticationManager.authenticate(request); SecurityContextHolder.getContext().setAuthentication(result); but when calling

SecurityContextHolder.getContext().getAuthentication().getPrincipal(); I get a Nullpointer-Exception most times. So I know I have to store the SecurityContext between the requests which can be done by using the SecurityContextPersistenceFilter. But unfortunatley I have not found any examples on how to do that.
I would be glad if someone could give me a hint on how to accomplish that. (My setup does not use a web.xml or security.xml)

Kind regards


Have you checked this excellent demo by Petter Holmström

Check also the blog post related to the topic

Tahnks very much! This solved my problem!