提交 1e3c1841 编写于 作者: H hujie

clear

上级 a1a46168
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-remoting</artifactId>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>rocketmq-logging</artifactId> <artifactId>rocketmq-logging</artifactId>
......
...@@ -23,7 +23,7 @@ import java.util.Map; ...@@ -23,7 +23,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class AccessContralAnalysis { public class AccessContralAnalysis {
...@@ -42,7 +42,7 @@ public class AccessContralAnalysis { ...@@ -42,7 +42,7 @@ public class AccessContralAnalysis {
} }
} catch (IllegalArgumentException | IllegalAccessException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
throw new AclPlugAccountAnalysisException(String.format("analysis on failure Class is %s", clazz.getName()), e); throw new AclPlugRuntimeException(String.format("analysis on failure Class is %s", clazz.getName()), e);
} }
} }
...@@ -57,14 +57,14 @@ public class AccessContralAnalysis { ...@@ -57,14 +57,14 @@ public class AccessContralAnalysis {
continue; continue;
Integer code = fieldNameAndCode.get(field.getName().toLowerCase()); Integer code = fieldNameAndCode.get(field.getName().toLowerCase());
if (code == null) { if (code == null) {
throw new AclPlugAccountAnalysisException(String.format("field nonexistent in code fieldName is %s", field.getName())); throw new AclPlugRuntimeException(String.format("field nonexistent in code fieldName is %s", field.getName()));
} }
field.setAccessible(true); field.setAccessible(true);
codeAndField.put(code, field); codeAndField.put(code, field);
} }
if (codeAndField.isEmpty()) { if (codeAndField.isEmpty()) {
throw new AclPlugAccountAnalysisException(String.format("AccessControl nonexistent code , name %s", accessControl.getClass().getName())); throw new AclPlugRuntimeException(String.format("AccessControl nonexistent code , name %s", accessControl.getClass().getName()));
} }
classTocodeAndMentod.put(clazz, codeAndField); classTocodeAndMentod.put(clazz, codeAndField);
} }
...@@ -76,7 +76,7 @@ public class AccessContralAnalysis { ...@@ -76,7 +76,7 @@ public class AccessContralAnalysis {
authority.put(e.getKey(), (Boolean) e.getValue().get(accessControl)); authority.put(e.getKey(), (Boolean) e.getValue().get(accessControl));
} }
} catch (IllegalArgumentException | IllegalAccessException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
throw new AclPlugAccountAnalysisException(String.format("analysis on failure AccessControl is %s", AccessControl.class.getName()), e); throw new AclPlugRuntimeException(String.format("analysis on failure AccessControl is %s", AccessControl.class.getName()), e);
} }
return authority; return authority;
} }
......
...@@ -19,7 +19,7 @@ package org.apache.rocketmq.acl.plug; ...@@ -19,7 +19,7 @@ package org.apache.rocketmq.acl.plug;
import org.apache.rocketmq.acl.plug.engine.AclPlugEngine; import org.apache.rocketmq.acl.plug.engine.AclPlugEngine;
import org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine; import org.apache.rocketmq.acl.plug.engine.PlainAclPlugEngine;
import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity;
import org.apache.rocketmq.acl.plug.exception.AclPlugStartException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class AclPlugController { public class AclPlugController {
...@@ -31,14 +31,14 @@ public class AclPlugController { ...@@ -31,14 +31,14 @@ public class AclPlugController {
private boolean startSucceed = false; private boolean startSucceed = false;
public AclPlugController(ControllerParametersEntity controllerParametersEntity) throws AclPlugStartException { public AclPlugController(ControllerParametersEntity controllerParametersEntity) throws AclPlugRuntimeException {
try { try {
this.controllerParametersEntity = controllerParametersEntity; this.controllerParametersEntity = controllerParametersEntity;
aclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity); aclPlugEngine = new PlainAclPlugEngine(controllerParametersEntity);
aclRemotingServer = new DefaultAclRemotingServerImpl(aclPlugEngine); aclRemotingServer = new DefaultAclRemotingServerImpl(aclPlugEngine);
this.startSucceed = true; this.startSucceed = true;
} catch (Exception e) { } catch (Exception e) {
throw new AclPlugStartException(String.format("Start the abnormal , Launch parameters is %s", this.controllerParametersEntity.toString()), e); throw new AclPlugRuntimeException(String.format("Start the abnormal , Launch parameters is %s", this.controllerParametersEntity.toString()), e);
} }
} }
......
/*
* 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 {
}
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
*/ */
package org.apache.rocketmq.acl.plug; package org.apache.rocketmq.acl.plug;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
public interface AclRemotingServer { public interface AclRemotingServer {
public AuthenticationResult eachCheck(LoginOrRequestAccessControl accessControl); public AuthenticationResult eachCheck(AccessControl accessControl);
} }
...@@ -17,9 +17,16 @@ ...@@ -17,9 +17,16 @@
package org.apache.rocketmq.acl.plug; package org.apache.rocketmq.acl.plug;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class AclUtils { public class AclUtils {
public static void verify(String netaddress, int index) {
if (!AclUtils.isScope(netaddress, index)) {
throw new AclPlugRuntimeException(String.format("netaddress examine scope Exception netaddress is %s", netaddress));
}
}
public static String[] getAddreeStrArray(String netaddress, String four) { public static String[] getAddreeStrArray(String netaddress, String four) {
String[] fourStrArray = StringUtils.split(four.substring(1, four.length() - 1), ","); String[] fourStrArray = StringUtils.split(four.substring(1, four.length() - 1), ",");
String address = netaddress.substring(0, netaddress.indexOf("{")); String address = netaddress.substring(0, netaddress.indexOf("{"));
......
...@@ -20,23 +20,21 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl; ...@@ -20,23 +20,21 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
public class Authentication { public class Authentication {
public boolean authentication(AuthenticationInfo authenticationInfo, public boolean authentication(AuthenticationInfo authenticationInfo,
LoginOrRequestAccessControl loginOrRequestAccessControl, AuthenticationResult authenticationResult) { AccessControl accessControl, AuthenticationResult authenticationResult) {
int code = loginOrRequestAccessControl.getCode(); int code = accessControl.getCode();
if (!authenticationInfo.getAuthority().get(code)) { if (!authenticationInfo.getAuthority().get(code)) {
authenticationResult.setResultString(String.format("code is %d Authentication failed", code)); authenticationResult.setResultString(String.format("code is %d Authentication failed", code));
return false; return false;
} }
AccessControl accessControl = authenticationInfo.getAccessControl(); if (!(authenticationInfo.getAccessControl() instanceof BorkerAccessControl)) {
if (!(accessControl instanceof BorkerAccessControl)) {
return true; return true;
} }
BorkerAccessControl borker = (BorkerAccessControl) authenticationInfo.getAccessControl(); BorkerAccessControl borker = (BorkerAccessControl) authenticationInfo.getAccessControl();
String topicName = loginOrRequestAccessControl.getTopic(); String topicName = accessControl.getTopic();
if (code == 10 || code == 310 || code == 320) { if (code == 10 || code == 310 || code == 320) {
if (borker.getPermitSendTopic().contains(topicName)) { if (borker.getPermitSendTopic().contains(topicName)) {
return true; return true;
......
...@@ -17,10 +17,8 @@ ...@@ -17,10 +17,8 @@
package org.apache.rocketmq.acl.plug; package org.apache.rocketmq.acl.plug;
import org.apache.rocketmq.acl.plug.engine.AclPlugEngine; import org.apache.rocketmq.acl.plug.engine.AclPlugEngine;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; 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; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class DefaultAclRemotingServerImpl implements AclRemotingServer { public class DefaultAclRemotingServerImpl implements AclRemotingServer {
...@@ -32,16 +30,16 @@ public class DefaultAclRemotingServerImpl implements AclRemotingServer { ...@@ -32,16 +30,16 @@ public class DefaultAclRemotingServerImpl implements AclRemotingServer {
} }
@Override @Override
public AuthenticationResult eachCheck(LoginOrRequestAccessControl accessControl) { public AuthenticationResult eachCheck(AccessControl accessControl) {
AuthenticationResult authenticationResult = aclPlugEngine.eachCheckLoginAndAuthentication(accessControl); AuthenticationResult authenticationResult = aclPlugEngine.eachCheckLoginAndAuthentication(accessControl);
if (authenticationResult.getException() != null) { if (authenticationResult.getException() != null) {
throw new AclPlugRuntimeException(String.format("eachCheck the inspection appear exception, accessControl data is %s", accessControl.toString()), authenticationResult.getException()); throw new AclPlugRuntimeException(String.format("eachCheck the inspection appear exception, accessControl data is %s", accessControl.toString()), authenticationResult.getException());
} }
if (authenticationResult.getAccessControl() == null) { if (authenticationResult.getAccessControl() == null) {
throw new AclPlugLoginException(String.format("%s accessControl data is %s", authenticationResult.getResultString(), accessControl.toString())); throw new AclPlugRuntimeException(String.format("%s accessControl data is %s", authenticationResult.getResultString(), accessControl.toString()));
} }
if (!authenticationResult.isSucceed()) { if (!authenticationResult.isSucceed()) {
throw new AclPlugAuthenticationException(String.format("%s accessControl data is %s", authenticationResult.getResultString(), accessControl.toString())); throw new AclPlugRuntimeException(String.format("%s accessControl data is %s", authenticationResult.getResultString(), accessControl.toString()));
} }
return authenticationResult; return authenticationResult;
} }
......
...@@ -20,7 +20,6 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl; ...@@ -20,7 +20,6 @@ import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.LoginInfo; import org.apache.rocketmq.acl.plug.entity.LoginInfo;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
public interface AclPlugEngine { public interface AclPlugEngine {
...@@ -30,5 +29,5 @@ public interface AclPlugEngine { ...@@ -30,5 +29,5 @@ public interface AclPlugEngine {
public void deleteLoginInfo(String remoteAddr); public void deleteLoginInfo(String remoteAddr);
public AuthenticationResult eachCheckLoginAndAuthentication(LoginOrRequestAccessControl accessControl); public AuthenticationResult eachCheckLoginAndAuthentication(AccessControl accessControl);
} }
...@@ -26,8 +26,7 @@ import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; ...@@ -26,8 +26,7 @@ import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport;
import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException;
import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategy;
import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory;
import org.apache.rocketmq.common.constant.LoggerName; import org.apache.rocketmq.common.constant.LoggerName;
...@@ -49,9 +48,9 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl ...@@ -49,9 +48,9 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
accessContralAnalysis.analysisClass(controllerParametersEntity.getAccessContralAnalysisClass()); accessContralAnalysis.analysisClass(controllerParametersEntity.getAccessContralAnalysisClass());
} }
public void setAccessControl(AccessControl accessControl) throws AclPlugAccountAnalysisException { public void setAccessControl(AccessControl accessControl) throws AclPlugRuntimeException {
if (accessControl.getAccount() == null || accessControl.getPassword() == null || accessControl.getAccount().length() <= 6 || accessControl.getPassword().length() <= 6) { if (accessControl.getAccount() == null || accessControl.getPassword() == null || accessControl.getAccount().length() <= 6 || accessControl.getPassword().length() <= 6) {
throw new AclPlugAccountAnalysisException(String.format("The account password cannot be null and is longer than 6, account is %s password is %s", accessControl.getAccount(), accessControl.getPassword())); throw new AclPlugRuntimeException(String.format("The account password cannot be null and is longer than 6, account is %s password is %s", accessControl.getAccount(), accessControl.getPassword()));
} }
try { try {
NetaddressStrategy netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); NetaddressStrategy netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
...@@ -64,22 +63,22 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl ...@@ -64,22 +63,22 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
accessControlAddressMap.put(accessControl.getNetaddress(), authenticationInfo); accessControlAddressMap.put(accessControl.getNetaddress(), authenticationInfo);
log.info("authenticationInfo is {}", authenticationInfo.toString()); log.info("authenticationInfo is {}", authenticationInfo.toString());
} catch (Exception e) { } catch (Exception e) {
throw new AclPlugAccountAnalysisException(accessControl.toString(), e); throw new AclPlugRuntimeException(accessControl.toString(), e);
} }
} }
public void setAccessControlList(List<AccessControl> accessControlList) throws AclPlugAccountAnalysisException { public void setAccessControlList(List<AccessControl> accessControlList) throws AclPlugRuntimeException {
for (AccessControl accessControl : accessControlList) { for (AccessControl accessControl : accessControlList) {
setAccessControl(accessControl); setAccessControl(accessControl);
} }
} }
public void setNetaddressAccessControl(AccessControl accessControl) throws AclPlugAccountAnalysisException { public void setNetaddressAccessControl(AccessControl accessControl) throws AclPlugRuntimeException {
try { try {
authenticationInfo = new AuthenticationInfo(accessContralAnalysis.analysis(accessControl), accessControl, netaddressStrategyFactory.getNetaddressStrategy(accessControl)); authenticationInfo = new AuthenticationInfo(accessContralAnalysis.analysis(accessControl), accessControl, netaddressStrategyFactory.getNetaddressStrategy(accessControl));
log.info("default authenticationInfo is {}", authenticationInfo.toString()); log.info("default authenticationInfo is {}", authenticationInfo.toString());
} catch (Exception e) { } catch (Exception e) {
throw new AclPlugAccountAnalysisException(accessControl.toString(), e); throw new AclPlugRuntimeException(accessControl.toString(), e);
} }
} }
...@@ -106,7 +105,7 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl ...@@ -106,7 +105,7 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
} }
@Override @Override
public AuthenticationResult eachCheckLoginAndAuthentication(LoginOrRequestAccessControl accessControl) { public AuthenticationResult eachCheckLoginAndAuthentication(AccessControl accessControl) {
AuthenticationResult authenticationResult = new AuthenticationResult(); AuthenticationResult authenticationResult = new AuthenticationResult();
try { try {
AuthenticationInfo authenticationInfo = getAuthenticationInfo(accessControl, authenticationResult); AuthenticationInfo authenticationInfo = getAuthenticationInfo(accessControl, authenticationResult);
...@@ -122,7 +121,7 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl ...@@ -122,7 +121,7 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
void setBorkerAccessControlTransport(BorkerAccessControlTransport transport) { void setBorkerAccessControlTransport(BorkerAccessControlTransport transport) {
if (transport.getOnlyNetAddress() == null && (transport.getList() == null || transport.getList().size() == 0)) { if (transport.getOnlyNetAddress() == null && (transport.getList() == null || transport.getList().size() == 0)) {
throw new AclPlugAccountAnalysisException("onlyNetAddress and list can't be all empty"); throw new AclPlugRuntimeException("onlyNetAddress and list can't be all empty");
} }
if (transport.getOnlyNetAddress() != null) { if (transport.getOnlyNetAddress() != null) {
...@@ -135,6 +134,6 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl ...@@ -135,6 +134,6 @@ public abstract class AuthenticationInfoManagementAclPlugEngine implements AclPl
} }
} }
protected abstract AuthenticationInfo getAuthenticationInfo(LoginOrRequestAccessControl accessControl, protected abstract AuthenticationInfo getAuthenticationInfo(AccessControl accessControl,
AuthenticationResult authenticationResult); AuthenticationResult authenticationResult);
} }
...@@ -23,7 +23,6 @@ import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; ...@@ -23,7 +23,6 @@ import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity;
import org.apache.rocketmq.acl.plug.entity.LoginInfo; import org.apache.rocketmq.acl.plug.entity.LoginInfo;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagementAclPlugEngine { public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagementAclPlugEngine {
...@@ -53,7 +52,7 @@ public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagemen ...@@ -53,7 +52,7 @@ public abstract class LoginInfoAclPlugEngine extends AuthenticationInfoManagemen
loginInfoMap.remove(remoteAddr); loginInfoMap.remove(remoteAddr);
} }
protected AuthenticationInfo getAuthenticationInfo(LoginOrRequestAccessControl accessControl, protected AuthenticationInfo getAuthenticationInfo(AccessControl accessControl,
AuthenticationResult authenticationResult) { AuthenticationResult authenticationResult) {
LoginInfo loginInfo = getLoginInfo(accessControl); LoginInfo loginInfo = getLoginInfo(accessControl);
if (loginInfo != null && loginInfo.getAuthenticationInfo() != null) { if (loginInfo != null && loginInfo.getAuthenticationInfo() != null) {
......
...@@ -21,18 +21,18 @@ import java.io.FileInputStream; ...@@ -21,18 +21,18 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport;
import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
public class PlainAclPlugEngine extends LoginInfoAclPlugEngine { public class PlainAclPlugEngine extends LoginInfoAclPlugEngine {
public PlainAclPlugEngine( public PlainAclPlugEngine(
ControllerParametersEntity controllerParametersEntity) throws AclPlugAccountAnalysisException { ControllerParametersEntity controllerParametersEntity) throws AclPlugRuntimeException {
super(controllerParametersEntity); super(controllerParametersEntity);
init(); init();
} }
void init() throws AclPlugAccountAnalysisException { void init() throws AclPlugRuntimeException {
String filePath = controllerParametersEntity.getFileHome() + "/conf/transport.yml"; String filePath = controllerParametersEntity.getFileHome() + "/conf/transport.yml";
Yaml ymal = new Yaml(); Yaml ymal = new Yaml();
FileInputStream fis = null; FileInputStream fis = null;
...@@ -41,18 +41,18 @@ public class PlainAclPlugEngine extends LoginInfoAclPlugEngine { ...@@ -41,18 +41,18 @@ public class PlainAclPlugEngine extends LoginInfoAclPlugEngine {
fis = new FileInputStream(new File(filePath)); fis = new FileInputStream(new File(filePath));
transport = ymal.loadAs(fis, BorkerAccessControlTransport.class); transport = ymal.loadAs(fis, BorkerAccessControlTransport.class);
} catch (Exception e) { } catch (Exception e) {
throw new AclPlugAccountAnalysisException("The transport.yml file for Plain mode was not found", e); throw new AclPlugRuntimeException("The transport.yml file for Plain mode was not found", e);
} finally { } finally {
if (fis != null) { if (fis != null) {
try { try {
fis.close(); fis.close();
} catch (IOException e) { } catch (IOException e) {
throw new AclPlugAccountAnalysisException("close transport fileInputStream Exception", e); throw new AclPlugRuntimeException("close transport fileInputStream Exception", e);
} }
} }
} }
if (transport == null) { if (transport == null) {
throw new AclPlugAccountAnalysisException("transport.yml file is no data"); throw new AclPlugRuntimeException("transport.yml file is no data");
} }
super.setBorkerAccessControlTransport(transport); super.setBorkerAccessControlTransport(transport);
} }
......
...@@ -26,6 +26,10 @@ public class AccessControl { ...@@ -26,6 +26,10 @@ public class AccessControl {
private String recognition; private String recognition;
private int code;
private String topic;
public AccessControl() { public AccessControl() {
} }
...@@ -61,10 +65,29 @@ public class AccessControl { ...@@ -61,10 +65,29 @@ public class AccessControl {
this.recognition = recognition; this.recognition = recognition;
} }
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
@Override @Override
public String toString() { public String toString() {
return "AccessControl [account=" + account + ", password=" + password + ", netaddress=" + netaddress StringBuilder builder = new StringBuilder();
+ ", recognition=" + recognition + "]"; builder.append("AccessControl [account=").append(account).append(", password=").append(password)
.append(", netaddress=").append(netaddress).append(", recognition=").append(recognition)
.append(", code=").append(code).append(", topic=").append(topic).append("]");
return builder.toString();
} }
} }
/*
* 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 LoginOrRequestAccessControl extends AccessControl {
private int code;
private String topic;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("LoginOrRequestAccessControl [code=").append(code).append(", topic=").append(topic).append("]");
return builder.toString();
}
}
/*
* 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);
}
}
/*
* 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);
}
}
/*
* 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);
}
}
/*
* 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);
}
}
/*
* 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);
}
}
/*
* 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;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException;
public abstract class AbstractNetaddressStrategy implements NetaddressStrategy {
public void verify(String netaddress, int index) {
if (!AclUtils.isScope(netaddress, index)) {
throw new AclPlugAccountAnalysisException(String.format("netaddress examine scope Exception netaddress is %s", netaddress));
}
}
}
/*
* 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;
import java.util.Set;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
public class MultipleNetaddressStrategy extends AbstractNetaddressStrategy {
private final Set<String> multipleSet = new HashSet<>();
public MultipleNetaddressStrategy(String[] strArray) {
for (String netaddress : strArray) {
verify(netaddress, 4);
multipleSet.add(netaddress);
}
}
@Override
public boolean match(AccessControl accessControl) {
return multipleSet.contains(accessControl.getNetaddress());
}
}
...@@ -16,23 +16,27 @@ ...@@ -16,23 +16,27 @@
*/ */
package org.apache.rocketmq.acl.plug.strategy; package org.apache.rocketmq.acl.plug.strategy;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.plug.AclUtils; import org.apache.rocketmq.acl.plug.AclUtils;
import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
public class NetaddressStrategyFactory { public class NetaddressStrategyFactory {
public static final NullNetaddressStrategy NULL_NET_ADDRESS_STRATEGY = new NullNetaddressStrategy();
public NetaddressStrategy getNetaddressStrategy(AccessControl accessControl) { public NetaddressStrategy getNetaddressStrategy(AccessControl accessControl) {
String netaddress = accessControl.getNetaddress(); String netaddress = accessControl.getNetaddress();
if (StringUtils.isBlank(netaddress) || "*".equals(netaddress)) { if (StringUtils.isBlank(netaddress) || "*".equals(netaddress)) {
return NullNetaddressStrategy.NULL_NET_ADDRESS_STRATEGY; return NULL_NET_ADDRESS_STRATEGY;
} }
if (netaddress.endsWith("}")) { if (netaddress.endsWith("}")) {
String[] strArray = StringUtils.split(netaddress, "."); String[] strArray = StringUtils.split(netaddress, ".");
String four = strArray[3]; String four = strArray[3];
if (!four.startsWith("{")) { if (!four.startsWith("{")) {
throw new AclPlugAccountAnalysisException(String.format("MultipleNetaddressStrategy netaddress examine scope Exception netaddress", netaddress)); throw new AclPlugRuntimeException(String.format("MultipleNetaddressStrategy netaddress examine scope Exception netaddress", netaddress));
} }
return new MultipleNetaddressStrategy(AclUtils.getAddreeStrArray(netaddress, four)); return new MultipleNetaddressStrategy(AclUtils.getAddreeStrArray(netaddress, four));
} else if (AclUtils.isColon(netaddress)) { } else if (AclUtils.isColon(netaddress)) {
...@@ -43,4 +47,114 @@ public class NetaddressStrategyFactory { ...@@ -43,4 +47,114 @@ public class NetaddressStrategyFactory {
return new OneNetaddressStrategy(netaddress); return new OneNetaddressStrategy(netaddress);
} }
public static class NullNetaddressStrategy implements NetaddressStrategy {
@Override
public boolean match(AccessControl accessControl) {
return true;
}
}
public static class MultipleNetaddressStrategy implements NetaddressStrategy {
private final Set<String> multipleSet = new HashSet<>();
public MultipleNetaddressStrategy(String[] strArray) {
for (String netaddress : strArray) {
AclUtils.verify(netaddress, 4);
multipleSet.add(netaddress);
}
}
@Override
public boolean match(AccessControl accessControl) {
return multipleSet.contains(accessControl.getNetaddress());
}
}
public static class OneNetaddressStrategy implements NetaddressStrategy {
private String netaddress;
public OneNetaddressStrategy(String netaddress) {
this.netaddress = netaddress;
AclUtils.verify(netaddress, 4);
}
@Override
public boolean match(AccessControl accessControl) {
return netaddress.equals(accessControl.getNetaddress());
}
}
public static class RangeNetaddressStrategy implements NetaddressStrategy {
private String head;
private int start;
private int end;
private int index;
public RangeNetaddressStrategy(String netaddress) {
String[] strArray = StringUtils.split(netaddress, ".");
if (analysis(strArray, 2) || analysis(strArray, 3)) {
AclUtils.verify(netaddress, index - 1);
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) {
String value = strArray[index].trim();
this.index = index;
if ("*".equals(value)) {
setValue(0, 255);
} else if (AclUtils.isMinus(value)) {
if (value.indexOf("-") == 0) {
throw new AclPlugRuntimeException(String.format("RangeNetaddressStrategy netaddress examine scope Exception value %s ", 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)) {
throw new AclPlugRuntimeException(String.format("RangeNetaddressStrategy netaddress examine scope Exception start is %s , end is %s", start, end));
}
}
return this.end > 0 ? true : false;
}
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)) {
String value;
if (index == 3) {
value = netAddress.substring(this.head.length());
} else {
value = netAddress.substring(this.head.length(), netAddress.lastIndexOf('.'));
}
Integer address = Integer.valueOf(value);
if (address >= this.start && address <= this.end) {
return true;
}
}
return false;
}
}
} }
/*
* 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 NullNetaddressStrategy implements NetaddressStrategy {
public static final NullNetaddressStrategy NULL_NET_ADDRESS_STRATEGY = new NullNetaddressStrategy();
@Override
public boolean match(AccessControl accessControl) {
return true;
}
}
/*
* 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) {
this.netaddress = netaddress;
verify(netaddress, 4);
}
@Override
public boolean match(AccessControl accessControl) {
return netaddress.equals(accessControl.getNetaddress());
}
}
/*
* 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;
import org.apache.rocketmq.acl.plug.AclUtils;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException;
public class RangeNetaddressStrategy extends AbstractNetaddressStrategy {
private String head;
private int start;
private int end;
private int index;
public RangeNetaddressStrategy(String netaddress) {
String[] strArray = StringUtils.split(netaddress, ".");
if (analysis(strArray, 2) || analysis(strArray, 3)) {
verify(netaddress, index - 1);
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) {
String value = strArray[index].trim();
this.index = index;
if ("*".equals(value)) {
setValue(0, 255);
} else if (AclUtils.isMinus(value)) {
if (value.indexOf("-") == 0) {
throw new AclPlugAccountAnalysisException(String.format("RangeNetaddressStrategy netaddress examine scope Exception value %s ", 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)) {
throw new AclPlugAccountAnalysisException(String.format("RangeNetaddressStrategy netaddress examine scope Exception start is %s , end is %s", start, end));
}
}
return this.end > 0 ? true : false;
}
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)) {
String value;
if (index == 3) {
value = netAddress.substring(this.head.length());
} else {
value = netAddress.substring(this.head.length(), netAddress.lastIndexOf('.'));
}
Integer address = Integer.valueOf(value);
if (address >= this.start && address <= this.end) {
return true;
}
}
return false;
}
}
...@@ -21,7 +21,7 @@ import java.util.Map; ...@@ -21,7 +21,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.common.protocol.RequestCode;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
...@@ -54,7 +54,7 @@ public class AccessContralAnalysisTest { ...@@ -54,7 +54,7 @@ public class AccessContralAnalysisTest {
Assert.assertEquals(num, 1); Assert.assertEquals(num, 1);
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void analysisExceptionTest() { public void analysisExceptionTest() {
AccessControl accessControl = new AccessControl(); AccessControl accessControl = new AccessControl();
accessContralAnalysis.analysis(accessControl); accessContralAnalysis.analysis(accessControl);
......
...@@ -19,11 +19,11 @@ package org.apache.rocketmq.acl.plug; ...@@ -19,11 +19,11 @@ package org.apache.rocketmq.acl.plug;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo;
import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl; import org.apache.rocketmq.acl.plug.strategy.NetaddressStrategyFactory;
import org.apache.rocketmq.acl.plug.strategy.OneNetaddressStrategy;
import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.common.protocol.RequestCode;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
...@@ -38,11 +38,10 @@ public class AuthenticationTest { ...@@ -38,11 +38,10 @@ public class AuthenticationTest {
BorkerAccessControl borkerAccessControl; BorkerAccessControl borkerAccessControl;
AuthenticationResult authenticationResult = new AuthenticationResult(); AuthenticationResult authenticationResult = new AuthenticationResult();
LoginOrRequestAccessControl loginOrRequestAccessControl = new LoginOrRequestAccessControl(); AccessControl accessControl = new AccessControl();
@Before @Before
public void init() { public void init() {
OneNetaddressStrategy netaddressStrategy = new OneNetaddressStrategy("127.0.0.1");
borkerAccessControl = new BorkerAccessControl(); borkerAccessControl = new BorkerAccessControl();
//321 //321
borkerAccessControl.setQueryConsumeQueue(false); borkerAccessControl.setQueryConsumeQueue(false);
...@@ -67,75 +66,75 @@ public class AuthenticationTest { ...@@ -67,75 +66,75 @@ public class AuthenticationTest {
accessContralAnalysis.analysisClass(RequestCode.class); accessContralAnalysis.analysisClass(RequestCode.class);
Map<Integer, Boolean> map = accessContralAnalysis.analysis(borkerAccessControl); Map<Integer, Boolean> map = accessContralAnalysis.analysis(borkerAccessControl);
authenticationInfo = new AuthenticationInfo(map, borkerAccessControl, netaddressStrategy); authenticationInfo = new AuthenticationInfo(map, borkerAccessControl, NetaddressStrategyFactory.NULL_NET_ADDRESS_STRATEGY);
} }
@Test @Test
public void authenticationTest() { public void authenticationTest() {
loginOrRequestAccessControl.setCode(317); accessControl.setCode(317);
boolean isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); boolean isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
loginOrRequestAccessControl.setCode(321); accessControl.setCode(321);
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
loginOrRequestAccessControl.setCode(10); accessControl.setCode(10);
loginOrRequestAccessControl.setTopic("permitSendTopic"); accessControl.setTopic("permitSendTopic");
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
loginOrRequestAccessControl.setCode(310); accessControl.setCode(310);
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
loginOrRequestAccessControl.setCode(320); accessControl.setCode(320);
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
loginOrRequestAccessControl.setTopic("noPermitSendTopic"); accessControl.setTopic("noPermitSendTopic");
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
loginOrRequestAccessControl.setTopic("nopermitSendTopic"); accessControl.setTopic("nopermitSendTopic");
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
loginOrRequestAccessControl.setCode(11); accessControl.setCode(11);
loginOrRequestAccessControl.setTopic("permitPullTopic"); accessControl.setTopic("permitPullTopic");
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
loginOrRequestAccessControl.setTopic("noPermitPullTopic"); accessControl.setTopic("noPermitPullTopic");
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
loginOrRequestAccessControl.setTopic("nopermitPullTopic"); accessControl.setTopic("nopermitPullTopic");
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
} }
@Test @Test
public void isEmptyTest() { public void isEmptyTest() {
loginOrRequestAccessControl.setCode(10); accessControl.setCode(10);
loginOrRequestAccessControl.setTopic("absentTopic"); accessControl.setTopic("absentTopic");
boolean isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); boolean isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
Set<String> permitSendTopic = new HashSet<>(); Set<String> permitSendTopic = new HashSet<>();
borkerAccessControl.setPermitSendTopic(permitSendTopic); borkerAccessControl.setPermitSendTopic(permitSendTopic);
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
loginOrRequestAccessControl.setCode(11); accessControl.setCode(11);
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertFalse(isReturn); Assert.assertFalse(isReturn);
borkerAccessControl.setPermitPullTopic(permitSendTopic); borkerAccessControl.setPermitPullTopic(permitSendTopic);
isReturn = authentication.authentication(authenticationInfo, loginOrRequestAccessControl, authenticationResult); isReturn = authentication.authentication(authenticationInfo, accessControl, authenticationResult);
Assert.assertTrue(isReturn); Assert.assertTrue(isReturn);
} }
......
...@@ -30,8 +30,7 @@ import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl; ...@@ -30,8 +30,7 @@ import org.apache.rocketmq.acl.plug.entity.BorkerAccessControl;
import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport; import org.apache.rocketmq.acl.plug.entity.BorkerAccessControlTransport;
import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity;
import org.apache.rocketmq.acl.plug.entity.LoginInfo; import org.apache.rocketmq.acl.plug.entity.LoginInfo;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException;
import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.MixAll;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
...@@ -83,31 +82,31 @@ public class PlainAclPlugEngineTest { ...@@ -83,31 +82,31 @@ public class PlainAclPlugEngineTest {
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void accountNullTest() { public void accountNullTest() {
accessControl.setAccount(null); accessControl.setAccount(null);
plainAclPlugEngine.setAccessControl(accessControl); plainAclPlugEngine.setAccessControl(accessControl);
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void accountThanTest() { public void accountThanTest() {
accessControl.setAccount("123"); accessControl.setAccount("123");
plainAclPlugEngine.setAccessControl(accessControl); plainAclPlugEngine.setAccessControl(accessControl);
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void passWordtNullTest() { public void passWordtNullTest() {
accessControl.setAccount(null); accessControl.setAccount(null);
plainAclPlugEngine.setAccessControl(accessControl); plainAclPlugEngine.setAccessControl(accessControl);
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void passWordThanTest() { public void passWordThanTest() {
accessControl.setAccount("123"); accessControl.setAccount("123");
plainAclPlugEngine.setAccessControl(accessControl); plainAclPlugEngine.setAccessControl(accessControl);
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void testPlainAclPlugEngineInit() { public void testPlainAclPlugEngineInit() {
ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity(); ControllerParametersEntity controllerParametersEntity = new ControllerParametersEntity();
new PlainAclPlugEngine(controllerParametersEntity); new PlainAclPlugEngine(controllerParametersEntity);
...@@ -186,7 +185,7 @@ public class PlainAclPlugEngineTest { ...@@ -186,7 +185,7 @@ public class PlainAclPlugEngineTest {
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void borkerAccessControlTransportTestNull() { public void borkerAccessControlTransportTestNull() {
plainAclPlugEngine.setBorkerAccessControlTransport(new BorkerAccessControlTransport()); plainAclPlugEngine.setBorkerAccessControlTransport(new BorkerAccessControlTransport());
} }
...@@ -241,18 +240,18 @@ public class PlainAclPlugEngineTest { ...@@ -241,18 +240,18 @@ public class PlainAclPlugEngineTest {
@Test @Test
public void getAuthenticationInfo() { public void getAuthenticationInfo() {
LoginOrRequestAccessControl loginOrRequestAccessControl = new LoginOrRequestAccessControl(); AccessControl AccessControl = new AccessControl();
loginOrRequestAccessControl.setAccount("rokcetmq"); AccessControl.setAccount("rokcetmq");
loginOrRequestAccessControl.setPassword("aliyun11"); AccessControl.setPassword("aliyun11");
loginOrRequestAccessControl.setNetaddress("127.0.0.1"); AccessControl.setNetaddress("127.0.0.1");
loginOrRequestAccessControl.setRecognition("127.0.0.1:1"); AccessControl.setRecognition("127.0.0.1:1");
AuthenticationResult authenticationResult = new AuthenticationResult(); AuthenticationResult authenticationResult = new AuthenticationResult();
plainAclPlugEngine.getAuthenticationInfo(loginOrRequestAccessControl, authenticationResult); plainAclPlugEngine.getAuthenticationInfo(AccessControl, authenticationResult);
Assert.assertEquals("Login information does not exist, Please check login, password, IP", authenticationResult.getResultString()); Assert.assertEquals("Login information does not exist, Please check login, password, IP", authenticationResult.getResultString());
plainAclPlugEngine.setAccessControl(accessControl); plainAclPlugEngine.setAccessControl(accessControl);
AuthenticationInfo authenticationInfo = plainAclPlugEngine.getAuthenticationInfo(loginOrRequestAccessControl, authenticationResult); AuthenticationInfo authenticationInfo = plainAclPlugEngine.getAuthenticationInfo(AccessControl, authenticationResult);
Assert.assertNotNull(authenticationInfo); Assert.assertNotNull(authenticationInfo);
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
package org.apache.rocketmq.acl.plug.strategy; package org.apache.rocketmq.acl.plug.strategy;
import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.exception.AclPlugAccountAnalysisException; import org.apache.rocketmq.acl.plug.exception.AclPlugRuntimeException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
...@@ -29,53 +29,57 @@ public class NetaddressStrategyTest { ...@@ -29,53 +29,57 @@ public class NetaddressStrategyTest {
public void NetaddressStrategyFactoryTest() { public void NetaddressStrategyFactoryTest() {
AccessControl accessControl = new AccessControl(); AccessControl accessControl = new AccessControl();
NetaddressStrategy netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); NetaddressStrategy netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy, NullNetaddressStrategy.NULL_NET_ADDRESS_STRATEGY); Assert.assertEquals(netaddressStrategy, NetaddressStrategyFactory.NULL_NET_ADDRESS_STRATEGY);
accessControl.setNetaddress("*"); accessControl.setNetaddress("*");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy, NullNetaddressStrategy.NULL_NET_ADDRESS_STRATEGY); Assert.assertEquals(netaddressStrategy, NetaddressStrategyFactory.NULL_NET_ADDRESS_STRATEGY);
accessControl.setNetaddress("127.0.0.1"); accessControl.setNetaddress("127.0.0.1");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy.getClass(), OneNetaddressStrategy.class); Assert.assertEquals(netaddressStrategy.getClass(), NetaddressStrategyFactory.OneNetaddressStrategy.class);
accessControl.setNetaddress("127.0.0.1,127.0.0.2,127.0.0.3"); accessControl.setNetaddress("127.0.0.1,127.0.0.2,127.0.0.3");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy.getClass(), MultipleNetaddressStrategy.class); Assert.assertEquals(netaddressStrategy.getClass(), NetaddressStrategyFactory.MultipleNetaddressStrategy.class);
accessControl.setNetaddress("127.0.0.{1,2,3}"); accessControl.setNetaddress("127.0.0.{1,2,3}");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy.getClass(), MultipleNetaddressStrategy.class); Assert.assertEquals(netaddressStrategy.getClass(), NetaddressStrategyFactory.MultipleNetaddressStrategy.class);
accessControl.setNetaddress("127.0.0.1-200"); accessControl.setNetaddress("127.0.0.1-200");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy.getClass(), RangeNetaddressStrategy.class); Assert.assertEquals(netaddressStrategy.getClass(), NetaddressStrategyFactory.RangeNetaddressStrategy.class);
accessControl.setNetaddress("127.0.0.*"); accessControl.setNetaddress("127.0.0.*");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy.getClass(), RangeNetaddressStrategy.class); Assert.assertEquals(netaddressStrategy.getClass(), NetaddressStrategyFactory.RangeNetaddressStrategy.class);
accessControl.setNetaddress("127.0.1-20.*"); accessControl.setNetaddress("127.0.1-20.*");
netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl); netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
Assert.assertEquals(netaddressStrategy.getClass(), RangeNetaddressStrategy.class); Assert.assertEquals(netaddressStrategy.getClass(), NetaddressStrategyFactory.RangeNetaddressStrategy.class);
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void verifyTest() { public void verifyTest() {
new OneNetaddressStrategy("127.0.0.1"); AccessControl accessControl = new AccessControl();
accessControl.setNetaddress("127.0.0.1");
new OneNetaddressStrategy("256.0.0.1"); netaddressStrategyFactory.getNetaddressStrategy(accessControl);
accessControl.setNetaddress("256.0.0.1");
netaddressStrategyFactory.getNetaddressStrategy(accessControl);
} }
@Test @Test
public void nullNetaddressStrategyTest() { public void nullNetaddressStrategyTest() {
boolean isMatch = NullNetaddressStrategy.NULL_NET_ADDRESS_STRATEGY.match(new AccessControl()); boolean isMatch = NetaddressStrategyFactory.NULL_NET_ADDRESS_STRATEGY.match(new AccessControl());
Assert.assertTrue(isMatch); Assert.assertTrue(isMatch);
} }
public void oneNetaddressStrategyTest() { public void oneNetaddressStrategyTest() {
OneNetaddressStrategy netaddressStrategy = new OneNetaddressStrategy("127.0.0.1");
AccessControl accessControl = new AccessControl(); AccessControl accessControl = new AccessControl();
accessControl.setNetaddress("127.0.0.1");
NetaddressStrategy netaddressStrategy = netaddressStrategyFactory.getNetaddressStrategy(accessControl);
accessControl.setNetaddress("");
boolean match = netaddressStrategy.match(accessControl); boolean match = netaddressStrategy.match(accessControl);
Assert.assertFalse(match); Assert.assertFalse(match);
...@@ -101,7 +105,7 @@ public class NetaddressStrategyTest { ...@@ -101,7 +105,7 @@ public class NetaddressStrategyTest {
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void multipleNetaddressStrategyExceptionTest() { public void multipleNetaddressStrategyExceptionTest() {
AccessControl accessControl = new AccessControl(); AccessControl accessControl = new AccessControl();
accessControl.setNetaddress("127.0.0.1,2,3}"); accessControl.setNetaddress("127.0.0.1,2,3}");
...@@ -174,17 +178,17 @@ public class NetaddressStrategyTest { ...@@ -174,17 +178,17 @@ public class NetaddressStrategyTest {
} }
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void rangeNetaddressStrategyExceptionStartGreaterEndTest() { public void rangeNetaddressStrategyExceptionStartGreaterEndTest() {
rangeNetaddressStrategyExceptionTest("127.0.0.2-1"); rangeNetaddressStrategyExceptionTest("127.0.0.2-1");
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void rangeNetaddressStrategyExceptionScopeTest() { public void rangeNetaddressStrategyExceptionScopeTest() {
rangeNetaddressStrategyExceptionTest("127.0.0.-1-200"); rangeNetaddressStrategyExceptionTest("127.0.0.-1-200");
} }
@Test(expected = AclPlugAccountAnalysisException.class) @Test(expected = AclPlugRuntimeException.class)
public void rangeNetaddressStrategyExceptionScopeTwoTest() { public void rangeNetaddressStrategyExceptionScopeTwoTest() {
rangeNetaddressStrategyExceptionTest("127.0.0.0-256"); rangeNetaddressStrategyExceptionTest("127.0.0.0-256");
} }
......
...@@ -16,19 +16,19 @@ ...@@ -16,19 +16,19 @@
onlyNetAddress: onlyNetAddress:
netaddress: 10.10.103.* netaddress: 10.10.103.*
noPermitPullTopic: noPermitPullTopic:
- broker-a - broker-a
list: list:
- account: RocketMQ - account: RocketMQ
password: 1234567 password: 1234567
netaddress: 192.0.0.* netaddress: 192.0.0.*
permitSendTopic: permitSendTopic:
- test1 - test1
- test2 - test2
- account: RocketMQ - account: RocketMQ
password: 1234567 password: 1234567
netaddress: 192.0.2.1 netaddress: 192.0.2.1
permitSendTopic: permitSendTopic:
- test3 - test3
- test4 - test4
\ No newline at end of file
...@@ -32,11 +32,12 @@ import java.util.concurrent.LinkedBlockingQueue; ...@@ -32,11 +32,12 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.plug.AclPlugController; import org.apache.rocketmq.acl.plug.AclPlugController;
import org.apache.rocketmq.acl.plug.AclRemotingServer; import org.apache.rocketmq.acl.plug.AclRemotingServer;
import org.apache.rocketmq.acl.plug.entity.AccessControl;
import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity; import org.apache.rocketmq.acl.plug.entity.ControllerParametersEntity;
import org.apache.rocketmq.acl.plug.entity.LoginOrRequestAccessControl;
import org.apache.rocketmq.broker.client.ClientHousekeepingService; import org.apache.rocketmq.broker.client.ClientHousekeepingService;
import org.apache.rocketmq.broker.client.ConsumerIdsChangeListener; import org.apache.rocketmq.broker.client.ConsumerIdsChangeListener;
import org.apache.rocketmq.broker.client.ConsumerManager; import org.apache.rocketmq.broker.client.ConsumerManager;
...@@ -515,7 +516,7 @@ public class BrokerController { ...@@ -515,7 +516,7 @@ public class BrokerController {
@Override @Override
public void doBeforeRequest(String remoteAddr, RemotingCommand request) { public void doBeforeRequest(String remoteAddr, RemotingCommand request) {
HashMap<String, String> extFields = request.getExtFields(); HashMap<String, String> extFields = request.getExtFields();
LoginOrRequestAccessControl accessControl = new LoginOrRequestAccessControl(); AccessControl accessControl = new AccessControl();
accessControl.setCode(request.getCode()); accessControl.setCode(request.getCode());
accessControl.setRecognition(remoteAddr); accessControl.setRecognition(remoteAddr);
if (extFields != null) { if (extFields != null) {
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
limitations under the License. limitations under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<groupId>org.apache</groupId> <groupId>org.apache</groupId>
...@@ -158,7 +159,7 @@ ...@@ -158,7 +159,7 @@
</executions> </executions>
<configuration> <configuration>
<rules> <rules>
<banCircularDependencies /> <banCircularDependencies/>
</rules> </rules>
<fail>true</fail> <fail>true</fail>
</configuration> </configuration>
...@@ -215,9 +216,9 @@ ...@@ -215,9 +216,9 @@
<execution> <execution>
<id>generate-effective-dependencies-pom</id> <id>generate-effective-dependencies-pom</id>
<phase>generate-resources</phase> <phase>generate-resources</phase>
<!-- <goals> <goals>
<goal>effective-pom</goal> <goal>effective-pom</goal>
</goals> --> </goals>
<configuration> <configuration>
<output>${project.build.directory}/effective-pom/effective-dependencies.xml</output> <output>${project.build.directory}/effective-pom/effective-dependencies.xml</output>
</configuration> </configuration>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册