public final class SecurityContextChannelInterceptor
extends org.springframework.messaging.support.ChannelInterceptorAdapter
implements org.springframework.messaging.support.ExecutorChannelInterceptor
Creates a ExecutorChannelInterceptor
that will obtain the
Authentication
from the specified Message.getHeaders()
.
Constructor and Description |
---|
SecurityContextChannelInterceptor()
Creates a new instance using the header of the name
SimpMessageHeaderAccessor.USER_HEADER . |
SecurityContextChannelInterceptor(String authenticationHeaderName)
Creates a new instance that uses the specified header to obtain the
Authentication . |
Modifier and Type | Method and Description |
---|---|
void |
afterMessageHandled(org.springframework.messaging.Message<?> message,
org.springframework.messaging.MessageChannel channel,
org.springframework.messaging.MessageHandler handler,
Exception ex) |
void |
afterSendCompletion(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) |
void |
setAnonymousAuthentication(Authentication authentication)
Allows setting the Authentication used for anonymous authentication.
|
afterReceiveCompletion, postReceive, postSend, preReceive
public SecurityContextChannelInterceptor()
SimpMessageHeaderAccessor.USER_HEADER
.public SecurityContextChannelInterceptor(String authenticationHeaderName)
Authentication
.authenticationHeaderName
- the header name to obtain the
Authentication
. Cannot be null.public void setAnonymousAuthentication(Authentication authentication)
new AnonymousAuthenticationToken("key", "anonymous", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
authentication
- the Authentication used for anonymous authentication. Cannot
be null.public org.springframework.messaging.Message<?> preSend(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)
preSend
in interface org.springframework.messaging.support.ChannelInterceptor
preSend
in class org.springframework.messaging.support.ChannelInterceptorAdapter
public void afterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, Exception ex)
afterSendCompletion
in interface org.springframework.messaging.support.ChannelInterceptor
afterSendCompletion
in class org.springframework.messaging.support.ChannelInterceptorAdapter
public org.springframework.messaging.Message<?> beforeHandle(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler)
beforeHandle
in interface org.springframework.messaging.support.ExecutorChannelInterceptor
public void afterMessageHandled(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler, Exception ex)
afterMessageHandled
in interface org.springframework.messaging.support.ExecutorChannelInterceptor