Class SecurityContextChangedEvent
- java.lang.Object
-
- java.util.EventObject
-
- org.springframework.context.ApplicationEvent
-
- org.springframework.security.core.context.SecurityContextChangedEvent
-
- All Implemented Interfaces:
java.io.Serializable
public class SecurityContextChangedEvent extends org.springframework.context.ApplicationEventAn event that represents a change inSecurityContext- Since:
- 5.6
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Supplier<SecurityContext>NO_CONTEXT
-
Constructor Summary
Constructors Constructor Description SecurityContextChangedEvent(java.util.function.Supplier<SecurityContext> oldContext, java.util.function.Supplier<SecurityContext> newContext)Construct an eventSecurityContextChangedEvent(SecurityContext oldContext, SecurityContext newContext)Construct an event
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecurityContextgetNewContext()Get theSecurityContextset on theSecurityContextHolderas of this eventSecurityContextgetOldContext()Get theSecurityContextset on theSecurityContextHolderimmediately previous to this eventbooleanisCleared()Say whether the event is a context-clearing event.
-
-
-
Field Detail
-
NO_CONTEXT
public static final java.util.function.Supplier<SecurityContext> NO_CONTEXT
-
-
Constructor Detail
-
SecurityContextChangedEvent
public SecurityContextChangedEvent(java.util.function.Supplier<SecurityContext> oldContext, java.util.function.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
public SecurityContextChangedEvent(SecurityContext oldContext, SecurityContext newContext)
Construct an event- Parameters:
oldContext- the old security contextnewContext- the new security context
-
-
Method Detail
-
getOldContext
public SecurityContext getOldContext()
Get theSecurityContextset on theSecurityContextHolderimmediately previous to this event- Returns:
- the previous
SecurityContext
-
getNewContext
public 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
-
-