Repository: incubator-ranger
Updated Branches:
  refs/heads/stack ee9ecde98 -> cc5e3f714


RANGER-203: renamed "impliedAccessGrants" to "impliedGrants". Replaced
ServiceDefManager/ServiceManager with
ServiceDefStoreFactory/ServiceStoreFactory.

Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/cc5e3f71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/cc5e3f71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/cc5e3f71

Branch: refs/heads/stack
Commit: cc5e3f71491d749dc0200f7c01c5827d8a5de073
Parents: ee9ecde
Author: Madhan Neethiraj <[email protected]>
Authored: Fri Jan 9 17:42:29 2015 -0800
Committer: Madhan Neethiraj <[email protected]>
Committed: Fri Jan 9 17:42:29 2015 -0800

----------------------------------------------------------------------
 .../plugin/manager/ServiceDefManager.java       | 141 -----------
 .../ranger/plugin/manager/ServiceManager.java   | 250 -------------------
 .../ranger/plugin/model/RangerServiceDef.java   |  46 ++--
 .../RangerDefaultPolicyEvaluator.java           |  12 +-
 .../plugin/store/ServiceDefStoreFactory.java    |  70 ++++++
 .../plugin/store/ServiceStoreFactory.java       |  70 ++++++
 .../service-defs/ranger-servicedef-hbase.json   |   2 +-
 .../plugin/manager/TestServiceManager.java      | 203 ---------------
 .../ranger/plugin/store/TestServiceStore.java   | 205 +++++++++++++++
 .../policyengine/test_policyengine_hbase.json   |   2 +-
 .../org/apache/ranger/rest/ServiceREST.java     |  53 ++--
 11 files changed, 405 insertions(+), 649 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceDefManager.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceDefManager.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceDefManager.java
