Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
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