The SecurityContextHolder in Spring Security has three operation modes that determine how and where the SecurityContext is stored per thread/request:
MODE_THREADLOCAL (Default)SecurityContext in a ThreadLocal variable.java
CopyEdit
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_THREADLOCAL);
MODE_INHERITABLETHREADLOCALSecurityContext in an InheritableThreadLocal.SecurityContext.java
CopyEdit
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
MODE_GLOBALSecurityContext in a static global variable (singleton).