未验证 提交 c572b4b2 编写于 作者: Z zhangjidi2016 提交者: GitHub

[ISSUE #1409] Fix the bug when use queryMsgByKey or queryMsgByUniqueKey...

[ISSUE #1409] Fix the bug when use queryMsgByKey or queryMsgByUniqueKey command in aclEnable = true (#1756)
上级 dd943622
...@@ -27,6 +27,7 @@ import org.apache.rocketmq.acl.common.AclUtils; ...@@ -27,6 +27,7 @@ import org.apache.rocketmq.acl.common.AclUtils;
import org.apache.rocketmq.acl.common.Permission; import org.apache.rocketmq.acl.common.Permission;
import org.apache.rocketmq.acl.common.SessionCredentials; import org.apache.rocketmq.acl.common.SessionCredentials;
import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.AclConfig;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.PlainAccessConfig; import org.apache.rocketmq.common.PlainAccessConfig;
import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupRequestHeader; import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupRequestHeader;
...@@ -125,7 +126,8 @@ public class PlainAccessValidator implements AccessValidator { ...@@ -125,7 +126,8 @@ public class PlainAccessValidator implements AccessValidator {
// Content // Content
SortedMap<String, String> map = new TreeMap<String, String>(); SortedMap<String, String> map = new TreeMap<String, String>();
for (Map.Entry<String, String> entry : request.getExtFields().entrySet()) { for (Map.Entry<String, String> entry : request.getExtFields().entrySet()) {
if (!SessionCredentials.SIGNATURE.equals(entry.getKey())) { if (!SessionCredentials.SIGNATURE.equals(entry.getKey())
&& !MixAll.UNIQUE_MSG_QUERY_FLAG.equals(entry.getKey())) {
map.put(entry.getKey(), entry.getValue()); map.put(entry.getKey(), entry.getValue());
} }
} }
......
...@@ -30,6 +30,7 @@ import org.apache.rocketmq.acl.common.AclException; ...@@ -30,6 +30,7 @@ import org.apache.rocketmq.acl.common.AclException;
import org.apache.rocketmq.acl.common.AclUtils; import org.apache.rocketmq.acl.common.AclUtils;
import org.apache.rocketmq.acl.common.SessionCredentials; import org.apache.rocketmq.acl.common.SessionCredentials;
import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.AclConfig;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.PlainAccessConfig; import org.apache.rocketmq.common.PlainAccessConfig;
import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.header.*; import org.apache.rocketmq.common.protocol.header.*;
...@@ -183,6 +184,21 @@ public class PlainAccessValidatorTest { ...@@ -183,6 +184,21 @@ public class PlainAccessValidatorTest {
plainAccessValidator.validate(accessResource); plainAccessValidator.validate(accessResource);
} }
@Test
public void validateQueryMessageByKeyTest() {
QueryMessageRequestHeader queryMessageRequestHeader=new QueryMessageRequestHeader();
queryMessageRequestHeader.setTopic("topicC");
RemotingCommand remotingCommand = RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE,queryMessageRequestHeader);
aclClient.doBeforeRequest("", remotingCommand);
remotingCommand.addExtField(MixAll.UNIQUE_MSG_QUERY_FLAG, "false");
ByteBuffer buf = remotingCommand.encodeHeader();
buf.getInt();
buf = ByteBuffer.allocate(buf.limit() - buf.position()).put(buf);
buf.position(0);
PlainAccessResource accessResource = (PlainAccessResource) plainAccessValidator.parse(RemotingCommand.decode(buf), "192.168.1.1:9876");
plainAccessValidator.validate(accessResource);
}
@Test @Test
public void validateHeartBeatTest() { public void validateHeartBeatTest() {
HeartbeatData heartbeatData=new HeartbeatData(); HeartbeatData heartbeatData=new HeartbeatData();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册