zhangbutao commented on code in PR #3545:
URL: https://github.com/apache/hive/pull/3545#discussion_r974878654


##########
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/filtercontext/DataConnectorFilterContext.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.hadoop.hive.ql.security.authorization.plugin.metastore.filtercontext;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.metastore.HiveMetaStoreAuthorizableEvent;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.metastore.HiveMetaStoreAuthzInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataConnectorFilterContext extends HiveMetaStoreAuthorizableEvent 
{
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(DataConnectorFilterContext.class);
+
+    List<String> connectors = null;
+
+    public DataConnectorFilterContext(List<String> connectors) {
+        super(null);
+        this.connectors = connectors;
+        getAuthzContext();
+    }
+
+    @Override
+    public HiveMetaStoreAuthzInfo getAuthzContext() {
+        HiveMetaStoreAuthzInfo ret =
+                new HiveMetaStoreAuthzInfo(preEventContext, 
HiveOperationType.QUERY, getInputHObjs(), getOutputHObjs(), null);
+        return ret;
+    }
+
+    private List<HivePrivilegeObject> getInputHObjs() {
+        LOG.debug("==> DataConnectorFilterContext.getOutputHObjs()");
+
+        List<HivePrivilegeObject> ret = new ArrayList<>();
+        for (String connector : connectors) {
+            HivePrivilegeObject.HivePrivilegeObjectType type = 
HivePrivilegeObject.HivePrivilegeObjectType.DATACONNECTOR;
+            HivePrivilegeObject.HivePrivObjectActionType objectActionType =
+                    HivePrivilegeObject.HivePrivObjectActionType.OTHER;
+            HivePrivilegeObject hivePrivilegeObject =
+                    new HivePrivilegeObject(type, null, connector, null, null, 
objectActionType, null, null);

Review Comment:
   Good suggestion. But we lack of HMS api  for getting all dataconnector 
objects and we can only all dataconnectors names by 
`HMSHandler::get_dataconnectors()`, so we can not set owner's name and 
owner-type in here.
   
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L2033-L2034
   
   If we want do this, i think we can define a new HtMS api or define a new api 
in RawStore  to get all dataconnector objects, like get all tables objects:
   
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java#L609-L610
   
   I think we can do this in following task. wdyt? @saihemanth-cloudera Thank 
you.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to