From 93b201d43a4263bc9b7e6e31c542255440a7cb39 Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 3 Jun 2015 17:15:57 +0000 Subject: [PATCH] Allow custom command role ACL files on classpath in Static Role API Checker. This commit has a small refactoring of cloud-plugin-acl-static-role-based to allow it to read files on the classpath that might have a different name than "commands.properties". It also allows more than one file to be read from. Rationale: Third-party plugins may want to keep their API command access level configuration separate from the main file so as to reduce configuration maintenance work during packaging and deployments. Signed-off-by: Rohit Yadav This closes #354 --- .../spring-acl-static-role-based-context.xml | 5 +++++ .../acl/StaticRoleBasedAPIAccessChecker.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/acl/static-role-based/resources/META-INF/cloudstack/acl-static-role-based/spring-acl-static-role-based-context.xml b/plugins/acl/static-role-based/resources/META-INF/cloudstack/acl-static-role-based/spring-acl-static-role-based-context.xml index f13acc190b6..0b222837f4c 100644 --- a/plugins/acl/static-role-based/resources/META-INF/cloudstack/acl-static-role-based/spring-acl-static-role-based-context.xml +++ b/plugins/acl/static-role-based/resources/META-INF/cloudstack/acl-static-role-based/spring-acl-static-role-based-context.xml @@ -29,6 +29,11 @@ + + + commands.properties + + diff --git a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java index 1316a92ccb1..4383b4573f9 100644 --- a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java +++ b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java @@ -45,6 +45,7 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC protected static final Logger s_logger = Logger.getLogger(StaticRoleBasedAPIAccessChecker.class); + Set commandPropertyFiles = new HashSet(); Set commandsPropertiesOverrides = new HashSet(); Map> commandsPropertiesRoleBasedApisMap = new HashMap>(); Map> annotationRoleBasedApisMap = new HashMap>(); @@ -84,7 +85,9 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC public boolean configure(String name, Map params) throws ConfigurationException { super.configure(name, params); - processMapping(PropertiesUtil.processConfigFile(new String[] {"commands.properties"})); + for (String commandPropertyFile : commandPropertyFiles) { + processMapping(PropertiesUtil.processConfigFile(new String[] { commandPropertyFile })); + } return true; } @@ -129,4 +132,12 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC this._services = services; } + public Set getCommandPropertyFiles() { + return commandPropertyFiles; + } + + public void setCommandPropertyFiles(Set commandPropertyFiles) { + this.commandPropertyFiles = commandPropertyFiles; + } + }