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.ApplicationEvent
An 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 SecurityContext
getNewContext()
Get theSecurityContext
set on theSecurityContextHolder
as of this eventSecurityContext
getOldContext()
Get theSecurityContext
set on theSecurityContextHolder
immediately previous to this eventboolean
isCleared()
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_CONTEXT
for 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 theSecurityContext
set on theSecurityContextHolder
immediately previous to this event- Returns:
- the previous
SecurityContext
-
getNewContext
public 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
-
-