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


RANGER-203: added RangerBasePlugin and RangerBaseService classes

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

Branch: refs/heads/stack
Commit: f49cac435d7cac126666ef9c60180274b365fd32
Parents: cc5e3f7
Author: Madhan Neethiraj <[email protected]>
Authored: Sat Jan 10 00:07:03 2015 -0800
Committer: Madhan Neethiraj <[email protected]>
Committed: Sat Jan 10 00:07:03 2015 -0800

----------------------------------------------------------------------
 .../ranger/plugin/service/RangerBasePlugin.java | 57 ++++++++++++++++
 .../plugin/service/RangerBaseService.java       | 55 +++++++++++++++
 .../plugin/service/ResourceLookupContext.java   | 72 ++++++++++++++++++++
 3 files changed, 184 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f49cac43/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
new file mode 100644
index 0000000..29c1082
--- /dev/null
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
@@ -0,0 +1,57 @@
+/*
+ * 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.service;
+
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+
+public abstract class RangerBasePlugin {
+       private boolean initDone = false;
+
+       public boolean init() {
+               if(!initDone) {
+                       synchronized(this) {
+                               if(! initDone) {
+                                       /* TODO:
+                                       loadConfig(); // to get serviceName, 
policy download URL, local cache file details, etc
+
+                                       initAuditFramework();
+
+                                       loadLocallyCachedPolicies();
+
+                                       
getPolicyEngine().setPolicies(serviceDef, policies);
+
+                                       setupPolicyRefresher(); // to poll for 
policy updates
+                                        */
+                                       
+                                       initDone = true;
+                               }
+                       }
+               }
+
+               return initDone;
+       }
+       
+       public void cleanup() {
+               // TODO:
+       }
+
+       public abstract RangerPolicyEngine getPolicyEngine();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f49cac43/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBaseService.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBaseService.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBaseService.java
new file mode 100644
index 0000000..b234b46
--- /dev/null
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/service/RangerBaseService.java
@@ -0,0 +1,55 @@
+/*
+ * 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.service;
+
+import java.util.List;
+
+import org.apache.ranger.plugin.model.RangerService;
+import org.apache.ranger.plugin.model.RangerServiceDef;
+
+
+public abstract class RangerBaseService {
+       private RangerServiceDef serviceDef;
+       private RangerService    service;
+
+
+       public void init(RangerServiceDef serviceDef, RangerService service) {
+               this.serviceDef = serviceDef;
+               this.service    = service;
+       }
+
+       /**
+        * @return the serviceDef
+        */
+       public RangerServiceDef getServiceDef() {
+               return serviceDef;
+       }
+
+       /**
+        * @return the service
+        */
+       public RangerService getService() {
+               return service;
+       }
+
+       public abstract void validateConfig();
+       
+       public abstract List<String> lookupResource(ResourceLookupContext 
context);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f49cac43/plugin-common/src/main/java/org/apache/ranger/plugin/service/ResourceLookupContext.java
----------------------------------------------------------------------
diff --git 
a/plugin-common/src/main/java/org/apache/ranger/plugin/service/ResourceLookupContext.java
 
b/plugin-common/src/main/java/org/apache/ranger/plugin/service/ResourceLookupContext.java
new file mode 100644
index 0000000..b5c3dda
--- /dev/null
+++ 
b/plugin-common/src/main/java/org/apache/ranger/plugin/service/ResourceLookupContext.java
@@ -0,0 +1,72 @@
+/*
+ * 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.service;
+
+import java.util.List;
+import java.util.Map;
+
+
+public class ResourceLookupContext {
+       private String                    userInput;
+       private String                    resourceName;
+       private Map<String, List<String>> resources;
+
+
+       public ResourceLookupContext() {
+               
+       }
+
+       /**
+        * @return the userInput
+        */
+       public String getUserInput() {
+               return userInput;
+       }
+       /**
+        * @param userInput the userInput to set
+        */
+       public void setUserInput(String userInput) {
+               this.userInput = userInput;
+       }
+       /**
+        * @return the resourceName
+        */
+       public String getResourceName() {
+               return resourceName;
+       }
+       /**
+        * @param resourceName the resourceName to set
+        */
+       public void setResourceName(String resourceName) {
+               this.resourceName = resourceName;
+       }
+       /**
+        * @return the resources
+        */
+       public Map<String, List<String>> getResources() {
+               return resources;
+       }
+       /**
+        * @param resources the resources to set
+        */
+       public void setResources(Map<String, List<String>> resources) {
+               this.resources = resources;
+       }
+}

Reply via email to