提交 2a93a9bf 编写于 作者: D dongeforever

Polish acl

上级 2d4cda26
/*
* 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;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
public class DefaultAccessValidator implements AccessValidator {
@Override
public AccessResource parse(RemotingCommand request, String remoteAddr) {
return null;
}
@Override
public void validate(AccessResource accessResource) {
}
}
......@@ -42,7 +42,6 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
......
......@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.rocketmq.acl.plug;
package org.apache.rocketmq.acl;
import java.util.HashMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.AccessResource;
import org.apache.rocketmq.acl.AccessValidator;
import org.apache.rocketmq.acl.plug.AclRemotingService;
import org.apache.rocketmq.acl.plug.engine.AclPlugEngine;
import org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
......@@ -28,17 +29,17 @@ import org.apache.rocketmq.acl.plug.entity.ControllerParameters;
import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
public class DefaultAclRemotingServiceImpl implements AclRemotingService, AccessValidator {
public class PlainAccessValidator implements AclRemotingService, AccessValidator {
private AclPlugEngine aclPlugEngine;
public DefaultAclRemotingServiceImpl() {
public PlainAccessValidator() {
ControllerParameters controllerParameters = new ControllerParameters();
this.aclPlugEngine = new PlainAclPlugEngine(controllerParameters);
this.aclPlugEngine.initialize();
}
public DefaultAclRemotingServiceImpl(AclPlugEngine aclPlugEngine) {
public PlainAccessValidator(AclPlugEngine aclPlugEngine) {
this.aclPlugEngine = aclPlugEngine;
}
......
......@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.acl.plug;
import org.apache.rocketmq.acl.PlainAccessValidator;
import org.apache.rocketmq.acl.plug.engine.AclPlugEngine;
import org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine;
import org.apache.rocketmq.acl.plug.entity.ControllerParameters;
......@@ -36,7 +37,7 @@ public class AclPlugController {
this.controllerParameters = controllerParameters;
aclPlugEngine = new PlainAclPlugEngine(controllerParameters);
aclPlugEngine.initialize();
aclRemotingService = new DefaultAclRemotingServiceImpl(aclPlugEngine);
aclRemotingService = new PlainAccessValidator(aclPlugEngine);
this.startSucceed = true;
} catch (Exception e) {
throw new AclPlugRuntimeException(String.format("Start the abnormal , Launch parameters is %s", this.controllerParameters.toString()), e);
......
......@@ -20,6 +20,7 @@ import java.util.HashMap;
import org.apache.rocketmq.acl.AccessResource;
import org.apache.rocketmq.acl.AccessValidator;
import org.apache.rocketmq.acl.PlainAccessValidator;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl;
......@@ -43,7 +44,7 @@ public class AclRemotingServiceTest {
@Before
public void init() {
System.setProperty("rocketmq.home.dir", "src/test/resources");
DefaultAclRemotingServiceImpl aclRemotingServiceImpl = new DefaultAclRemotingServiceImpl();
PlainAccessValidator aclRemotingServiceImpl = new PlainAccessValidator();
defaultAclService = aclRemotingServiceImpl;
accessValidator = aclRemotingServiceImpl;
......@@ -64,7 +65,7 @@ public class AclRemotingServiceTest {
@Test
public void defaultConstructorTest() {
System.setProperty("rocketmq.home.dir", "src/test/resources");
AclRemotingService defaultAclService = new DefaultAclRemotingServiceImpl();
AclRemotingService defaultAclService = new PlainAccessValidator();
Assert.assertNotNull(defaultAclService);
}
......
org.apache.rocketmq.acl.plug.DefaultAclRemotingServiceImpl
\ No newline at end of file
org.apache.rocketmq.acl.DefaultAclRemotingServiceImpl
\ No newline at end of file
......@@ -63,7 +63,7 @@ public class AclClient {
}
public static void producer() throws MQClientException {
DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName", getAalRPCHook());
DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName", getAclRPCHook());
producer.setNamesrvAddr("127.0.0.1:9876");
producer.start();
......@@ -87,7 +87,7 @@ public class AclClient {
public static void pushConsumer() throws MQClientException {
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_5", getAalRPCHook(), new AllocateMessageQueueAveragely());
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_5", getAclRPCHook(), new AllocateMessageQueueAveragely());
consumer.setNamesrvAddr("127.0.0.1:9876");
consumer.subscribe("TopicTest", "*");
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
......@@ -107,7 +107,7 @@ public class AclClient {
}
public static void pullConsumer() throws MQClientException {
DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_6", getAalRPCHook());
DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_6", getAclRPCHook());
consumer.setNamesrvAddr("127.0.0.1:9876");
consumer.start();
......@@ -169,17 +169,17 @@ public class AclClient {
OFFSE_TABLE.put(mq, offset);
}
static RPCHook getAalRPCHook() {
return new AalRPCHook(ACL_RCPHOOK_ACCOUT, ACL_RCPHOOK_PASSWORD);
static RPCHook getAclRPCHook() {
return new AclRPCHook(ACL_RCPHOOK_ACCOUT, ACL_RCPHOOK_PASSWORD);
}
static class AalRPCHook implements RPCHook {
static class AclRPCHook implements RPCHook {
private String account;
private String password;
public AalRPCHook(String account, String password) {
public AclRPCHook(String account, String password) {
this.account = account;
this.password = password;
}
......@@ -198,7 +198,7 @@ public class AclClient {
@Override
public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {
// TODO Auto-generated method stub
//do nothing
}
......
......@@ -126,7 +126,7 @@
<module>distribution</module>
<module>openmessaging</module>
<module>logging</module>
<module>acl-plug</module>
<module>acl</module>
</modules>
<build>
......@@ -588,6 +588,11 @@
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册