Using Spring SecurityContextPersistenceFilter with Vaadin

Hi,
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

Christoph

Have you checked this excellent demo by Petter Holmström

https://github.com/peholmst/SpringSecurityDemo

Check also the blog post related to the topic

https://vaadin.com/blog/-/blogs/filter-based-spring-security-in-vaadin-applications

Tahnks very much! This solved my problem!