Message payload can no longer be set. MessageTransformer's transform() method now returns a Message (instead of void). ChannelInterceptor preSend() and postReceive() methods now return a Message instead of boolean.
This commit is contained in:
@@ -27,7 +27,7 @@ import org.springframework.security.context.SecurityContext;
|
||||
import org.springframework.security.context.SecurityContextHolder;
|
||||
|
||||
/**
|
||||
* Propagates the {@ link SecurityContext} associated with the current thread
|
||||
* Propagates the {@link SecurityContext} associated with the current thread
|
||||
* (if any) by adding it to the header of sent messages.
|
||||
*
|
||||
* @author Jonas Partner
|
||||
@@ -36,10 +36,11 @@ public class SecurityContextPropagatingChannelInterceptor extends ChannelInterce
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
|
||||
@Override
|
||||
public boolean preSend(Message<?> message, MessageChannel channel) {
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
this.setSecurityContextAttribute(message);
|
||||
return true;
|
||||
return message;
|
||||
}
|
||||
|
||||
protected void setSecurityContextAttribute(Message<?> message) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Delegates to the provided instance of {@link AccessDecisionManager} to
|
||||
* enforce the security on the send and receive calls on the {@ MessageChannel}.
|
||||
* enforce the security on the send and receive calls of the {@link MessageChannel}.
|
||||
*
|
||||
* @author Jonas Partner
|
||||
*/
|
||||
@@ -38,11 +38,13 @@ public class SecurityEnforcingChannelInterceptor extends ChannelInterceptorAdapt
|
||||
|
||||
private volatile ConfigAttributeDefinition receiveSecurityAttributes;
|
||||
|
||||
|
||||
public SecurityEnforcingChannelInterceptor(AccessDecisionManager accessDecisionManager) {
|
||||
Assert.notNull(accessDecisionManager, "AccessDecisionManager must not be null");
|
||||
this.accessDecisionManger = accessDecisionManager;
|
||||
}
|
||||
|
||||
|
||||
public ConfigAttributeDefinition getSendSecurityAttributes() {
|
||||
return this.sendSecurityAttributes;
|
||||
}
|
||||
@@ -60,9 +62,9 @@ public class SecurityEnforcingChannelInterceptor extends ChannelInterceptorAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preSend(Message<?> message, MessageChannel channel) {
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
this.checkSend(channel);
|
||||
return true;
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.Test;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.selector.MessageSelector;
|
||||
|
||||
@@ -38,6 +39,7 @@ public class ChannelInterceptorRegisteringBeanPostProcessorTests {
|
||||
|
||||
public ArrayList<String> matchAll;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
matchAll = new ArrayList<String>();
|
||||
@@ -45,6 +47,7 @@ public class ChannelInterceptorRegisteringBeanPostProcessorTests {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithAbstractMessageChannel() {
|
||||
ChannelInterceptorRegisteringBeanPostProcessor postprocessor = new ChannelInterceptorRegisteringBeanPostProcessor(
|
||||
@@ -74,25 +77,11 @@ public class ChannelInterceptorRegisteringBeanPostProcessorTests {
|
||||
}
|
||||
|
||||
|
||||
static class TestInterceptor implements ChannelInterceptor {
|
||||
|
||||
public void postReceive(Message<?> message, MessageChannel channel) {
|
||||
}
|
||||
|
||||
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
|
||||
}
|
||||
|
||||
public boolean preReceive(MessageChannel channel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean preSend(Message<?> message, MessageChannel channel) {
|
||||
return false;
|
||||
}
|
||||
private static class TestInterceptor extends ChannelInterceptorAdapter {
|
||||
}
|
||||
|
||||
|
||||
static class TestChannel extends AbstractMessageChannel {
|
||||
private static class TestChannel extends AbstractMessageChannel {
|
||||
|
||||
ChannelInterceptor channelInterceptor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user