fixed bug in stack security strategy which was not removing the context correctly
This commit is contained in:
@@ -39,7 +39,7 @@ public class StackBasedSecurityContextHolderStrategy implements SecurityContextH
|
||||
|
||||
public void clearContext() {
|
||||
if (getStackForThread().size() > 0) {
|
||||
SecurityContext ctx = getStackForThread().poll();
|
||||
SecurityContext ctx = getStackForThread().removeFirst();
|
||||
logger.debug("Popped security context " + ctx);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class StackBasedSecurityContextHolderStrategy implements SecurityContextH
|
||||
public SecurityContext getContext() {
|
||||
if (getStackForThread().peek() == null) {
|
||||
logger.debug("Pushed new blank security context");
|
||||
getStackForThread().offer(new SecurityContextImpl());
|
||||
getStackForThread().addFirst(new SecurityContextImpl());
|
||||
}
|
||||
|
||||
return (SecurityContext) getStackForThread().peek();
|
||||
@@ -56,7 +56,7 @@ public class StackBasedSecurityContextHolderStrategy implements SecurityContextH
|
||||
public void setContext(SecurityContext context) {
|
||||
Assert.notNull(context, "Only non-null SecurityContext instances are permitted");
|
||||
|
||||
getStackForThread().offer(context);
|
||||
getStackForThread().addFirst(context);
|
||||
logger.debug("Pushed context " + context);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.dispatcher.DirectChannel;
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
@@ -77,9 +77,6 @@ public class SecurityContextPropagatingChannelInterceptorTests {
|
||||
channel.send(message);
|
||||
message = (StringMessage) channel.receive(0);
|
||||
MessageHeader header = message.getHeader();
|
||||
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
assertFalse("Security context header found when no security context existed.",
|
||||
header.getAttributeNames().contains(SecurityContextPropagatingChannelInterceptor.SECURITY_CONTEXT_HEADER_ATTRIBUTE));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ public class SecuredParserTests extends AbstractJUnit4SpringContextTests{
|
||||
public void testAdminRequiredForSendWithAccessGranted() {
|
||||
login("jimi", "jimispassword");
|
||||
adminRequiredForSend.send(new StringMessage("testmessage"));
|
||||
SecurityContextHolder.clearContext();
|
||||
assertNotNull("Message not received", adminRequiredForSend.receive(0));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user