Class SecurityContextChannelInterceptor
java.lang.Object
org.springframework.security.messaging.context.SecurityContextChannelInterceptor
- All Implemented Interfaces:
- org.springframework.messaging.support.ChannelInterceptor,- org.springframework.messaging.support.ExecutorChannelInterceptor
public final class SecurityContextChannelInterceptor
extends Object
implements org.springframework.messaging.support.ExecutorChannelInterceptor, org.springframework.messaging.support.ChannelInterceptor
 Creates a ExecutorChannelInterceptor that will obtain the
 Authentication from the specified Message.getHeaders().
 
- Since:
- 4.0
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new instance using the header of the nameSimpMessageHeaderAccessor.USER_HEADER.SecurityContextChannelInterceptor(String authenticationHeaderName) Creates a new instance that uses the specified header to obtain theAuthentication.
- 
Method SummaryModifier and TypeMethodDescriptionvoidafterMessageHandled(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler, Exception ex) voidafterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, Exception ex) org.springframework.messaging.Message<?>beforeHandle(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler) org.springframework.messaging.Message<?>preSend(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel) voidsetAnonymousAuthentication(Authentication authentication) Allows setting the Authentication used for anonymous authentication.voidMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.messaging.support.ChannelInterceptorafterReceiveCompletion, postReceive, postSend, preReceive
- 
Constructor Details- 
SecurityContextChannelInterceptorpublic SecurityContextChannelInterceptor()Creates a new instance using the header of the nameSimpMessageHeaderAccessor.USER_HEADER.
- 
SecurityContextChannelInterceptorCreates a new instance that uses the specified header to obtain theAuthentication.- Parameters:
- authenticationHeaderName- the header name to obtain the- Authentication. Cannot be null.
 
 
- 
- 
Method Details- 
setAnonymousAuthenticationAllows setting the Authentication used for anonymous authentication. Default is:new AnonymousAuthenticationToken("key", "anonymous", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));- Parameters:
- authentication- the Authentication used for anonymous authentication. Cannot be null.
 
- 
preSendpublic org.springframework.messaging.Message<?> preSend(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel) - Specified by:
- preSendin interface- org.springframework.messaging.support.ChannelInterceptor
 
- 
afterSendCompletionpublic void afterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, Exception ex) - Specified by:
- afterSendCompletionin interface- org.springframework.messaging.support.ChannelInterceptor
 
- 
beforeHandlepublic org.springframework.messaging.Message<?> beforeHandle(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler) - Specified by:
- beforeHandlein interface- org.springframework.messaging.support.ExecutorChannelInterceptor
 
- 
afterMessageHandledpublic void afterMessageHandled(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler, Exception ex) - Specified by:
- afterMessageHandledin interface- org.springframework.messaging.support.ExecutorChannelInterceptor
 
- 
setSecurityContextHolderStrategy
 
-