Class VaadinSecurityContextHolderStrategy
java.lang.Object
de.codecamp.vaadin.security.spring.authentication.VaadinSecurityContextHolderStrategy
- All Implemented Interfaces:
org.springframework.security.core.context.SecurityContextHolderStrategy
public class VaadinSecurityContextHolderStrategy
extends Object
implements org.springframework.security.core.context.SecurityContextHolderStrategy
A
SecurityContextHolderStrategy that also uses the current VaadinSession, if available, to determine the SecurityContext. Otherwise the
behavior is that of the default SecurityContextHolder.MODE_THREADLOCAL.
After authentication the SecurityContext is (unless configured otherwise) stored in the
HTTP session via a HttpSessionSecurityContextRepository, which can be accessed wherever
the current VaadinSession is available. However, security
contexts with an anonymous authentication are not saved and instead recreated with every request
by the AnonymousAuthenticationFilter. This means that when e.g. accessing the Vaadin UI
from a background thread no authentication would be available; Spring Security however expects
any kind of Authentication when checking access rights. For that reason the
VaadinSecurityContextStorageUIInitListener always stores the latest anonymous
authentication in the Vaadin session.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidorg.springframework.security.core.context.SecurityContextorg.springframework.security.core.context.SecurityContextvoidsetContext(org.springframework.security.core.context.SecurityContext context)
-
Constructor Details
-
VaadinSecurityContextHolderStrategy
public VaadinSecurityContextHolderStrategy()
-
-
Method Details
-
clearContext
public void clearContext()- Specified by:
clearContextin interfaceorg.springframework.security.core.context.SecurityContextHolderStrategy
-
getContext
public org.springframework.security.core.context.SecurityContext getContext()- Specified by:
getContextin interfaceorg.springframework.security.core.context.SecurityContextHolderStrategy
-
setContext
public void setContext(org.springframework.security.core.context.SecurityContext context) - Specified by:
setContextin interfaceorg.springframework.security.core.context.SecurityContextHolderStrategy
-
createEmptyContext
public org.springframework.security.core.context.SecurityContext createEmptyContext()- Specified by:
createEmptyContextin interfaceorg.springframework.security.core.context.SecurityContextHolderStrategy
-