Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
7a030209
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
Star
16139
Fork
68
代码
文件
提交
分支
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看板
提交
7a030209
编写于
10月 03, 2018
作者:
H
hujie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
accomplish
上级
9e0021db
变更
39
显示空白变更内容
内联
并排
Showing
39 changed file
with
2056 addition
and
1286 deletion
+2056
-1286
acl-plug/pom.xml
acl-plug/pom.xml
+34
-26
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AccessContralAnalysis.java
...a/org/apache/rocketmq/acl/plug/AccessContralAnalysis.java
+51
-35
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugController.java
.../java/org/apache/rocketmq/acl/plug/AclPlugController.java
+47
-21
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugServer.java
...main/java/org/apache/rocketmq/acl/plug/AclPlugServer.java
+16
-2
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingServer.java
.../java/org/apache/rocketmq/acl/plug/AclRemotingServer.java
+21
-6
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclUtils.java
.../src/main/java/org/apache/rocketmq/acl/plug/AclUtils.java
+68
-53
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/Authentication.java
...ain/java/org/apache/rocketmq/acl/plug/Authentication.java
+50
-32
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServerImpl.java
...pache/rocketmq/acl/plug/DefaultAclRemotingServerImpl.java
+46
-17
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/EmptyImplementationAclRemotingServer.java
...cketmq/acl/plug/EmptyImplementationAclRemotingServer.java
+0
-19
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/annotation/RequestCode.java
.../org/apache/rocketmq/acl/plug/annotation/RequestCode.java
+17
-1
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AclPlugEngine.java
...va/org/apache/rocketmq/acl/plug/engine/AclPlugEngine.java
+23
-5
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AuthenticationInfoManagementAclPlugEngine.java
...lug/engine/AuthenticationInfoManagementAclPlugEngine.java
+100
-67
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java
...ache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java
+55
-33
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java
...g/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java
+46
-13
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/AccessControl.java
...va/org/apache/rocketmq/acl/plug/entity/AccessControl.java
+65
-52
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/AuthenticationInfo.java
...g/apache/rocketmq/acl/plug/entity/AuthenticationInfo.java
+72
-47
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/AuthenticationResult.java
...apache/rocketmq/acl/plug/entity/AuthenticationResult.java
+56
-40
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/BorkerAccessControl.java
.../apache/rocketmq/acl/plug/entity/BorkerAccessControl.java
+649
-565
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/BorkerAccessControlTransport.java
...ocketmq/acl/plug/entity/BorkerAccessControlTransport.java
+38
-26
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParametersEntity.java
.../rocketmq/acl/plug/entity/ControllerParametersEntity.java
+33
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/LoginInfo.java
...n/java/org/apache/rocketmq/acl/plug/entity/LoginInfo.java
+77
-50
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/LoginOrRequestAccessControl.java
...rocketmq/acl/plug/entity/LoginOrRequestAccessControl.java
+43
-34
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugAccountAnalysisException.java
...q/acl/plug/exception/AclPlugAccountAnalysisException.java
+31
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugAuthenticationException.java
...mq/acl/plug/exception/AclPlugAuthenticationException.java
+30
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugException.java
.../apache/rocketmq/acl/plug/exception/AclPlugException.java
+30
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugLoginException.java
...he/rocketmq/acl/plug/exception/AclPlugLoginException.java
+31
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugRuntimeException.java
.../rocketmq/acl/plug/exception/AclPlugRuntimeException.java
+31
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugStartException.java
...he/rocketmq/acl/plug/exception/AclPlugStartException.java
+30
-0
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/AbstractNetaddressStrategy.java
...ocketmq/acl/plug/strategy/AbstractNetaddressStrategy.java
+19
-3
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/MultipleNetaddressStrategy.java
...ocketmq/acl/plug/strategy/MultipleNetaddressStrategy.java
+29
-14
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/NetaddressStrategy.java
...apache/rocketmq/acl/plug/strategy/NetaddressStrategy.java
+17
-2
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/NetaddressStrategyFactory.java
...rocketmq/acl/plug/strategy/NetaddressStrategyFactory.java
+36
-22
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/NullNetaddressStrategy.java
...he/rocketmq/acl/plug/strategy/NullNetaddressStrategy.java
+22
-7
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/OneNetaddressStrategy.java
...che/rocketmq/acl/plug/strategy/OneNetaddressStrategy.java
+26
-11
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/RangeNetaddressStrategy.java
...e/rocketmq/acl/plug/strategy/RangeNetaddressStrategy.java
+74
-59
acl-plug/src/test/java/org/apache/rocketmq/acl/plug/AccessContralAnalysisTest.java
...g/apache/rocketmq/acl/plug/AccessContralAnalysisTest.java
+6
-6
acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java
...ache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java
+5
-5
acl-plug/src/test/resources/transport.yml
acl-plug/src/test/resources/transport.yml
+13
-13
distribution/conf/transport.yml
distribution/conf/transport.yml
+19
-0
未找到文件。
acl-plug/pom.xml
浏览文件 @
7a030209
...
...
@@ -17,6 +17,14 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
rocketmq-logging
</artifactId>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
rocketmq-common
</artifactId>
</dependency>
<dependency>
<groupId>
org.yaml
</groupId>
<artifactId>
snakeyaml
</artifactId>
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AccessContralAnalysis.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
import
java.lang.reflect.Field
;
...
...
@@ -13,7 +29,7 @@ public class AccessContralAnalysis {
private
Map
<
Class
<?>,
Map
<
Integer
,
Field
>>
classTocodeAndMentod
=
new
HashMap
<>();
public
Map
<
Integer
,
Boolean
>
analysis
(
AccessControl
accessControl
)
{
public
Map
<
Integer
,
Boolean
>
analysis
(
AccessControl
accessControl
)
{
Class
<?
extends
AccessControl
>
clazz
=
accessControl
.
getClass
();
Map
<
Integer
,
Field
>
codeAndField
=
classTocodeAndMentod
.
get
(
clazz
);
if
(
codeAndField
==
null
)
{
...
...
@@ -39,7 +55,7 @@ public class AccessContralAnalysis {
try
{
while
(
it
.
hasNext
())
{
Entry
<
Integer
,
Field
>
e
=
it
.
next
();
authority
.
put
(
e
.
getKey
(),
(
Boolean
)
e
.
getValue
().
get
(
accessControl
));
authority
.
put
(
e
.
getKey
(),
(
Boolean
)
e
.
getValue
().
get
(
accessControl
));
}
}
catch
(
IllegalArgumentException
|
IllegalAccessException
e1
)
{
e1
.
printStackTrace
();
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugController.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
import
org.apache.rocketmq.acl.plug.engine.AclPlugEngine
;
import
org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine
;
import
org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity
;
import
org.apache.rocketmq.acl.plug.exception.AclPlugStartException
;
public
class
AclPlugController
{
private
ControllerParametersEntity
controllerParametersEntity
;
private
AclPlugEngine
aclPlugEngine
;
private
AclRemotingServer
aclRemotingServer
;
public
AclPlugController
(
ControllerParametersEntity
controllerParametersEntity
){
private
boolean
startSucceed
=
false
;
public
AclPlugController
(
ControllerParametersEntity
controllerParametersEntity
)
throws
AclPlugStartException
{
try
{
this
.
controllerParametersEntity
=
controllerParametersEntity
;
aclPlugEngine
=
new
PlainAclPlugEngine
(
);
aclPlugEngine
=
new
PlainAclPlugEngine
(
controllerParametersEntity
);
aclRemotingServer
=
new
DefaultAclRemotingServerImpl
(
aclPlugEngine
);
this
.
startSucceed
=
true
;
}
catch
(
Exception
e
)
{
throw
new
AclPlugStartException
(
String
.
format
(
"Start the abnormal , Launch parameters is %s"
,
this
.
controllerParametersEntity
.
toString
()),
e
);
}
}
public
AclRemotingServer
getAclRemotingServer
()
{
return
this
.
aclRemotingServer
;
}
public
void
doChannelCloseEvent
(
String
remoteAddr
)
{
aclPlugEngine
.
deleteLoginInfo
(
remoteAddr
);
}
public
boolean
isStartSucceed
()
{
return
true
;
return
startSucceed
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclPlugServer.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
public
class
AclPlugServer
{
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclRemotingServer.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationInfo
;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationResult
;
import
org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl
;
public
interface
AclRemotingServer
{
public
AuthenticationInfo
login
();
public
AuthenticationInfo
eachCheck
(
LoginOrRequestAccessControl
accessControl
);
public
AuthenticationResult
eachCheck
(
LoginOrRequestAccessControl
accessControl
);
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/AclUtils.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
import
org.apache.commons.lang3.StringUtils
;
public
class
AclUtils
{
public
static
String
[]
getAddreeStrArray
(
String
netaddress
,
String
four
)
{
String
[]
fourStrArray
=
StringUtils
.
split
(
four
.
substring
(
1
,
four
.
length
()-
1
)
,
","
);
String
address
=
netaddress
.
substring
(
0
,
netaddress
.
indexOf
(
"{"
)
);
String
[]
addreeStrArray
=
new
String
[
fourStrArray
.
length
];
for
(
int
i
=
0
;
i
<
fourStrArray
.
length
;
i
++)
{
addreeStrArray
[
i
]
=
address
+
fourStrArray
[
i
];
public
static
String
[]
getAddreeStrArray
(
String
netaddress
,
String
four
)
{
String
[]
fourStrArray
=
StringUtils
.
split
(
four
.
substring
(
1
,
four
.
length
()
-
1
),
","
);
String
address
=
netaddress
.
substring
(
0
,
netaddress
.
indexOf
(
"{"
));
String
[]
addreeStrArray
=
new
String
[
fourStrArray
.
length
];
for
(
int
i
=
0
;
i
<
fourStrArray
.
length
;
i
++)
{
addreeStrArray
[
i
]
=
address
+
fourStrArray
[
i
];
}
return
addreeStrArray
;
}
public
static
boolean
isScope
(
String
num
,
int
index
)
{
String
[]
strArray
=
StringUtils
.
split
(
num
,
"."
);
if
(
strArray
.
length
!=
4
)
{
String
[]
strArray
=
StringUtils
.
split
(
num
,
"."
);
if
(
strArray
.
length
!=
4
)
{
return
false
;
}
return
isScope
(
strArray
,
index
);
...
...
@@ -29,7 +44,7 @@ public class AclUtils {
}
for
(
int
i
=
0
;
i
<
index
;
i
++)
{
if
(
!
isScope
(
num
[
i
]))
{
if
(
!
isScope
(
num
[
i
]))
{
return
false
;
}
}
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/Authentication.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
import
org.apache.rocketmq.acl.plug.entity.AccessControl
;
...
...
@@ -8,11 +24,15 @@ import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
public
class
Authentication
{
public
boolean
authentication
(
AuthenticationInfo
authenticationInfo
,
LoginOrRequestAccessControl
loginOrRequestAccessControl
,
AuthenticationResult
authenticationResult
)
{
public
boolean
authentication
(
AuthenticationInfo
authenticationInfo
,
LoginOrRequestAccessControl
loginOrRequestAccessControl
,
AuthenticationResult
authenticationResult
)
{
int
code
=
loginOrRequestAccessControl
.
getCode
();
if
(
authenticationInfo
.
getAuthority
().
get
(
code
))
{
if
(!
authenticationInfo
.
getAuthority
().
get
(
code
))
{
authenticationResult
.
setResultString
(
String
.
format
(
"code is %d Authentication failed"
,
code
));
return
false
;
}
AccessControl
accessControl
=
authenticationInfo
.
getAccessControl
();
if
(
!(
accessControl
instanceof
BorkerAccessControl
))
{
if
(
!(
accessControl
instanceof
BorkerAccessControl
))
{
return
true
;
}
BorkerAccessControl
borker
=
(
BorkerAccessControl
)
authenticationInfo
.
getAccessControl
();
...
...
@@ -38,6 +58,4 @@ public class Authentication {
}
return
true
;
}
return
false
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/DefaultAclRemotingServerImpl.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug
;
import
org.apache.rocketmq.acl.plug.engine.AclPlugEngine
;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationInfo
;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationResult
;
import
org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl
;
import
org.apache.rocketmq.acl.plug.exception.AclPlugAuthenticationException
;
import
org.apache.rocketmq.acl.plug.exception.AclPlugLoginException
;
import
org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException
;
public
class
DefaultAclRemotingServerImpl
implements
AclRemotingServer
{
private
AclPlugEngine
aclPlugEngine
;
public
DefaultAclRemotingServerImpl
(
AclPlugEngine
aclPlugEngine
)
{
public
DefaultAclRemotingServerImpl
(
AclPlugEngine
aclPlugEngine
)
{
this
.
aclPlugEngine
=
aclPlugEngine
;
}
...
...
@@ -19,9 +39,18 @@ public class DefaultAclRemotingServerImpl implements AclRemotingServer {
}
@Override
public
AuthenticationInfo
eachCheck
(
LoginOrRequestAccessControl
accessControl
)
{
aclPlugEngine
.
eachCheckLoginAndAuthentication
(
accessControl
);
return
null
;
public
AuthenticationResult
eachCheck
(
LoginOrRequestAccessControl
accessControl
)
{
AuthenticationResult
authenticationResult
=
aclPlugEngine
.
eachCheckLoginAndAuthentication
(
accessControl
);
if
(
authenticationResult
.
getException
()
!=
null
)
{
throw
new
AclPlugRuntimeException
(
String
.
format
(
"eachCheck the inspection appear exception, accessControl data is %s"
,
accessControl
.
toString
()),
authenticationResult
.
getException
());
}
if
(
authenticationResult
.
getAccessControl
()
==
null
)
{
throw
new
AclPlugLoginException
(
String
.
format
(
"%s accessControl data is %s"
,
authenticationResult
.
getResultString
(),
accessControl
.
toString
()));
}
if
(!
authenticationResult
.
isSucceed
())
{
throw
new
AclPlugAuthenticationException
(
String
.
format
(
"%s accessControl data is %s"
,
authenticationResult
.
getResultString
(),
accessControl
.
toString
()));
}
return
authenticationResult
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/EmptyImplementationAclRemotingServer.java
已删除
100644 → 0
浏览文件 @
9e0021db
package
org.apache.rocketmq.acl.plug
;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationInfo
;
public
class
EmptyImplementationAclRemotingServer
implements
AclRemotingServer
{
@Override
public
AuthenticationInfo
login
()
{
return
null
;
}
@Override
public
AuthenticationInfo
eachCheck
()
{
// TODO Auto-generated method stub
return
null
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/annotation/RequestCode.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.annotation
;
import
java.lang.annotation.Documented
;
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AclPlugEngine.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.engine
;
import
org.apache.rocketmq.acl.plug.entity.AccessControl
;
...
...
@@ -8,9 +24,11 @@ import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
public
interface
AclPlugEngine
{
public
AuthenticationInfo
getAccessControl
(
AccessControl
accessControl
)
;
public
AuthenticationInfo
getAccessControl
(
AccessControl
accessControl
)
;
public
LoginInfo
getLoginInfo
(
AccessControl
accessControl
)
;
public
LoginInfo
getLoginInfo
(
AccessControl
accessControl
);
public
void
deleteLoginInfo
(
String
remoteAddr
);
public
AuthenticationResult
eachCheckLoginAndAuthentication
(
LoginOrRequestAccessControl
accessControl
);
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/AuthenticationInfoManagementAclPlugEngine.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.engine
;
import
java.util.HashMap
;
...
...
@@ -10,13 +26,18 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationInfo
;
import
org.apache.rocketmq.acl.plug.entity.AuthenticationResult
;
import
org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl
;
import
org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException
;
import
org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy
;
import
org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
public
abstract
class
AuthenticationInfoManagementAclPlugEngine
implements
AclPlugEngine
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
ACL_PLUG_LOGGER_NAME
);
private
Map
<
String
/**account **/
,
Map
<
String
/**netaddress**/
,
AuthenticationInfo
>>
accessControlMap
=
new
HashMap
<>();
private
Map
<
String
/** account **/
,
Map
<
String
/** netaddress **/
,
AuthenticationInfo
>>
accessControlMap
=
new
HashMap
<>();
private
AuthenticationInfo
authenticationInfo
;
...
...
@@ -26,41 +47,48 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
private
Authentication
authentication
=
new
Authentication
();
public
void
setAccessControl
(
AccessControl
accessControl
)
{
public
void
setAccessControl
(
AccessControl
accessControl
)
throws
AclPlugAccountAnalysisException
{
try
{
NetaddressStrategy
netaddressStrategy
=
netaddressStrategyFactory
.
getNetaddressStrategy
(
accessControl
);
Map
<
String
,
AuthenticationInfo
>
accessControlAddressMap
=
accessControlMap
.
get
(
accessControl
.
getAccount
());
if
(
accessControlAddressMap
==
null
)
{
Map
<
String
,
AuthenticationInfo
>
accessControlAddressMap
=
accessControlMap
.
get
(
accessControl
.
getAccount
());
if
(
accessControlAddressMap
==
null
)
{
accessControlAddressMap
=
new
HashMap
<>();
accessControlMap
.
put
(
accessControl
.
getAccount
(),
accessControlAddressMap
);
}
accessControlAddressMap
.
put
(
accessControl
.
getNetaddress
(),
new
AuthenticationInfo
(
accessContralAnalysis
.
analysis
(
accessControl
),
accessControl
,
netaddressStrategy
));
}
catch
(
Exception
e
)
{
// TODO Exception
AuthenticationInfo
authenticationInfo
=
new
AuthenticationInfo
(
accessContralAnalysis
.
analysis
(
accessControl
),
accessControl
,
netaddressStrategy
);
accessControlAddressMap
.
put
(
accessControl
.
getNetaddress
(),
authenticationInfo
);
log
.
info
(
"authenticationInfo is {}"
,
authenticationInfo
.
toString
());
}
catch
(
Exception
e
)
{
throw
new
AclPlugAccountAnalysisException
(
accessControl
.
toString
(),
e
);
}
}
public
void
setAccessControlList
(
List
<
AccessControl
>
AccessControlList
)
{
for
(
AccessControl
accessControl
:
A
ccessControlList
)
{
public
void
setAccessControlList
(
List
<
AccessControl
>
accessControlList
)
throws
AclPlugAccountAnalysisException
{
for
(
AccessControl
accessControl
:
a
ccessControlList
)
{
setAccessControl
(
accessControl
);
}
}
public
void
setNetaddressAccessControl
(
AccessControl
accessControl
)
throws
AclPlugAccountAnalysisException
{
try
{
authenticationInfo
=
new
AuthenticationInfo
(
accessContralAnalysis
.
analysis
(
accessControl
),
accessControl
,
netaddressStrategyFactory
.
getNetaddressStrategy
(
accessControl
));
log
.
info
(
"default authenticationInfo is {}"
,
authenticationInfo
.
toString
());
}
catch
(
Exception
e
)
{
throw
new
AclPlugAccountAnalysisException
(
accessControl
.
toString
(),
e
);
}
public
void
setNetaddressAccessControl
(
AccessControl
accessControl
)
{
authenticationInfo
=
new
AuthenticationInfo
(
accessContralAnalysis
.
analysis
(
accessControl
)
,
accessControl
,
netaddressStrategyFactory
.
getNetaddressStrategy
(
accessControl
));
}
public
AuthenticationInfo
getAccessControl
(
AccessControl
accessControl
)
{
AuthenticationInfo
existing
=
null
;
if
(
accessControl
.
getAccount
()
==
null
&&
authenticationInfo
!=
null
)
{
existing
=
authenticationInfo
.
getNetaddressStrategy
().
match
(
accessControl
)?
authenticationInfo:
null
;
}
else
{
if
(
accessControl
.
getAccount
()
==
null
&&
authenticationInfo
!=
null
)
{
existing
=
authenticationInfo
.
getNetaddressStrategy
().
match
(
accessControl
)
?
authenticationInfo
:
null
;
}
else
{
Map
<
String
,
AuthenticationInfo
>
accessControlAddressMap
=
accessControlMap
.
get
(
accessControl
.
getAccount
());
if
(
accessControlAddressMap
!=
null
)
{
if
(
accessControlAddressMap
!=
null
)
{
existing
=
accessControlAddressMap
.
get
(
accessControl
.
getNetaddress
());
if
(
existing
.
getAccessControl
().
getPassword
().
equals
(
accessControl
.
getPassword
()))
{
if
(
existing
.
getNetaddressStrategy
().
match
(
accessControl
))
{
if
(
existing
.
getAccessControl
().
getPassword
().
equals
(
accessControl
.
getPassword
()))
{
if
(
existing
.
getNetaddressStrategy
().
match
(
accessControl
))
{
return
existing
;
}
}
...
...
@@ -73,13 +101,18 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
@Override
public
AuthenticationResult
eachCheckLoginAndAuthentication
(
LoginOrRequestAccessControl
accessControl
)
{
AuthenticationResult
authenticationResult
=
new
AuthenticationResult
();
AuthenticationInfo
authenticationInfo
=
getAuthenticationInfo
(
accessControl
,
authenticationResult
);
if
(
authenticationInfo
!=
null
)
{
boolean
boo
=
authentication
.
authentication
(
authenticationInfo
,
accessControl
,
authenticationResult
);
authenticationResult
.
setSucceed
(
boo
);
try
{
AuthenticationInfo
authenticationInfo
=
getAuthenticationInfo
(
accessControl
,
authenticationResult
);
if
(
authenticationInfo
!=
null
)
{
boolean
boo
=
authentication
.
authentication
(
authenticationInfo
,
accessControl
,
authenticationResult
);
authenticationResult
.
setSucceed
(
boo
);
}
}
catch
(
Exception
e
)
{
authenticationResult
.
setException
(
e
);
}
return
authenticationResult
;
}
protected
abstract
AuthenticationInfo
getAuthenticationInfo
(
LoginOrRequestAccessControl
accessControl
,
AuthenticationResult
authenticationResult
);
protected
abstract
AuthenticationInfo
getAuthenticationInfo
(
LoginOrRequestAccessControl
accessControl
,
AuthenticationResult
authenticationResult
);
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/LoginInfoAclPlugEngine.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.engine
;
import
java.util.Map
;
...
...
@@ -16,16 +32,17 @@ public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagemen
@Override
public
AuthenticationInfo
getAccessControl
(
AccessControl
accessControl
)
{
AuthenticationInfo
authenticationInfo
=
super
.
getAccessControl
(
accessControl
);
if
(
authenticationInfo
!=
null
)
{
LoginInfo
loginInfo
=
new
LoginInfo
();
loginInfo
.
setAuthenticationInfo
(
authenticationInfo
);
loginInfoMap
.
put
(
accessControl
.
getRecognition
(),
loginInfo
);
}
return
authenticationInfo
;
}
public
LoginInfo
getLoginInfo
(
AccessControl
accessControl
)
{
LoginInfo
loginInfo
=
loginInfoMap
.
get
(
accessControl
.
getRecognition
());
if
(
loginInfo
==
null
)
{
getAccessControl
(
accessControl
);
if
(
loginInfo
==
null
&&
getAccessControl
(
accessControl
)
!=
null
)
{
loginInfo
=
loginInfoMap
.
get
(
accessControl
.
getRecognition
());
}
if
(
loginInfo
!=
null
)
{
...
...
@@ -34,14 +51,19 @@ public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagemen
return
loginInfo
;
}
public
void
deleteLoginInfo
(
String
remoteAddr
)
{
loginInfoMap
.
remove
(
remoteAddr
);
}
protected
AuthenticationInfo
getAuthenticationInfo
(
LoginOrRequestAccessControl
accessControl
,
AuthenticationResult
authenticationResult
)
{
protected
AuthenticationInfo
getAuthenticationInfo
(
LoginOrRequestAccessControl
accessControl
,
AuthenticationResult
authenticationResult
)
{
LoginInfo
anthenticationInfo
=
getLoginInfo
(
accessControl
);
if
(
anthenticationInfo
!=
null
)
{
if
(
anthenticationInfo
!=
null
&&
anthenticationInfo
.
getAuthenticationInfo
()
!=
null
)
{
return
anthenticationInfo
.
getAuthenticationInfo
();
}
else
{
authenticationResult
.
setResultString
(
"Login information does not exist
"
);
}
else
{
authenticationResult
.
setResultString
(
"Login information does not exist, Please check login, password, IP
"
);
}
return
null
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngine.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.engine
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
org.apache.rocketmq.acl.plug.entity.AccessControl
;
import
org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport
;
import
org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity
;
import
org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException
;
import
org.yaml.snakeyaml.Yaml
;
public
class
PlainAclPlugEngine
extends
LoginInfoAclPlugEngine
{
public
PlainAclPlugEngine
()
{
private
ControllerParametersEntity
controllerParametersEntity
;
public
PlainAclPlugEngine
(
ControllerParametersEntity
controllerParametersEntity
)
throws
AclPlugAccountAnalysisException
{
this
.
controllerParametersEntity
=
controllerParametersEntity
;
init
();
}
void
init
()
{
void
init
()
throws
AclPlugAccountAnalysisException
{
String
filePath
=
controllerParametersEntity
.
getFileHome
()
+
"/conf/transport.yml"
;
Yaml
ymal
=
new
Yaml
();
BorkerAccessControlTransport
transport
=
ymal
.
loadAs
(
PlainAclPlugEngine
.
class
.
getClassLoader
().
getResourceAsStream
(
"transport.yml"
),
BorkerAccessControlTransport
.
class
);
FileInputStream
fis
;
try
{
fis
=
new
FileInputStream
(
new
File
(
filePath
));
BorkerAccessControlTransport
transport
=
ymal
.
loadAs
(
fis
,
BorkerAccessControlTransport
.
class
);
super
.
setNetaddressAccessControl
(
transport
.
getOnlyNetAddress
());
for
(
AccessControl
accessControl
:
transport
.
getList
())
{
for
(
AccessControl
accessControl
:
transport
.
getList
())
{
super
.
setAccessControl
(
accessControl
);
}
}
catch
(
FileNotFoundException
e
)
{
throw
new
AclPlugAccountAnalysisException
(
"The transport.yml file for Plain mode was not found"
,
e
);
}
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/AccessControl.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
public
class
AccessControl
{
...
...
@@ -13,7 +29,6 @@ public class AccessControl {
public
AccessControl
()
{
}
public
String
getAccount
()
{
return
account
;
}
...
...
@@ -52,6 +67,4 @@ public class AccessControl {
+
", recognition="
+
recognition
+
"]"
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/AuthenticationInfo.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy
;
...
...
@@ -12,7 +30,8 @@ public class AuthenticationInfo {
private
Map
<
Integer
,
Boolean
>
authority
;
public
AuthenticationInfo
(
Map
<
Integer
,
Boolean
>
authority
,
AccessControl
accessControl
,
NetaddressStrategy
netaddressStrategy
)
{
public
AuthenticationInfo
(
Map
<
Integer
,
Boolean
>
authority
,
AccessControl
accessControl
,
NetaddressStrategy
netaddressStrategy
)
{
super
();
this
.
authority
=
authority
;
this
.
accessControl
=
accessControl
;
...
...
@@ -35,8 +54,6 @@ public class AuthenticationInfo {
this
.
netaddressStrategy
=
netaddressStrategy
;
}
public
Map
<
Integer
,
Boolean
>
getAuthority
()
{
return
authority
;
}
...
...
@@ -47,10 +64,18 @@ public class AuthenticationInfo {
@Override
public
String
toString
()
{
return
"AuthenticationInfo [accessControl="
+
accessControl
+
", netaddressStrategy="
+
netaddressStrategy
+
", authority="
+
authority
+
"]"
;
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"AuthenticationInfo [accessControl="
).
append
(
accessControl
).
append
(
", netaddressStrategy="
)
.
append
(
netaddressStrategy
).
append
(
", authority={"
);
Iterator
<
Entry
<
Integer
,
Boolean
>>
it
=
authority
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Entry
<
Integer
,
Boolean
>
e
=
it
.
next
();
if
(!
e
.
getValue
())
{
builder
.
append
(
e
.
getKey
().
toString
()).
append
(
":"
).
append
(
e
.
getValue
()).
append
(
","
);
}
}
builder
.
append
(
"}]"
);
return
builder
.
toString
();
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/AuthenticationResult.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
public
class
AuthenticationResult
{
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/BorkerAccessControl.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
import
java.util.HashSet
;
...
...
@@ -5,17 +21,13 @@ import java.util.Set;
import
org.apache.rocketmq.acl.plug.annotation.RequestCode
;
/**
* @author Administrator
*
*/
public
class
BorkerAccessControl
extends
AccessControl
{
public
class
BorkerAccessControl
extends
AccessControl
{
public
BorkerAccessControl
()
{
}
private
Set
<
String
>
permitSendTopic
=
new
HashSet
<>();
private
Set
<
String
>
noPermitSendTopic
=
new
HashSet
<>();
...
...
@@ -70,7 +82,7 @@ public class BorkerAccessControl extends AccessControl{
private
boolean
updateAndCreateTopic
=
true
;
@RequestCode
(
code
=
215
)
private
boolean
deleteTopicInbroker
=
true
;
private
boolean
deleteTopicInbroker
=
true
;
@RequestCode
(
code
=
21
)
private
boolean
getAllTopicConfig
=
true
;
...
...
@@ -171,9 +183,6 @@ public class BorkerAccessControl extends AccessControl{
@RequestCode
(
code
=
321
)
private
boolean
queryConsumeQueue
=
true
;
public
Set
<
String
>
getPermitSendTopic
()
{
return
permitSendTopic
;
}
...
...
@@ -600,35 +609,110 @@ public class BorkerAccessControl extends AccessControl{
@Override
public
String
toString
()
{
return
"BorkerAccessControl [permitSendTopic="
+
permitSendTopic
+
", noPermitSendTopic="
+
noPermitSendTopic
+
", permitPullTopic="
+
permitPullTopic
+
", noPermitPullTopic="
+
noPermitPullTopic
+
", sendMessage="
+
sendMessage
+
", sendMessageV2="
+
sendMessageV2
+
", sendBatchMessage="
+
sendBatchMessage
+
", consumerSendMsgBack="
+
consumerSendMsgBack
+
", pullMessage="
+
pullMessage
+
", queryMessage="
+
queryMessage
+
", viewMessageById="
+
viewMessageById
+
", heartBeat="
+
heartBeat
+
", unregisterClient="
+
unregisterClient
+
", checkClientConfig="
+
checkClientConfig
+
", getConsumerListByGroup="
+
getConsumerListByGroup
+
", updateConsumerOffset="
+
updateConsumerOffset
+
", queryConsumerOffset="
+
queryConsumerOffset
+
", endTransaction="
+
endTransaction
+
", updateAndCreateTopic="
+
updateAndCreateTopic
+
", deleteTopicInbroker="
+
deleteTopicInbroker
+
", getAllTopicConfig="
+
getAllTopicConfig
+
", updateBrokerConfig="
+
updateBrokerConfig
+
", getBrokerConfig="
+
getBrokerConfig
+
", searchOffsetByTimestamp="
+
searchOffsetByTimestamp
+
", getMaxOffset="
+
getMaxOffset
+
", getMixOffset="
+
getMixOffset
+
", getEarliestMsgStoretime="
+
getEarliestMsgStoretime
+
", getBrokerRuntimeInfo="
+
getBrokerRuntimeInfo
+
", lockBatchMQ="
+
lockBatchMQ
+
", unlockBatchMQ="
+
unlockBatchMQ
+
", updateAndCreteSubscriptiongroup="
+
updateAndCreteSubscriptiongroup
+
", getAllSubscriptiongroupConfig="
+
getAllSubscriptiongroupConfig
+
", deleteSubscriptiongroup="
+
deleteSubscriptiongroup
+
", getTopicStatsInfo="
+
getTopicStatsInfo
+
", getConsumerConnectionList="
+
getConsumerConnectionList
+
", getProducerConnectionList="
+
getProducerConnectionList
+
", getConsumeStats="
+
getConsumeStats
+
", getAllConsumerOffset="
+
getAllConsumerOffset
+
", getAllDelayOffset="
+
getAllDelayOffset
+
", invokeBrokerToresetOffset="
+
invokeBrokerToresetOffset
+
", queryTopicConsumByWho="
+
queryTopicConsumByWho
+
", registerFilterServer="
+
registerFilterServer
+
", queryConsumeTimeSpan="
+
queryConsumeTimeSpan
+
", getSystemTopicListFromBroker="
+
getSystemTopicListFromBroker
+
", cleanExpiredConsumequeue="
+
cleanExpiredConsumequeue
+
", cleanUnusedTopic="
+
cleanUnusedTopic
+
", getConsumerRunningInfo="
+
getConsumerRunningInfo
+
", queryCorrectionOffset="
+
queryCorrectionOffset
+
", consumeMessageDirectly="
+
consumeMessageDirectly
+
", cloneGroupOffset="
+
cloneGroupOffset
+
", viewBrokerStatsData="
+
viewBrokerStatsData
+
", getBrokerConsumeStats="
+
getBrokerConsumeStats
+
", queryConsumeQueue="
+
queryConsumeQueue
+
", toString()="
+
super
.
toString
()
+
"]"
;
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"BorkerAccessControl [permitSendTopic="
).
append
(
permitSendTopic
).
append
(
", noPermitSendTopic="
)
.
append
(
noPermitSendTopic
).
append
(
", permitPullTopic="
).
append
(
permitPullTopic
)
.
append
(
", noPermitPullTopic="
).
append
(
noPermitPullTopic
);
if
(!!
sendMessage
)
builder
.
append
(
", sendMessage="
).
append
(
sendMessage
);
if
(!!
sendMessageV2
)
builder
.
append
(
", sendMessageV2="
).
append
(
sendMessageV2
);
if
(!
sendBatchMessage
)
builder
.
append
(
", sendBatchMessage="
).
append
(
sendBatchMessage
);
if
(!
consumerSendMsgBack
)
builder
.
append
(
", consumerSendMsgBack="
).
append
(
consumerSendMsgBack
);
if
(!
pullMessage
)
builder
.
append
(
", pullMessage="
).
append
(
pullMessage
);
if
(!
queryMessage
)
builder
.
append
(
", queryMessage="
).
append
(
queryMessage
);
if
(!
viewMessageById
)
builder
.
append
(
", viewMessageById="
).
append
(
viewMessageById
);
if
(!
heartBeat
)
builder
.
append
(
", heartBeat="
).
append
(
heartBeat
);
if
(!
unregisterClient
)
builder
.
append
(
", unregisterClient="
).
append
(
unregisterClient
);
if
(!
checkClientConfig
)
builder
.
append
(
", checkClientConfig="
).
append
(
checkClientConfig
);
if
(!
getConsumerListByGroup
)
builder
.
append
(
", getConsumerListByGroup="
).
append
(
getConsumerListByGroup
);
if
(!
updateConsumerOffset
)
builder
.
append
(
", updateConsumerOffset="
).
append
(
updateConsumerOffset
);
if
(!
queryConsumerOffset
)
builder
.
append
(
", queryConsumerOffset="
).
append
(
queryConsumerOffset
);
if
(!
endTransaction
)
builder
.
append
(
", endTransaction="
).
append
(
endTransaction
);
if
(!
updateAndCreateTopic
)
builder
.
append
(
", updateAndCreateTopic="
).
append
(
updateAndCreateTopic
);
if
(!
deleteTopicInbroker
)
builder
.
append
(
", deleteTopicInbroker="
).
append
(
deleteTopicInbroker
);
if
(!
getAllTopicConfig
)
builder
.
append
(
", getAllTopicConfig="
).
append
(
getAllTopicConfig
);
if
(!
updateBrokerConfig
)
builder
.
append
(
", updateBrokerConfig="
).
append
(
updateBrokerConfig
);
if
(!
getBrokerConfig
)
builder
.
append
(
", getBrokerConfig="
).
append
(
getBrokerConfig
);
if
(!
searchOffsetByTimestamp
)
builder
.
append
(
", searchOffsetByTimestamp="
).
append
(
searchOffsetByTimestamp
);
if
(!
getMaxOffset
)
builder
.
append
(
", getMaxOffset="
).
append
(
getMaxOffset
);
if
(!
getMixOffset
)
builder
.
append
(
", getMixOffset="
).
append
(
getMixOffset
);
if
(!
getEarliestMsgStoretime
)
builder
.
append
(
", getEarliestMsgStoretime="
).
append
(
getEarliestMsgStoretime
);
if
(!
getBrokerRuntimeInfo
)
builder
.
append
(
", getBrokerRuntimeInfo="
).
append
(
getBrokerRuntimeInfo
);
if
(!
lockBatchMQ
)
builder
.
append
(
", lockBatchMQ="
).
append
(
lockBatchMQ
);
if
(!
unlockBatchMQ
)
builder
.
append
(
", unlockBatchMQ="
).
append
(
unlockBatchMQ
);
if
(!
updateAndCreteSubscriptiongroup
)
builder
.
append
(
", updateAndCreteSubscriptiongroup="
).
append
(
updateAndCreteSubscriptiongroup
);
if
(!
getAllSubscriptiongroupConfig
)
builder
.
append
(
", getAllSubscriptiongroupConfig="
).
append
(
getAllSubscriptiongroupConfig
);
if
(!
deleteSubscriptiongroup
)
builder
.
append
(
", deleteSubscriptiongroup="
).
append
(
deleteSubscriptiongroup
);
if
(!
getTopicStatsInfo
)
builder
.
append
(
", getTopicStatsInfo="
).
append
(
getTopicStatsInfo
);
if
(!
getConsumerConnectionList
)
builder
.
append
(
", getConsumerConnectionList="
).
append
(
getConsumerConnectionList
);
if
(!
getProducerConnectionList
)
builder
.
append
(
", getProducerConnectionList="
).
append
(
getProducerConnectionList
);
if
(!
getConsumeStats
)
builder
.
append
(
", getConsumeStats="
).
append
(
getConsumeStats
);
if
(!
getAllConsumerOffset
)
builder
.
append
(
", getAllConsumerOffset="
).
append
(
getAllConsumerOffset
);
if
(!
getAllDelayOffset
)
builder
.
append
(
", getAllDelayOffset="
).
append
(
getAllDelayOffset
);
if
(!
invokeBrokerToresetOffset
)
builder
.
append
(
", invokeBrokerToresetOffset="
).
append
(
invokeBrokerToresetOffset
);
if
(!
queryTopicConsumByWho
)
builder
.
append
(
", queryTopicConsumByWho="
).
append
(
queryTopicConsumByWho
);
if
(!
registerFilterServer
)
builder
.
append
(
", registerFilterServer="
).
append
(
registerFilterServer
);
if
(!
queryConsumeTimeSpan
)
builder
.
append
(
", queryConsumeTimeSpan="
).
append
(
queryConsumeTimeSpan
);
if
(!
getSystemTopicListFromBroker
)
builder
.
append
(
", getSystemTopicListFromBroker="
).
append
(
getSystemTopicListFromBroker
);
if
(!
cleanExpiredConsumequeue
)
builder
.
append
(
", cleanExpiredConsumequeue="
).
append
(
cleanExpiredConsumequeue
);
if
(!
getConsumerRunningInfo
)
builder
.
append
(
", cleanUnusedTopic="
).
append
(
getConsumerRunningInfo
);
if
(!
getConsumerRunningInfo
)
builder
.
append
(
", getConsumerRunningInfo="
).
append
(
getConsumerRunningInfo
);
if
(!
queryCorrectionOffset
)
builder
.
append
(
", queryCorrectionOffset="
).
append
(
queryCorrectionOffset
);
if
(!
consumeMessageDirectly
)
builder
.
append
(
", consumeMessageDirectly="
).
append
(
consumeMessageDirectly
);
if
(!
cloneGroupOffset
)
builder
.
append
(
", cloneGroupOffset="
).
append
(
cloneGroupOffset
);
if
(!
viewBrokerStatsData
)
builder
.
append
(
", viewBrokerStatsData="
).
append
(
viewBrokerStatsData
);
if
(!
getBrokerConsumeStats
)
builder
.
append
(
", getBrokerConsumeStats="
).
append
(
getBrokerConsumeStats
);
if
(!
queryConsumeQueue
)
builder
.
append
(
", queryConsumeQueue="
).
append
(
queryConsumeQueue
);
builder
.
append
(
"]"
);
return
builder
.
toString
();
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/BorkerAccessControlTransport.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
import
java.util.List
;
...
...
@@ -8,8 +24,6 @@ public class BorkerAccessControlTransport {
private
List
<
BorkerAccessControl
>
list
;
public
BorkerAccessControlTransport
()
{
super
();
}
...
...
@@ -35,6 +49,4 @@ public class BorkerAccessControlTransport {
return
"BorkerAccessControlTransport [onlyNetAddress="
+
onlyNetAddress
+
", list="
+
list
+
"]"
;
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/ControllerParametersEntity.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
public
class
ControllerParametersEntity
{
private
String
fileHome
;
public
String
getFileHome
()
{
return
fileHome
;
}
public
void
setFileHome
(
String
fileHome
)
{
this
.
fileHome
=
fileHome
;
}
@Override
public
String
toString
()
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"ControllerParametersEntity [fileHome="
).
append
(
fileHome
).
append
(
"]"
);
return
builder
.
toString
();
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/LoginInfo.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.entity
;
public
class
LoginInfo
{
import
java.util.concurrent.atomic.AtomicBoolean
;
public
class
LoginInfo
{
private
String
recognition
;
private
long
loginTime
=
System
.
currentTimeMillis
();
private
long
operationTime
=
loginTime
;
private
AuthenticationInfo
authenticationInfo
;
private
volatile
long
operationTime
=
loginTime
;
private
volatile
AtomicBoolean
clear
=
new
AtomicBoolean
();
private
AuthenticationInfo
authenticationInfo
;
public
AuthenticationInfo
getAuthenticationInfo
()
{
return
authenticationInfo
;
...
...
@@ -45,11 +62,21 @@ public class LoginInfo {
this
.
operationTime
=
operationTime
;
}
public
AtomicBoolean
getClear
()
{
return
clear
;
}
public
void
setClear
(
AtomicBoolean
clear
)
{
this
.
clear
=
clear
;
}
@Override
public
String
toString
()
{
return
"LoginInfo [recognition="
+
recognition
+
", loginTime="
+
loginTime
+
", operationTime="
+
operationTime
+
", authenticationInfo="
+
authenticationInfo
+
"]"
;
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"LoginInfo [recognition="
).
append
(
recognition
).
append
(
", loginTime="
).
append
(
loginTime
)
.
append
(
", operationTime="
).
append
(
operationTime
).
append
(
", clear="
).
append
(
clear
)
.
append
(
", authenticationInfo="
).
append
(
authenticationInfo
).
append
(
"]"
);
return
builder
.
toString
();
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/entity/LoginOrRequestAccessControl.java
浏览文件 @
7a030209
package
org.apache.rocketmq.acl.plug.entity
;
/**
* @author Administrator
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
p
ublic
class
LoginOrRequestAccessControl
extends
AccessControl
{
p
ackage
org.apache.rocketmq.acl.plug.entity
;
public
class
LoginOrRequestAccessControl
extends
AccessControl
{
private
int
code
;
...
...
@@ -34,6 +45,4 @@ public class LoginOrRequestAccessControl extends AccessControl {
return
builder
.
toString
();
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugAccountAnalysisException.java
0 → 100644
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.exception
;
public
class
AclPlugAccountAnalysisException
extends
AclPlugRuntimeException
{
private
static
final
long
serialVersionUID
=
-
7286948517911075176L
;
public
AclPlugAccountAnalysisException
(
String
message
)
{
super
(
message
);
}
public
AclPlugAccountAnalysisException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugAuthenticationException.java
0 → 100644
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.exception
;
public
class
AclPlugAuthenticationException
extends
AclPlugRuntimeException
{
private
static
final
long
serialVersionUID
=
6365666045084521516L
;
public
AclPlugAuthenticationException
(
String
message
)
{
super
(
message
);
}
public
AclPlugAuthenticationException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugException.java
0 → 100644
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.exception
;
public
class
AclPlugException
extends
Exception
{
private
static
final
long
serialVersionUID
=
6843154847463800519L
;
public
AclPlugException
(
String
message
)
{
super
(
message
);
}
public
AclPlugException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugLoginException.java
0 → 100644
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.exception
;
public
class
AclPlugLoginException
extends
AclPlugRuntimeException
{
private
static
final
long
serialVersionUID
=
4593661700080106122L
;
public
AclPlugLoginException
(
String
message
)
{
super
(
message
);
}
public
AclPlugLoginException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugRuntimeException.java
0 → 100644
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.exception
;
public
class
AclPlugRuntimeException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
6062101368637228900L
;
public
AclPlugRuntimeException
(
String
message
)
{
super
(
message
);
}
public
AclPlugRuntimeException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/exception/AclPlugStartException.java
0 → 100644
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.exception
;
public
class
AclPlugStartException
extends
AclPlugException
{
private
static
final
long
serialVersionUID
=
5118936374739373693L
;
public
AclPlugStartException
(
String
message
)
{
super
(
message
);
}
public
AclPlugStartException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/AbstractNetaddressStrategy.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
org.apache.rocketmq.acl.plug.AclUtils
;
public
abstract
class
AbstractNetaddressStrategy
implements
NetaddressStrategy
{
public
void
verify
(
String
netaddress
,
int
index
)
{
public
void
verify
(
String
netaddress
,
int
index
)
{
AclUtils
.
isScope
(
netaddress
,
index
);
}
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/MultipleNetaddressStrategy.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
java.util.HashSet
;
...
...
@@ -10,13 +26,12 @@ public class MultipleNetaddressStrategy extends AbstractNetaddressStrategy {
private
final
Set
<
String
>
multipleSet
=
new
HashSet
<>();
public
MultipleNetaddressStrategy
(
String
[]
strArray
)
{
for
(
String
netaddress
:
strArray
)
{
for
(
String
netaddress
:
strArray
)
{
verify
(
netaddress
,
4
);
multipleSet
.
add
(
netaddress
);
}
}
@Override
public
boolean
match
(
AccessControl
accessControl
)
{
return
multipleSet
.
contains
(
accessControl
.
getNetaddress
());
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/NetaddressStrategy.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
org.apache.rocketmq.acl.plug.entity.AccessControl
;
public
interface
NetaddressStrategy
{
public
boolean
match
(
AccessControl
accessControl
);
}
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/NetaddressStrategyFactory.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -6,23 +22,21 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl;
public
class
NetaddressStrategyFactory
{
public
NetaddressStrategy
getNetaddressStrategy
(
AccessControl
accessControl
)
{
public
NetaddressStrategy
getNetaddressStrategy
(
AccessControl
accessControl
)
{
String
netaddress
=
accessControl
.
getNetaddress
();
if
(
StringUtils
.
isBlank
(
netaddress
)
||
"*"
.
equals
(
netaddress
)
)
{
//*
if
(
StringUtils
.
isBlank
(
netaddress
)
||
"*"
.
equals
(
netaddress
))
{
return
NullNetaddressStrategy
.
NULL_NET_ADDRESS_STRATEGY
;
}
if
(
netaddress
.
endsWith
(
"}"
))
{
//1.1.1.{1,2,3,4,5}
if
(
netaddress
.
endsWith
(
"}"
))
{
String
[]
strArray
=
StringUtils
.
split
(
netaddress
);
String
four
=
strArray
[
3
];
if
(!
four
.
startsWith
(
"{"
))
{
if
(!
four
.
startsWith
(
"{"
))
{
}
return
new
MultipleNetaddressStrategy
(
AclUtils
.
getAddreeStrArray
(
netaddress
,
four
));
}
else
if
(
AclUtils
.
isColon
(
netaddress
))
{
//1.1.1.1,1.2.3.4.5
return
new
MultipleNetaddressStrategy
(
StringUtils
.
split
(
","
));
}
else
if
(
AclUtils
.
isAsterisk
(
netaddress
)
||
AclUtils
.
isMinus
(
netaddress
))
{
//1.2.*.* , 1.1.1.1-5 ,1.1.1-5.*
}
else
if
(
AclUtils
.
isColon
(
netaddress
))
{
return
new
MultipleNetaddressStrategy
(
StringUtils
.
split
(
","
));
}
else
if
(
AclUtils
.
isAsterisk
(
netaddress
)
||
AclUtils
.
isMinus
(
netaddress
))
{
return
new
RangeNetaddressStrategy
(
netaddress
);
}
return
new
OneNetaddressStrategy
(
netaddress
);
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/NullNetaddressStrategy.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
org.apache.rocketmq.acl.plug.entity.AccessControl
;
...
...
@@ -6,7 +22,6 @@ public class NullNetaddressStrategy implements NetaddressStrategy {
public
static
final
NullNetaddressStrategy
NULL_NET_ADDRESS_STRATEGY
=
new
NullNetaddressStrategy
();
@Override
public
boolean
match
(
AccessControl
accessControl
)
{
return
true
;
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/OneNetaddressStrategy.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
org.apache.rocketmq.acl.plug.entity.AccessControl
;
public
class
OneNetaddressStrategy
extends
AbstractNetaddressStrategy
{
private
String
netaddress
;
public
OneNetaddressStrategy
(
String
netaddress
)
{
...
...
acl-plug/src/main/java/org/apache/rocketmq/acl/plug/strategy/RangeNetaddressStrategy.java
浏览文件 @
7a030209
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.acl.plug.strategy
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -15,51 +31,50 @@ public class RangeNetaddressStrategy extends AbstractNetaddressStrategy {
private
int
index
;
public
RangeNetaddressStrategy
(
String
netaddress
)
{
String
[]
strArray
=
StringUtils
.
split
(
netaddress
,
"."
);
if
(
analysis
(
strArray
,
2
)
||
analysis
(
strArray
,
3
)
)
{
String
[]
strArray
=
StringUtils
.
split
(
netaddress
,
"."
);
if
(
analysis
(
strArray
,
2
)
||
analysis
(
strArray
,
3
)
)
{
verify
(
netaddress
,
index
);
StringBuffer
sb
=
new
StringBuffer
().
append
(
strArray
[
0
].
trim
()).
append
(
"."
).
append
(
strArray
[
1
].
trim
()).
append
(
"."
);
if
(
index
==
3
)
{
sb
.
append
(
strArray
[
2
].
trim
()).
append
(
"."
);
StringBuffer
sb
=
new
StringBuffer
().
append
(
strArray
[
0
].
trim
()).
append
(
"."
).
append
(
strArray
[
1
].
trim
()).
append
(
"."
);
if
(
index
==
3
)
{
sb
.
append
(
strArray
[
2
].
trim
()).
append
(
"."
);
}
this
.
head
=
sb
.
toString
();
}
}
private
boolean
analysis
(
String
[]
strArray
,
int
index
)
{
private
boolean
analysis
(
String
[]
strArray
,
int
index
)
{
String
value
=
strArray
[
index
].
trim
();
this
.
index
=
index
;
if
(
"*"
.
equals
(
value
)
)
{
if
(
"*"
.
equals
(
value
))
{
setValue
(
0
,
255
);
}
else
if
(
AclUtils
.
isMinus
(
value
))
{
String
[]
valueArray
=
StringUtils
.
split
(
value
,
"-"
);
}
else
if
(
AclUtils
.
isMinus
(
value
))
{
String
[]
valueArray
=
StringUtils
.
split
(
value
,
"-"
);
this
.
start
=
Integer
.
valueOf
(
valueArray
[
0
]);
this
.
end
=
Integer
.
valueOf
(
valueArray
[
1
]);
if
(
!(
AclUtils
.
isScope
(
end
)
&&
AclUtils
.
isScope
(
start
)
&&
start
<=
end
))
{
if
(!(
AclUtils
.
isScope
(
end
)
&&
AclUtils
.
isScope
(
start
)
&&
start
<=
end
))
{
}
}
return
this
.
end
>
0
?
true
:
false
;
}
private
void
setValue
(
int
start
,
int
end
)
{
this
.
start
=
start
;
private
void
setValue
(
int
start
,
int
end
)
{
this
.
start
=
start
;
this
.
end
=
end
;
}
@Override
public
boolean
match
(
AccessControl
accessControl
)
{
String
netAddress
=
accessControl
.
getNetaddress
();
if
(
netAddress
.
startsWith
(
this
.
head
))
{
if
(
netAddress
.
startsWith
(
this
.
head
))
{
String
value
;
if
(
index
==
3
)
{
if
(
index
==
3
)
{
value
=
netAddress
.
substring
(
this
.
head
.
length
());
}
else
{
value
=
netAddress
.
substring
(
this
.
head
.
length
()
,
netAddress
.
lastIndexOf
(
'.'
));
}
else
{
value
=
netAddress
.
substring
(
this
.
head
.
length
()
,
netAddress
.
lastIndexOf
(
'.'
));
}
Integer
address
=
Integer
.
valueOf
(
value
);
if
(
address
>=
this
.
start
&&
address
<=
this
.
end
)
{
if
(
address
>=
this
.
start
&&
address
<=
this
.
end
)
{
return
true
;
}
}
...
...
acl-plug/src/test/java/org/apache/rocketmq/acl/plug/AccessContralAnalysisTest.java
浏览文件 @
7a030209
acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java
浏览文件 @
7a030209
...
...
@@ -6,7 +6,7 @@ public class PlainAclPlugEngineTest {
@Test
public
void
testPlainAclPlugEngineInit
()
{
PlainAclPlugEngine
plainAclPlugEngine
=
new
PlainAclPlugEngine
();
plainAclPlugEngine
.
init
();
//
PlainAclPlugEngine plainAclPlugEngine = new PlainAclPlugEngine();
//
plainAclPlugEngine.init();
}
}
acl-plug/src/test/resources/transport.yml
浏览文件 @
7a030209
...
...
@@ -4,13 +4,13 @@ onlyNetAddress:
-
broker-a
list
:
-
account
:
laohu
-
account
:
laohu
password
:
123456
netaddress
:
192.0.0.*
permitSendTopic
:
-
test1
-
test2
-
account
:
laohu
-
account
:
laohu
password
:
123456
netaddress
:
192.0.2.1
permitSendTopic
:
...
...
distribution/conf/transport.yml
0 → 100644
浏览文件 @
7a030209
onlyNetAddress
:
netaddress
:
10.10.103.*
noPermitPullTopic
:
-
broker-a
list
:
-
account
:
laohu
password
:
123456
netaddress
:
192.0.0.*
permitSendTopic
:
-
test1
-
test2
-
account
:
laohu
password
:
123456
netaddress
:
192.0.2.1
permitSendTopic
:
-
test3
-
test4
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录