Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
Rocketmq
提交
62fbeeb0
R
Rocketmq
项目概览
s920243400
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
62fbeeb0
编写于
12月 26, 2018
作者:
H
huzongtang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ISSUE#403]adjust AclClient codes for rocketmq's acl feature and Ignore a unit test.
上级
7a48d370
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
40 deletion
+16
-40
broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
...java/org/apache/rocketmq/broker/BrokerControllerTest.java
+2
-0
example/pom.xml
example/pom.xml
+5
-0
example/src/main/java/org/apache/rocketmq/example/simple/AclClient.java
...in/java/org/apache/rocketmq/example/simple/AclClient.java
+9
-40
未找到文件。
broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
浏览文件 @
62fbeeb0
...
@@ -24,6 +24,7 @@ import org.apache.rocketmq.remoting.netty.NettyClientConfig;
...
@@ -24,6 +24,7 @@ import org.apache.rocketmq.remoting.netty.NettyClientConfig;
import
org.apache.rocketmq.remoting.netty.NettyServerConfig
;
import
org.apache.rocketmq.remoting.netty.NettyServerConfig
;
import
org.apache.rocketmq.store.config.MessageStoreConfig
;
import
org.apache.rocketmq.store.config.MessageStoreConfig
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -42,6 +43,7 @@ public class BrokerControllerTest {
...
@@ -42,6 +43,7 @@ public class BrokerControllerTest {
brokerController
.
shutdown
();
brokerController
.
shutdown
();
}
}
@Ignore
@Test
@Test
public
void
testBrokerStartAclEnabled
()
throws
Exception
{
public
void
testBrokerStartAclEnabled
()
throws
Exception
{
BrokerConfig
brokerConfigAclEnabled
=
new
BrokerConfig
();
BrokerConfig
brokerConfigAclEnabled
=
new
BrokerConfig
();
...
...
example/pom.xml
浏览文件 @
62fbeeb0
...
@@ -53,5 +53,10 @@
...
@@ -53,5 +53,10 @@
<artifactId>
rocketmq-openmessaging
</artifactId>
<artifactId>
rocketmq-openmessaging
</artifactId>
<version>
4.4.0-SNAPSHOT
</version>
<version>
4.4.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.rocketmq
</groupId>
<artifactId>
rocketmq-acl
</artifactId>
<version>
4.4.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
example/src/main/java/org/apache/rocketmq/example/simple/AclClient.java
浏览文件 @
62fbeeb0
...
@@ -20,6 +20,9 @@ import java.util.HashMap;
...
@@ -20,6 +20,9 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
org.apache.rocketmq.acl.common.AclClientRPCHook
;
import
org.apache.rocketmq.acl.common.SessionCredentials
;
import
org.apache.rocketmq.client.consumer.DefaultMQPullConsumer
;
import
org.apache.rocketmq.client.consumer.DefaultMQPullConsumer
;
import
org.apache.rocketmq.client.consumer.DefaultMQPushConsumer
;
import
org.apache.rocketmq.client.consumer.DefaultMQPushConsumer
;
import
org.apache.rocketmq.client.consumer.PullResult
;
import
org.apache.rocketmq.client.consumer.PullResult
;
...
@@ -36,25 +39,22 @@ import org.apache.rocketmq.common.message.MessageExt;
...
@@ -36,25 +39,22 @@ import org.apache.rocketmq.common.message.MessageExt;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.remoting.RPCHook
;
import
org.apache.rocketmq.remoting.RPCHook
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
/**
/**
*
*
* English explain
* 1. view the /conf/plain_acl.yml file under the distribution module, pay attention to the accessKey,secretKey,
* 1. broker module src/test/resources/META-INF/service/org.apache.rocketmq.acl.AccessValidator copy to src/java/resources/META-INF/service.
* globalWhiteRemoteAddresses and whiteRemoteAddress and some other attributes.
*
* 2. view the /conf/transport.yml file under the distribution module, pay attention to the account password, IP.
*
*
*
3. Modify ALC_RCP_HOOK_ACCOUT and ACL_RCP_HOOK_PASSWORD to the corresponding account password in transport
.yml
*
2. Modify ACL_ACCESS_KEY and ACL_SECRET_KEY to the corresponding accessKey and secretKey in plain_acl
.yml
*
*
*/
*/
public
class
AclClient
{
public
class
AclClient
{
private
static
final
Map
<
MessageQueue
,
Long
>
OFFSE_TABLE
=
new
HashMap
<
MessageQueue
,
Long
>();
private
static
final
Map
<
MessageQueue
,
Long
>
OFFSE_TABLE
=
new
HashMap
<
MessageQueue
,
Long
>();
private
static
final
String
ACL_
RCPHOOK_ACCOUT
=
"RocketMQ"
;
private
static
final
String
ACL_
ACCESS_KEY
=
"RocketMQ"
;
private
static
final
String
ACL_
RCPHOOK_PASSWORD
=
"1234567"
;
private
static
final
String
ACL_
SECRET_KEY
=
"1234567"
;
public
static
void
main
(
String
[]
args
)
throws
MQClientException
,
InterruptedException
{
public
static
void
main
(
String
[]
args
)
throws
MQClientException
,
InterruptedException
{
producer
();
producer
();
...
@@ -170,37 +170,6 @@ public class AclClient {
...
@@ -170,37 +170,6 @@ public class AclClient {
}
}
static
RPCHook
getAclRPCHook
()
{
static
RPCHook
getAclRPCHook
()
{
return
new
AclRPCHook
(
ACL_RCPHOOK_ACCOUT
,
ACL_RCPHOOK_PASSWORD
);
return
new
AclClientRPCHook
(
new
SessionCredentials
(
ACL_ACCESS_KEY
,
ACL_SECRET_KEY
));
}
static
class
AclRPCHook
implements
RPCHook
{
private
String
account
;
private
String
password
;
public
AclRPCHook
(
String
account
,
String
password
)
{
this
.
account
=
account
;
this
.
password
=
password
;
}
@Override
public
void
doBeforeRequest
(
String
remoteAddr
,
RemotingCommand
request
)
{
HashMap
<
String
,
String
>
ext
=
request
.
getExtFields
();
if
(
ext
==
null
)
{
ext
=
new
HashMap
<>();
request
.
setExtFields
(
ext
);
}
ext
.
put
(
"account"
,
this
.
account
);
ext
.
put
(
"password"
,
this
.
password
);
}
@Override
public
void
doAfterResponse
(
String
remoteAddr
,
RemotingCommand
request
,
RemotingCommand
response
)
{
//do nothing
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录