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
FieldsFields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionSecurityContextChangedEvent(Supplier<SecurityContext> oldContext, Supplier<SecurityContext> newContext) Construct an eventSecurityContextChangedEvent(SecurityContext oldContext, SecurityContext newContext) Construct an event -
Method Summary
Modifier and TypeMethodDescriptionGet theSecurityContextset on theSecurityContextHolderas of this eventGet theSecurityContextset on theSecurityContextHolderimmediately previous to this eventbooleanSay whether the event is a context-clearing event.Methods inherited from class org.springframework.context.ApplicationEvent
getTimestampMethods 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_CONTEXTfor 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 theSecurityContextset on theSecurityContextHolderimmediately previous to this event- Returns:
- the previous
SecurityContext
-
getNewContext
Get theSecurityContextset on theSecurityContextHolderas 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:
trueif the new context isNO_CONTEXT- Since:
- 5.8
-