deleted file mode 100644
index ce7dbf0..0000000
--- 
a/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceDefManager.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.ranger.plugin.manager;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ranger.plugin.model.RangerServiceDef;
-import org.apache.ranger.plugin.store.ServiceDefStore;
-import org.apache.ranger.plugin.store.file.ServiceDefFileStore;
-
-
-public class ServiceDefManager {
-       private static final Log LOG = 
LogFactory.getLog(ServiceDefManager.class);
-
-       private ServiceDefStore sdStore = null;
-
-       public ServiceDefManager() {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.ServiceDefManager()");
-               }
-
-               init();
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.ServiceDefManager()");
-               }
-       }
-
-       public RangerServiceDef create(RangerServiceDef serviceDef) throws 
Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.create(" + serviceDef 
+ ")");
-               }
-
-               RangerServiceDef ret = sdStore.create(serviceDef);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.create(" + serviceDef 
+ "): " + ret);
-               }
-
-               return ret;
-       }
-
-       public RangerServiceDef update(RangerServiceDef serviceDef) throws 
Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.update(" + serviceDef 
+ ")");
-               }
-
-               RangerServiceDef ret = sdStore.update(serviceDef);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.update(" + serviceDef 
+ "): " + ret);
-               }
-
-               return ret;
-       }
-
-       public void delete(Long id) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.delete(" + id + ")");
-               }
-
-               sdStore.delete(id);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.delete(" + id + ")");
-               }
-       }
-
-       public RangerServiceDef get(Long id) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.get(" + id + ")");
-               }
-
-               RangerServiceDef ret = sdStore.get(id);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.get(" + id + ")");
-               }
-
-               return ret;
-       }
-
-       public RangerServiceDef getByName(String name) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.getByName(" + name + 
")");
-               }
-
-               RangerServiceDef ret = sdStore.getByName(name);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.getByName(" + name + 
"): " + ret);
-               }
-
-               return ret;
-       }
-
-       public List<RangerServiceDef> getAll() throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.getAll()");
-               }
-
-               List<RangerServiceDef> ret = sdStore.getAll();
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.getAll(): count=" + 
(ret == null ? 0 : ret.size()));
-               }
-
-               return ret;
-       }
-
-       private void init() {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceDefManager.init()");
-               }
-
-               sdStore = new ServiceDefFileStore(); // TODO: store type should 
be configurable
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceDefManager.init()");
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceManager.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceManager.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceManager.java
deleted file mode 100644
index 7b947ea..0000000
--- 
a/plugin-common/src/main/java/org/apache/ranger/plugin/manager/ServiceManager.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * 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.ranger.plugin.manager;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ranger.plugin.model.RangerPolicy;
-import org.apache.ranger.plugin.model.RangerService;
-import org.apache.ranger.plugin.store.ServiceStore;
-import org.apache.ranger.plugin.store.file.ServiceFileStore;
-
-
-public class ServiceManager {
-       private static final Log LOG = LogFactory.getLog(ServiceManager.class);
-
-       private ServiceStore svcStore = null;
-
-       public ServiceManager() {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.ServiceManager()");
-               }
-
-               init();
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.ServiceManager()");
-               }
-       }
-
-       public RangerService create(RangerService service) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.create(" + service + ")");
-               }
-
-               RangerService ret = svcStore.create(service);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.create(" + service + "): 
" + ret);
-               }
-
-               return ret;
-       }
-
-       public RangerService update(RangerService service) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.update(" + service + ")");
-               }
-
-               RangerService ret = svcStore.update(service);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.update(" + service + "): 
" + ret);
-               }
-
-               return ret;
-       }
-
-       public void delete(Long id) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.delete(" + id + ")");
-               }
-
-               svcStore.delete(id);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.delete(" + id + ")");
-               }
-       }
-
-       public RangerService get(Long id) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.get(" + id + ")");
-               }
-
-               RangerService ret = svcStore.get(id);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.get(" + id + "): " + ret);
-               }
-
-               return ret;
-       }
-
-       public RangerService getByName(String name) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.getByName(" + name + ")");
-               }
-
-               RangerService ret = svcStore.getByName(name);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.getByName(" + name + "): 
" + ret);
-               }
-
-               return ret;
-       }
-
-       public List<RangerService> getAll() throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.getAll()");
-               }
-
-               List<RangerService> ret = svcStore.getAll();
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.getAll(): count=" + (ret 
== null ? 0 : ret.size()));
-               }
-
-               return ret;
-       }
-
-       public void validateConfig(RangerService service) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.validateConfig(" + 
service + ")");
-               }
-
-               // TODO: call validateConfig() on the implClass
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.validateConfig(" + 
service + ")");
-               }
-       }
-
-       public RangerPolicy createPolicy(RangerPolicy policy) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.createPolicy(" + policy + 
")");
-               }
-
-               RangerPolicy ret = svcStore.createPolicy(policy);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.createPolicy(" + policy + 
"): " + ret);
-               }
-
-               return ret;
-       }
-
-       public RangerPolicy updatePolicy(RangerPolicy policy) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.updatePolicy(" + policy + 
")");
-               }
-
-               RangerPolicy ret = svcStore.updatePolicy(policy);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.updatePolicy(" + policy + 
"): " + ret);
-               }
-
-               return ret;
-       }
-
-       public void deletePolicy(Long id) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.deletePolicy(" + id + 
")");
-               }
-
-               svcStore.deletePolicy(id);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.deletePolicy(" + id + 
")");
-               }
-       }
-
-       public RangerPolicy getPolicy(Long id) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.getPolicy(" + id + ")");
-               }
-
-               RangerPolicy ret = svcStore.getPolicy(id);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.getPolicy(" + id + "): " 
+ ret);
-               }
-
-               return ret;
-       }
-
-       public List<RangerPolicy> getPolicies(Long svcId) throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.getPolicies(" + svcId + 
")");
-               }
-
-               List<RangerPolicy> ret = svcStore.getServicePolicies(svcId);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.getPolicies(" + svcId + 
"): count=" + (ret == null ? 0 : ret.size()));
-               }
-
-               return ret;
-       }
-
-       public RangerPolicy getPolicyByName(String svcName, String policyName) 
throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.getPolicyByName(" + 
svcName + "," + policyName + ")");
-               }
-
-               RangerPolicy ret = svcStore.getPolicyByName(svcName, 
policyName);
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.getPolicyByName(" + 
svcName + "," + policyName + "): " + ret);
-               }
-
-               return ret;
-       }
-
-       public List<RangerPolicy> getAllPolicies() throws Exception {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.getAllPolicies()");
-               }
-
-               List<RangerPolicy> ret = svcStore.getAllPolicies();
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== getAllPolicies.getAll(): count=" + (ret 
== null ? 0 : ret.size()));
-               }
-
-               return ret;
-       }
-
-       private void init() {
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("==> ServiceManager.init()");
-               }
-
-               svcStore = new ServiceFileStore(); // TODO: store type should 
be configurable
-
-               if(LOG.isDebugEnabled()) {
-                       LOG.debug("<== ServiceManager.init()");
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/java/org/apache/ranger/plugin/model/RangerServiceDef.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/model/RangerServiceDef.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/model/RangerServiceDef.java
index 53bab5c..f1fe7a8 100644
--- 
a/plugin-common/src/main/java/org/apache/ranger/plugin/model/RangerServiceDef.java
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/model/RangerServiceDef.java
@@ -1023,21 +1023,21 @@ public class RangerServiceDef extends 
RangerBaseModelObject implements java.io.S
        public static class RangerAccessTypeDef implements java.io.Serializable 
{
                private static final long serialVersionUID = 1L;
 
-               private String             name                = null;
-               private String             label               = null;
-               private String             rbKeyLabel          = null;
-               private Collection<String> impliedAccessGrants = null;
+               private String             name          = null;
+               private String             label         = null;
+               private String             rbKeyLabel    = null;
+               private Collection<String> impliedGrants = null;
 
 
                public RangerAccessTypeDef() {
                        this(null, null, null, null);
                }
 
-               public RangerAccessTypeDef(String name, String label, String 
rbKeyLabel, Collection<String> impliedAccessGrants) {
+               public RangerAccessTypeDef(String name, String label, String 
rbKeyLabel, Collection<String> impliedGrants) {
                        setName(name);
                        setLabel(label);
                        setRbKeyLabel(rbKeyLabel);
-                       setImpliedAccessGrants(impliedAccessGrants);
+                       setImpliedGrants(impliedGrants);
                }
 
                /**
@@ -1083,29 +1083,29 @@ public class RangerServiceDef extends 
RangerBaseModelObject implements java.io.S
                }
 
                /**
-                * @return the impliedAccessGrants
+                * @return the impliedGrants
                 */
-               public Collection<String> getImpliedAccessGrants() {
-                       return impliedAccessGrants;
+               public Collection<String> getImpliedGrants() {
+                       return impliedGrants;
                }
 
                /**
-                * @param impliedAccessGrants the impliedAccessGrants to set
+                * @param impliedGrants the impliedGrants to set
                 */
-               public void setImpliedAccessGrants(Collection<String> 
impliedAccessGrants) {
-                       if(this.impliedAccessGrants == null) {
-                               this.impliedAccessGrants = new 
ArrayList<String>();
+               public void setImpliedGrants(Collection<String> impliedGrants) {
+                       if(this.impliedGrants == null) {
+                               this.impliedGrants = new ArrayList<String>();
                        }
 
-                       if(this.impliedAccessGrants == impliedAccessGrants) {
+                       if(this.impliedGrants == impliedGrants) {
                                return;
                        }
 
-                       this.impliedAccessGrants.clear();
+                       this.impliedGrants.clear();
 
-                       if(impliedAccessGrants != null) {
-                               for(String impliedAccessGrant : 
impliedAccessGrants) {
-                                       
this.impliedAccessGrants.add(impliedAccessGrant);
+                       if(impliedGrants != null) {
+                               for(String impliedGrant : impliedGrants) {
+                                       this.impliedGrants.add(impliedGrant);
                                }
                        }
                }
@@ -1125,11 +1125,11 @@ public class RangerServiceDef extends 
RangerBaseModelObject implements java.io.S
                        sb.append("label={").append(label).append("} ");
                        sb.append("rbKeyLabel={").append(rbKeyLabel).append("} 
");
 
-                       sb.append("impliedAccessGrants={");
-                       if(impliedAccessGrants != null) {
-                               for(String impliedAccessGrant : 
impliedAccessGrants) {
-                                       if(impliedAccessGrant != null) {
-                                               
sb.append(impliedAccessGrant).append(" ");
+                       sb.append("impliedGrants={");
+                       if(impliedGrants != null) {
+                               for(String impliedGrant : impliedGrants) {
+                                       if(impliedGrant != null) {
+                                               
sb.append(impliedGrant).append(" ");
                                        }
                                }
                        }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
index eaf343d..37b39a6 100644
--- 
a/plugin-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
@@ -393,6 +393,8 @@ public class RangerDefaultPolicyEvaluator extends 
RangerAbstractPolicyEvaluator
                                continue;
                        }
 
+                       // Only one round of 'expansion' is done; multi-level 
impliedGrants (like shown below) are not handled for now
+                       // multi-level impliedGrants: given admin=>write; 
write=>read: must imply admin=>read,write
                        for(Map.Entry<String, Collection<String>> e : 
impliedAccessGrants.entrySet()) {
                                String             accessType    = e.getKey();
                                Collection<String> impliedGrants = e.getValue();
@@ -402,13 +404,13 @@ public class RangerDefaultPolicyEvaluator extends 
RangerAbstractPolicyEvaluator
                                if(access == null) {
                                        continue;
                                }
-                               
+
                                for(String impliedGrant : impliedGrants) {
                                        RangerPolicyItemAccess impliedAccess = 
getAccess(policyItem, impliedGrant);
-                                       
+
                                        if(impliedAccess == null) {
                                                impliedAccess = new 
RangerPolicyItemAccess(impliedGrant, access.getIsAllowed(), 
access.getIsAudited());
-                                               
+
                                                
policyItem.getAccesses().add(impliedAccess);
                                        } else {
                                                if(! 
impliedAccess.getIsAllowed()) {
@@ -429,7 +431,7 @@ public class RangerDefaultPolicyEvaluator extends 
RangerAbstractPolicyEvaluator
 
                if(serviceDef != null && 
!CollectionUtils.isEmpty(serviceDef.getAccessTypes())) {
                        for(RangerAccessTypeDef accessTypeDef : 
serviceDef.getAccessTypes()) {
-                               
if(!CollectionUtils.isEmpty(accessTypeDef.getImpliedAccessGrants())) {
+                               
if(!CollectionUtils.isEmpty(accessTypeDef.getImpliedGrants())) {
                                        if(ret == null) {
                                                ret = new HashMap<String, 
Collection<String>>();
                                        }
@@ -442,7 +444,7 @@ public class RangerDefaultPolicyEvaluator extends 
RangerAbstractPolicyEvaluator
                                                
ret.put(accessTypeDef.getName(), impliedAccessGrants);
                                        }
 
-                                       for(String impliedAccessGrant : 
accessTypeDef.getImpliedAccessGrants()) {
+                                       for(String impliedAccessGrant : 
accessTypeDef.getImpliedGrants()) {
                                                
impliedAccessGrants.add(impliedAccessGrant);
                                        }
                                }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceDefStoreFactory.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceDefStoreFactory.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceDefStoreFactory.java
new file mode 100644
index 0000000..3192efc
--- /dev/null
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceDefStoreFactory.java
@@ -0,0 +1,70 @@
+/*
+ * 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.ranger.plugin.store;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ranger.plugin.store.file.ServiceDefFileStore;
+
+
+public class ServiceDefStoreFactory {
+       private static final Log LOG = 
LogFactory.getLog(ServiceDefStoreFactory.class);
+
+       private static ServiceDefStoreFactory sInstance = null;
+
+       private ServiceDefStore serviceDefStore = null;
+
+
+       public static ServiceDefStoreFactory instance() {
+               if(sInstance == null) {
+                       sInstance = new ServiceDefStoreFactory();
+               }
+
+               return sInstance;
+       }
+
+       public ServiceDefStore getServiceDefStore() {
+               return serviceDefStore;
+       }
+
+       private ServiceDefStoreFactory() {
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("==> 
ServiceDefStoreFactory.ServiceDefStoreFactory()");
+               }
+
+               init();
+
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("<== 
ServiceDefStoreFactory.ServiceDefStoreFactory()");
+               }
+       }
+
+       private void init() {
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("==> ServiceDefStoreFactory.init()");
+               }
+
+               serviceDefStore = new ServiceDefFileStore(); // TODO: 
configurable store implementation
+
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("<== ServiceDefStoreFactory.init()");
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
new file mode 100644
index 0000000..7be2311
--- /dev/null
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/store/ServiceStoreFactory.java
@@ -0,0 +1,70 @@
+/*
+ * 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.ranger.plugin.store;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ranger.plugin.store.file.ServiceFileStore;
+
+
+public class ServiceStoreFactory {
+       private static final Log LOG = 
LogFactory.getLog(ServiceStoreFactory.class);
+
+       private static ServiceStoreFactory sInstance = null;
+
+       private ServiceStore serviceStore = null;
+
+
+       public static ServiceStoreFactory instance() {
+               if(sInstance == null) {
+                       sInstance = new ServiceStoreFactory();
+               }
+
+               return sInstance;
+       }
+
+       public ServiceStore getServiceStore() {
+               return serviceStore;
+       }
+
+       private ServiceStoreFactory() {
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("==> 
ServiceStoreFactory.ServiceStoreFactory()");
+               }
+
+               init();
+
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("<== 
ServiceStoreFactory.ServiceStoreFactory()");
+               }
+       }
+
+       private void init() {
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("==> ServiceStoreFactory.init()");
+               }
+
+               serviceStore = new ServiceFileStore(); // TODO: configurable 
store implementation
+
+               if(LOG.isDebugEnabled()) {
+                       LOG.debug("<== ServiceStoreFactory.init()");
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/resources/service-defs/ranger-servicedef-hbase.json 
b/plugin-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
index 6569b4e..20911c7 100644
--- a/plugin-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
+++ b/plugin-common/src/main/resources/service-defs/ranger-servicedef-hbase.json
@@ -42,7 +42,7 @@
     {"name":"read","label":"Read"},
        {"name":"write","label":"Write"},
        {"name":"create","label":"Create"},
-       
{"name":"admin","label":"Admin","impliedAccessGrants":["read","write","create"]}
+       
{"name":"admin","label":"Admin","impliedGrants":["read","write","create"]}
   ],
   "policyConditions":
   [

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/test/java/org/apache/ranger/plugin/manager/TestServiceManager.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/test/java/org/apache/ranger/plugin/manager/TestServiceManager.java
 
b/plugin-common/src/test/java/org/apache/ranger/plugin/manager/TestServiceManager.java
deleted file mode 100644
index 7b4a039..0000000
--- 
a/plugin-common/src/test/java/org/apache/ranger/plugin/manager/TestServiceManager.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * 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.ranger.plugin.manager;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import org.apache.ranger.plugin.manager.ServiceDefManager;
-import org.apache.ranger.plugin.manager.ServiceManager;
-import org.apache.ranger.plugin.model.RangerPolicy;
-import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess;
-import org.apache.ranger.plugin.model.RangerService;
-import org.apache.ranger.plugin.model.RangerServiceDef;
-import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem;
-import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class TestServiceManager {
-       static ServiceDefManager sdMgr  = null;
-       static ServiceManager    svcMgr = null;
-
-       static String sdName      = "HdfsTest";
-       static String serviceName = "HdfsTest-dev";
-       static String policyName  = "testPolicy-1";
-
-       @BeforeClass
-       public static void setupTest() {
-               sdMgr  = new ServiceDefManager();
-               svcMgr = new ServiceManager();
-       }
-
-       @Test
-       public void testServiceManager() throws Exception {
-               List<RangerServiceDef> sds = sdMgr.getAll();
-
-               int initSdCount = sds == null ? 0 : sds.size();
-
-               RangerServiceDef sd = new RangerServiceDef(sdName, 
"org.apache.ranger.services.TestService", "TestService", "test servicedef 
description", null, null, null, null, null);
-
-               RangerServiceDef createdSd = sdMgr.create(sd);
-               assertNotNull("createServiceDef() failed", createdSd != null);
-
-               sds = sdMgr.getAll();
-               assertEquals("createServiceDef() failed", initSdCount + 1, sds 
== null ? 0 : sds.size());
-
-               String updatedDescription = sd.getDescription() + ": updated";
-               createdSd.setDescription(updatedDescription);
-               RangerServiceDef updatedSd = sdMgr.update(createdSd);
-               assertNotNull("updateServiceDef(updatedDescription) failed", 
updatedSd);
-               assertEquals("updateServiceDef(updatedDescription) failed", 
updatedDescription, updatedSd.getDescription());
-
-               sds = sdMgr.getAll();
-               assertEquals("updateServiceDef(updatedDescription) failed", 
initSdCount + 1, sds == null ? 0 : sds.size());
-
-               String updatedName = sd.getName() + "-Renamed";
-               /*
-               updatedSd.setName(updatedName);
-               updatedSd = sdMgr.update(updatedSd);
-               assertNotNull("updateServiceDef(updatedName) failed", 
updatedSd);
-               assertEquals("updateServiceDef(updatedName) failed", 
updatedName, updatedSd.getName());
-
-               sds = getAllServiceDef();
-               assertEquals("updateServiceDef(updatedName) failed", 
initSdCount + 1, sds == null ? 0 : sds.size());
-               */
-
-               List<RangerService> services = svcMgr.getAll();
-
-               int initServiceCount = services == null ? 0 : services.size();
-
-               RangerService svc = new RangerService(sdName, serviceName, 
"test service description", Boolean.TRUE, null);
-
-               RangerService createdSvc = svcMgr.create(svc);
-               assertNotNull("createService() failed", createdSvc);
-
-               services = svcMgr.getAll();
-               assertEquals("createServiceDef() failed", initServiceCount + 1, 
services == null ? 0 : services.size());
-
-               updatedDescription = createdSvc.getDescription() + ": updated";
-               createdSvc.setDescription(updatedDescription);
-               RangerService updatedSvc = svcMgr.update(createdSvc);
-               assertNotNull("updateService(updatedDescription) failed", 
updatedSvc);
-               assertEquals("updateService(updatedDescription) failed", 
updatedDescription, updatedSvc.getDescription());
-
-               services = svcMgr.getAll();
-               assertEquals("updateService(updatedDescription) failed", 
initServiceCount + 1, services == null ? 0 : services.size());
-
-               updatedName = serviceName + "-Renamed";
-               updatedSvc.setName(updatedName);
-               updatedSvc = svcMgr.update(updatedSvc);
-               assertNotNull("updateService(updatedName) failed", updatedSvc);
-               assertEquals("updateService(updatedName) failed", updatedName, 
updatedSvc.getName());
-
-               services = svcMgr.getAll();
-               assertEquals("updateService(updatedName) failed", 
initServiceCount + 1, services == null ? 0 : services.size());
-
-               List<RangerPolicy> policies = svcMgr.getAllPolicies();
-
-               int initPolicyCount = policies == null ? 0 : policies.size();
-
-               RangerPolicy policy = new RangerPolicy(updatedSvc.getName(), 
policyName, "test policy description", Boolean.TRUE, null, null);
-               policy.getResources().put("path", new 
RangerPolicyResource("/demo/test/finance", Boolean.FALSE, Boolean.TRUE));
-
-               RangerPolicyItem item1 = new RangerPolicyItem();
-               item1.getAccesses().add(new RangerPolicyItemAccess("read"));
-               item1.getAccesses().add(new RangerPolicyItemAccess("write"));
-               item1.getAccesses().add(new RangerPolicyItemAccess("execute"));
-               item1.getUsers().add("admin");
-               item1.getGroups().add("finance");
-
-               RangerPolicyItem item2 = new RangerPolicyItem();
-               item2.getAccesses().add(new RangerPolicyItemAccess("read"));
-               item2.getGroups().add("public");
-
-               policy.getPolicyItems().add(item1);
-               policy.getPolicyItems().add(item2);
-
-               RangerPolicy createdPolicy = svcMgr.createPolicy(policy);
-               assertNotNull(createdPolicy);
-               assertNotNull(createdPolicy.getPolicyItems());
-               assertEquals(createdPolicy.getPolicyItems().size(), 2);
-
-               RangerPolicyItem createItem1 = 
createdPolicy.getPolicyItems().get(0);
-               RangerPolicyItem createItem2 = 
createdPolicy.getPolicyItems().get(1);
-
-               assertNotNull(createItem1.getAccesses());
-               assertEquals(createItem1.getAccesses().size(), 3);
-               assertNotNull(createItem1.getUsers());
-               assertEquals(createItem1.getUsers().size(), 1);
-               assertNotNull(createItem1.getGroups());
-               assertEquals(createItem1.getGroups().size(), 1);
-
-               assertNotNull(createItem2.getAccesses());
-               assertEquals(createItem2.getAccesses().size(), 1);
-               assertNotNull(createItem2.getUsers());
-               assertEquals(createItem2.getUsers().size(), 0);
-               assertNotNull(createItem2.getGroups());
-               assertEquals(createItem2.getGroups().size(), 1);
-
-               policies = svcMgr.getAllPolicies();
-               assertEquals("createPolicy() failed", initPolicyCount + 1, 
policies == null ? 0 : policies.size());
-
-               updatedDescription = policy.getDescription() + ":updated";
-               createdPolicy.setDescription(updatedDescription);
-               RangerPolicy updatedPolicy = svcMgr.updatePolicy(createdPolicy);
-               assertNotNull("updatePolicy(updatedDescription) failed", 
updatedPolicy != null);
-
-               policies = svcMgr.getAllPolicies();
-               assertEquals("updatePolicy(updatedDescription) failed", 
initPolicyCount + 1, policies == null ? 0 : policies.size());
-
-               updatedName = policyName + "-Renamed";
-               updatedPolicy.setName(updatedName);
-               updatedPolicy = svcMgr.updatePolicy(updatedPolicy);
-               assertNotNull("updatePolicy(updatedName) failed", 
updatedPolicy);
-
-               policies = svcMgr.getAllPolicies();
-               assertEquals("updatePolicy(updatedName) failed", 
initPolicyCount + 1, policies == null ? 0 : policies.size());
-
-               // rename the service; all the policies for this service should 
reflect the new service name
-               updatedName = serviceName + "-Renamed2";
-               updatedSvc.setName(updatedName);
-               updatedSvc = svcMgr.update(updatedSvc);
-               assertNotNull("updateService(updatedName2) failed", updatedSvc);
-               assertEquals("updateService(updatedName2) failed", updatedName, 
updatedSvc.getName());
-
-               services = svcMgr.getAll();
-               assertEquals("updateService(updatedName2) failed", 
initServiceCount + 1, services == null ? 0 : services.size());
-
-               updatedPolicy = svcMgr.getPolicy(createdPolicy.getId());
-               assertNotNull("updateService(updatedName2) failed", 
updatedPolicy);
-               assertEquals("updateService(updatedName2) failed", 
updatedPolicy.getService(), updatedSvc.getName());
-
-               svcMgr.deletePolicy(policy.getId());
-               policies = svcMgr.getAllPolicies();
-               assertEquals("deletePolicy() failed", initPolicyCount, policies 
== null ? 0 : policies.size());
-
-               svcMgr.delete(svc.getId());
-               services = svcMgr.getAll();
-               assertEquals("deleteService() failed", initServiceCount, 
services == null ? 0 : services.size());
-
-               sdMgr.delete(sd.getId());
-               sds = sdMgr.getAll();
-               assertEquals("deleteServiceDef() failed", initSdCount, sds == 
null ? 0 : sds.size());
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/test/java/org/apache/ranger/plugin/store/TestServiceStore.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/test/java/org/apache/ranger/plugin/store/TestServiceStore.java
 
b/plugin-common/src/test/java/org/apache/ranger/plugin/store/TestServiceStore.java
new file mode 100644
index 0000000..dcd2125
--- /dev/null
+++ 
b/plugin-common/src/test/java/org/apache/ranger/plugin/store/TestServiceStore.java
@@ -0,0 +1,205 @@
+/*
+ * 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.ranger.plugin.store;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.apache.ranger.plugin.model.RangerPolicy;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess;
+import org.apache.ranger.plugin.model.RangerService;
+import org.apache.ranger.plugin.model.RangerServiceDef;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
+import org.apache.ranger.plugin.store.ServiceDefStore;
+import org.apache.ranger.plugin.store.ServiceDefStoreFactory;
+import org.apache.ranger.plugin.store.ServiceStore;
+import org.apache.ranger.plugin.store.ServiceStoreFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestServiceStore {
+       static ServiceDefStore svcDefStore = null;
+       static ServiceStore    svcStore    = null;
+
+       static String sdName      = "HdfsTest";
+       static String serviceName = "HdfsTest-dev";
+       static String policyName  = "testPolicy-1";
+
+       @BeforeClass
+       public static void setupTest() {
+               svcDefStore = 
ServiceDefStoreFactory.instance().getServiceDefStore();
+               svcStore    = ServiceStoreFactory.instance().getServiceStore();
+       }
+
+       @Test
+       public void testServiceManager() throws Exception {
+               List<RangerServiceDef> sds = svcDefStore.getAll();
+
+               int initSdCount = sds == null ? 0 : sds.size();
+
+               RangerServiceDef sd = new RangerServiceDef(sdName, 
"org.apache.ranger.services.TestService", "TestService", "test servicedef 
description", null, null, null, null, null);
+
+               RangerServiceDef createdSd = svcDefStore.create(sd);
+               assertNotNull("createServiceDef() failed", createdSd != null);
+
+               sds = svcDefStore.getAll();
+               assertEquals("createServiceDef() failed", initSdCount + 1, sds 
== null ? 0 : sds.size());
+
+               String updatedDescription = sd.getDescription() + ": updated";
+               createdSd.setDescription(updatedDescription);
+               RangerServiceDef updatedSd = svcDefStore.update(createdSd);
+               assertNotNull("updateServiceDef(updatedDescription) failed", 
updatedSd);
+               assertEquals("updateServiceDef(updatedDescription) failed", 
updatedDescription, updatedSd.getDescription());
+
+               sds = svcDefStore.getAll();
+               assertEquals("updateServiceDef(updatedDescription) failed", 
initSdCount + 1, sds == null ? 0 : sds.size());
+
+               String updatedName = sd.getName() + "-Renamed";
+               /*
+               updatedSd.setName(updatedName);
+               updatedSd = sdMgr.update(updatedSd);
+               assertNotNull("updateServiceDef(updatedName) failed", 
updatedSd);
+               assertEquals("updateServiceDef(updatedName) failed", 
updatedName, updatedSd.getName());
+
+               sds = getAllServiceDef();
+               assertEquals("updateServiceDef(updatedName) failed", 
initSdCount + 1, sds == null ? 0 : sds.size());
+               */
+
+               List<RangerService> services = svcStore.getAll();
+
+               int initServiceCount = services == null ? 0 : services.size();
+
+               RangerService svc = new RangerService(sdName, serviceName, 
"test service description", Boolean.TRUE, null);
+
+               RangerService createdSvc = svcStore.create(svc);
+               assertNotNull("createService() failed", createdSvc);
+
+               services = svcStore.getAll();
+               assertEquals("createServiceDef() failed", initServiceCount + 1, 
services == null ? 0 : services.size());
+
+               updatedDescription = createdSvc.getDescription() + ": updated";
+               createdSvc.setDescription(updatedDescription);
+               RangerService updatedSvc = svcStore.update(createdSvc);
+               assertNotNull("updateService(updatedDescription) failed", 
updatedSvc);
+               assertEquals("updateService(updatedDescription) failed", 
updatedDescription, updatedSvc.getDescription());
+
+               services = svcStore.getAll();
+               assertEquals("updateService(updatedDescription) failed", 
initServiceCount + 1, services == null ? 0 : services.size());
+
+               updatedName = serviceName + "-Renamed";
+               updatedSvc.setName(updatedName);
+               updatedSvc = svcStore.update(updatedSvc);
+               assertNotNull("updateService(updatedName) failed", updatedSvc);
+               assertEquals("updateService(updatedName) failed", updatedName, 
updatedSvc.getName());
+
+               services = svcStore.getAll();
+               assertEquals("updateService(updatedName) failed", 
initServiceCount + 1, services == null ? 0 : services.size());
+
+               List<RangerPolicy> policies = svcStore.getAllPolicies();
+
+               int initPolicyCount = policies == null ? 0 : policies.size();
+
+               RangerPolicy policy = new RangerPolicy(updatedSvc.getName(), 
policyName, "test policy description", Boolean.TRUE, null, null);
+               policy.getResources().put("path", new 
RangerPolicyResource("/demo/test/finance", Boolean.FALSE, Boolean.TRUE));
+
+               RangerPolicyItem item1 = new RangerPolicyItem();
+               item1.getAccesses().add(new RangerPolicyItemAccess("read"));
+               item1.getAccesses().add(new RangerPolicyItemAccess("write"));
+               item1.getAccesses().add(new RangerPolicyItemAccess("execute"));
+               item1.getUsers().add("admin");
+               item1.getGroups().add("finance");
+
+               RangerPolicyItem item2 = new RangerPolicyItem();
+               item2.getAccesses().add(new RangerPolicyItemAccess("read"));
+               item2.getGroups().add("public");
+
+               policy.getPolicyItems().add(item1);
+               policy.getPolicyItems().add(item2);
+
+               RangerPolicy createdPolicy = svcStore.createPolicy(policy);
+               assertNotNull(createdPolicy);
+               assertNotNull(createdPolicy.getPolicyItems());
+               assertEquals(createdPolicy.getPolicyItems().size(), 2);
+
+               RangerPolicyItem createItem1 = 
createdPolicy.getPolicyItems().get(0);
+               RangerPolicyItem createItem2 = 
createdPolicy.getPolicyItems().get(1);
+
+               assertNotNull(createItem1.getAccesses());
+               assertEquals(createItem1.getAccesses().size(), 3);
+               assertNotNull(createItem1.getUsers());
+               assertEquals(createItem1.getUsers().size(), 1);
+               assertNotNull(createItem1.getGroups());
+               assertEquals(createItem1.getGroups().size(), 1);
+
+               assertNotNull(createItem2.getAccesses());
+               assertEquals(createItem2.getAccesses().size(), 1);
+               assertNotNull(createItem2.getUsers());
+               assertEquals(createItem2.getUsers().size(), 0);
+               assertNotNull(createItem2.getGroups());
+               assertEquals(createItem2.getGroups().size(), 1);
+
+               policies = svcStore.getAllPolicies();
+               assertEquals("createPolicy() failed", initPolicyCount + 1, 
policies == null ? 0 : policies.size());
+
+               updatedDescription = policy.getDescription() + ":updated";
+               createdPolicy.setDescription(updatedDescription);
+               RangerPolicy updatedPolicy = 
svcStore.updatePolicy(createdPolicy);
+               assertNotNull("updatePolicy(updatedDescription) failed", 
updatedPolicy != null);
+
+               policies = svcStore.getAllPolicies();
+               assertEquals("updatePolicy(updatedDescription) failed", 
initPolicyCount + 1, policies == null ? 0 : policies.size());
+
+               updatedName = policyName + "-Renamed";
+               updatedPolicy.setName(updatedName);
+               updatedPolicy = svcStore.updatePolicy(updatedPolicy);
+               assertNotNull("updatePolicy(updatedName) failed", 
updatedPolicy);
+
+               policies = svcStore.getAllPolicies();
+               assertEquals("updatePolicy(updatedName) failed", 
initPolicyCount + 1, policies == null ? 0 : policies.size());
+
+               // rename the service; all the policies for this service should 
reflect the new service name
+               updatedName = serviceName + "-Renamed2";
+               updatedSvc.setName(updatedName);
+               updatedSvc = svcStore.update(updatedSvc);
+               assertNotNull("updateService(updatedName2) failed", updatedSvc);
+               assertEquals("updateService(updatedName2) failed", updatedName, 
updatedSvc.getName());
+
+               services = svcStore.getAll();
+               assertEquals("updateService(updatedName2) failed", 
initServiceCount + 1, services == null ? 0 : services.size());
+
+               updatedPolicy = svcStore.getPolicy(createdPolicy.getId());
+               assertNotNull("updateService(updatedName2) failed", 
updatedPolicy);
+               assertEquals("updateService(updatedName2) failed", 
updatedPolicy.getService(), updatedSvc.getName());
+
+               svcStore.deletePolicy(policy.getId());
+               policies = svcStore.getAllPolicies();
+               assertEquals("deletePolicy() failed", initPolicyCount, policies 
== null ? 0 : policies.size());
+
+               svcStore.delete(svc.getId());
+               services = svcStore.getAll();
+               assertEquals("deleteService() failed", initServiceCount, 
services == null ? 0 : services.size());
+
+               svcDefStore.delete(sd.getId());
+               sds = svcDefStore.getAll();
+               assertEquals("deleteServiceDef() failed", initSdCount, sds == 
null ? 0 : sds.size());
+       }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/plugin-common/src/test/resources/policyengine/test_policyengine_hbase.json
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/test/resources/policyengine/test_policyengine_hbase.json 
b/plugin-common/src/test/resources/policyengine/test_policyengine_hbase.json
index 48c684d..f563c28 100644
--- a/plugin-common/src/test/resources/policyengine/test_policyengine_hbase.json
+++ b/plugin-common/src/test/resources/policyengine/test_policyengine_hbase.json
@@ -13,7 +13,7 @@
       {"name":"read","label":"Read"},
       {"name":"write","label":"Write"},
       {"name":"create","label":"Create"},
-      
{"name":"admin","label":"Admin","impliedAccessGrants":["read","write","create"]}
+      
{"name":"admin","label":"Admin","impliedGrants":["read","write","create"]}
     ]
   },
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc5e3f71/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
----------------------------------------------------------------------
diff --git 
a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java 
b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
index 9080cd9..b21528c 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
@@ -34,11 +34,13 @@ import javax.ws.rs.core.Context;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.ranger.plugin.manager.ServiceDefManager;
-import org.apache.ranger.plugin.manager.ServiceManager;
 import org.apache.ranger.plugin.model.RangerPolicy;
 import org.apache.ranger.plugin.model.RangerService;
 import org.apache.ranger.plugin.model.RangerServiceDef;
+import org.apache.ranger.plugin.store.ServiceDefStore;
+import org.apache.ranger.plugin.store.ServiceDefStoreFactory;
+import org.apache.ranger.plugin.store.ServiceStore;
+import org.apache.ranger.plugin.store.ServiceStoreFactory;
 import org.apache.ranger.view.VXResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
@@ -56,12 +58,12 @@ public class ServiceREST {
        @Autowired
        RESTErrorUtil restErrorUtil;
 
-       private ServiceDefManager sdMgr  = null;
-       private ServiceManager    svcMgr  = null;
+       private ServiceDefStore serviceDefStore = null;
+       private ServiceStore    svcStore        = null;
 
        public ServiceREST() {
-               sdMgr  = new ServiceDefManager();
-               svcMgr = new ServiceManager();
+               serviceDefStore = 
ServiceDefStoreFactory.instance().getServiceDefStore();
+               svcStore        = 
ServiceStoreFactory.instance().getServiceStore();
        }
 
        @GET
@@ -75,7 +77,7 @@ public class ServiceREST {
                RangerServiceDef ret = null;
 
                try {
-                       ret = sdMgr.get(id);
+                       ret = serviceDefStore.get(id);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -102,7 +104,7 @@ public class ServiceREST {
                RangerServiceDef ret = null;
 
                try {
-                       ret = sdMgr.getByName(name);
+                       ret = serviceDefStore.getByName(name);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -129,7 +131,7 @@ public class ServiceREST {
                List<RangerServiceDef> ret = null;
 
                try {
-                       ret = sdMgr.getAll();
+                       ret = serviceDefStore.getAll();
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -153,7 +155,7 @@ public class ServiceREST {
                RangerServiceDef ret = null;
 
                try {
-                       ret = sdMgr.create(serviceDef);
+                       ret = serviceDefStore.create(serviceDef);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -177,7 +179,7 @@ public class ServiceREST {
                RangerServiceDef ret = null;
 
                try {
-                       ret = sdMgr.update(serviceDef);
+                       ret = serviceDefStore.update(serviceDef);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -199,7 +201,7 @@ public class ServiceREST {
                }
 
                try {
-                       sdMgr.delete(id);
+                       serviceDefStore.delete(id);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -221,7 +223,7 @@ public class ServiceREST {
                RangerService ret = null;
 
                try {
-                       ret = svcMgr.get(id);
+                       ret = svcStore.get(id);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -248,7 +250,7 @@ public class ServiceREST {
                RangerService ret = null;
 
                try {
-                       ret = svcMgr.getByName(name);
+                       ret = svcStore.getByName(name);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -275,7 +277,7 @@ public class ServiceREST {
                List<RangerService> ret = null;
 
                try {
-                       ret = svcMgr.getAll();
+                       ret = svcStore.getAll();
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -323,7 +325,7 @@ public class ServiceREST {
                RangerService ret = null;
 
                try {
-                       ret = svcMgr.create(service);
+                       ret = svcStore.create(service);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -346,7 +348,7 @@ public class ServiceREST {
                RangerService ret = null;
 
                try {
-                       ret = svcMgr.update(service);
+                       ret = svcStore.update(service);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -368,7 +370,7 @@ public class ServiceREST {
                }
 
                try {
-                       svcMgr.delete(id);
+                       svcStore.delete(id);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -389,7 +391,7 @@ public class ServiceREST {
                VXResponse ret = new VXResponse();
 
                try {
-                       svcMgr.validateConfig(service);
+                       // TODO: svcStore.validateConfig(service);
                } catch(Exception excp) {
                        ret.setStatusCode(VXResponse.STATUS_ERROR);
                        // TODO: message
@@ -414,7 +416,7 @@ public class ServiceREST {
                RangerPolicy ret = null;
 
                try {
-                       ret = svcMgr.getPolicy(id);
+                       ret = svcStore.getPolicy(id);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -442,7 +444,8 @@ public class ServiceREST {
 
                try {
                        Long serviceId = 
Long.parseLong(request.getParameter("serviceId"));
-                       ret = svcMgr.getPolicies(serviceId);
+
+                       ret = svcStore.getServicePolicies(serviceId);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -490,7 +493,7 @@ public class ServiceREST {
                List<RangerPolicy> ret = null;
 
                try {
-                       ret = svcMgr.getPolicies(serviceId);
+                       ret = svcStore.getServicePolicies(serviceId);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -517,7 +520,7 @@ public class ServiceREST {
                RangerPolicy ret = null;
 
                try {
-                       ret = svcMgr.createPolicy(policy);
+                       ret = svcStore.createPolicy(policy);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -540,7 +543,7 @@ public class ServiceREST {
                RangerPolicy ret = null;
 
                try {
-                       ret = svcMgr.updatePolicy(policy);
+                       ret = svcStore.updatePolicy(policy);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }
@@ -562,7 +565,7 @@ public class ServiceREST {
                }
 
                try {
-                       svcMgr.deletePolicy(id);
+                       svcStore.deletePolicy(id);
                } catch(Exception excp) {
                        throw 
restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, 
excp.getMessage(), true);
                }

Reply via email to