Class SecurityContextChannelInterceptor
- java.lang.Object
- 
- org.springframework.messaging.support.ChannelInterceptorAdapter
- 
- org.springframework.security.messaging.context.SecurityContextChannelInterceptor
 
 
- 
- All Implemented Interfaces:
- org.springframework.messaging.support.ChannelInterceptor,- org.springframework.messaging.support.ExecutorChannelInterceptor
 
 public final class SecurityContextChannelInterceptor extends org.springframework.messaging.support.ChannelInterceptorAdapter implements org.springframework.messaging.support.ExecutorChannelInterceptorCreates a ExecutorChannelInterceptorthat will obtain theAuthenticationfrom the specifiedMessage.getHeaders().- Since:
- 4.0
 
- 
- 
Constructor SummaryConstructors Constructor Description SecurityContextChannelInterceptor()Creates a new instance using the header of the nameSimpMessageHeaderAccessor.USER_HEADER.SecurityContextChannelInterceptor(java.lang.String authenticationHeaderName)Creates a new instance that uses the specified header to obtain theAuthentication.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterMessageHandled(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler, java.lang.Exception ex)voidafterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, java.lang.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.- 
Methods inherited from class org.springframework.messaging.support.ChannelInterceptorAdapterafterReceiveCompletion, postReceive, postSend, preReceive
 
- 
 
- 
- 
- 
Constructor Detail- 
SecurityContextChannelInterceptorpublic SecurityContextChannelInterceptor() Creates a new instance using the header of the nameSimpMessageHeaderAccessor.USER_HEADER.
 - 
SecurityContextChannelInterceptorpublic SecurityContextChannelInterceptor(java.lang.String authenticationHeaderName) Creates a new instance that uses the specified header to obtain theAuthentication.- Parameters:
- authenticationHeaderName- the header name to obtain the- Authentication. Cannot be null.
 
 
- 
 - 
Method Detail- 
setAnonymousAuthenticationpublic void setAnonymousAuthentication(Authentication authentication) Allows 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
- Overrides:
- preSendin class- org.springframework.messaging.support.ChannelInterceptorAdapter
 
 - 
afterSendCompletionpublic void afterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, java.lang.Exception ex)- Specified by:
- afterSendCompletionin interface- org.springframework.messaging.support.ChannelInterceptor
- Overrides:
- afterSendCompletionin class- org.springframework.messaging.support.ChannelInterceptorAdapter
 
 - 
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, java.lang.Exception ex)- Specified by:
- afterMessageHandledin interface- org.springframework.messaging.support.ExecutorChannelInterceptor
 
 
- 
 
-