Class SecurityContextChangedEvent
java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.security.core.context.SecurityContextChangedEvent
- All Implemented Interfaces:
Serializable
public class SecurityContextChangedEvent
extends org.springframework.context.ApplicationEvent
An event that represents a change in
SecurityContext
- Since:
- 5.6
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionSecurityContextChangedEvent
(Supplier<SecurityContext> oldContext, Supplier<SecurityContext> newContext) Construct an eventSecurityContextChangedEvent
(SecurityContext oldContext, SecurityContext newContext) Construct an event -
Method Summary
Modifier and TypeMethodDescriptionGet theSecurityContext
set on theSecurityContextHolder
as of this eventGet theSecurityContext
set on theSecurityContextHolder
immediately previous to this eventboolean
Say whether the event is a context-clearing event.Methods inherited from class org.springframework.context.ApplicationEvent
getTimestamp
Methods inherited from class java.util.EventObject
getSource, toString
-
Field Details
-
NO_CONTEXT
-
-
Constructor Details
-
SecurityContextChangedEvent
public SecurityContextChangedEvent(Supplier<SecurityContext> oldContext, Supplier<SecurityContext> newContext) Construct an event- Parameters:
oldContext
- the old security contextnewContext
- the new security context, useNO_CONTEXT
for if the context is cleared- Since:
- 5.8
-
SecurityContextChangedEvent
Construct an event- Parameters:
oldContext
- the old security contextnewContext
- the new security context
-
-
Method Details
-
getOldContext
Get theSecurityContext
set on theSecurityContextHolder
immediately previous to this event- Returns:
- the previous
SecurityContext
-
getNewContext
Get theSecurityContext
set on theSecurityContextHolder
as of this event- Returns:
- the current
SecurityContext
-
isCleared
public boolean isCleared()Say whether the event is a context-clearing event.This method is handy for avoiding looking up the new context to confirm it is a cleared event.
- Returns:
true
if the new context isNO_CONTEXT
- Since:
- 5.8
-