Skip to content

Commit

Permalink
Polish acl
Browse files Browse the repository at this point in the history
  • Loading branch information
dongeforever committed Nov 9, 2018
1 parent 2d4cda2 commit 2a93a9b
Show file tree
Hide file tree
Showing 35 changed files with 25 additions and 51 deletions.

This file was deleted.

1 change: 0 additions & 1 deletion acl-plug/pom.xml → acl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,17 +29,17 @@
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +37,7 @@ public AclPlugController(ControllerParameters controllerParameters) throws AclPl
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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;
Expand All @@ -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;

Expand All @@ -64,7 +65,7 @@ public void init() {
@Test
public void defaultConstructorTest() {
System.setProperty("rocketmq.home.dir", "src/test/resources");
AclRemotingService defaultAclService = new DefaultAclRemotingServiceImpl();
AclRemotingService defaultAclService = new PlainAccessValidator();
Assert.assertNotNull(defaultAclService);
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.apache.rocketmq.acl.plug.DefaultAclRemotingServiceImpl
org.apache.rocketmq.acl.DefaultAclRemotingServiceImpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void main(String[] args) throws MQClientException, InterruptedExce
}

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();

Expand All @@ -87,7 +87,7 @@ public static void producer() throws MQClientException {

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);
Expand All @@ -107,7 +107,7 @@ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeCo
}

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();

Expand Down Expand Up @@ -169,17 +169,17 @@ private static void putMessageQueueOffset(MessageQueue mq, long offset) {
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;
}
Expand All @@ -198,7 +198,7 @@ public void doBeforeRequest(String remoteAddr, RemotingCommand request) {

@Override
public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {
// TODO Auto-generated method stub
//do nothing

}

Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<module>distribution</module>
<module>openmessaging</module>
<module>logging</module>
<module>acl-plug</module>
<module>acl</module>
</modules>

<build>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 2a93a9b

Please sign in to comment.