saihemanth-cloudera commented on code in PR #3312:
URL: https://github.com/apache/hive/pull/3312#discussion_r942718845


##########
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/events/AlterDataConnectorEvent.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.events;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hive.metastore.api.DataConnector;
+import org.apache.hadoop.hive.metastore.events.PreAlterDataConnectorEvent;
+import org.apache.hadoop.hive.metastore.events.PreEventContext;
+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;
+
+/*
+ Authorizable Event for HiveMetaStore operation AlterDataConnector
+ */
+
+public class AlterDataConnectorEvent extends HiveMetaStoreAuthorizableEvent {
+  private static final Logger LOG = 
LoggerFactory.getLogger(AlterDataConnectorEvent.class);
+
+  private String COMMAND_STR = "alter connector";
+
+  public AlterDataConnectorEvent(PreEventContext preEventContext) {
+    super(preEventContext);
+  }
+
+  @Override
+  public HiveMetaStoreAuthzInfo getAuthzContext() {
+    HiveMetaStoreAuthzInfo ret =
+        new HiveMetaStoreAuthzInfo(preEventContext, 
HiveOperationType.ALTERDATACONNECTOR, getInputHObjs(),
+            getOutputHObjs(), COMMAND_STR);
+
+    return ret;
+  }
+
+  private List<HivePrivilegeObject> getInputHObjs() {
+    return Collections.emptyList();

Review Comment:
   Instead of sending an empty list, we need to send the old dataconnector 
object, so that the authorization service can check if the current user has 
required access/privilege on this connector. Anyway we have oldDC object in the 
 PreAlterDataConnectorEvent, so let's just pass it in here. 



##########
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/HiveMetaStoreAuthorizableEvent.java:
##########
@@ -71,4 +72,10 @@ protected HivePrivilegeObject 
getHivePrivilegeObjectLocalUri(String uri) {
     return new 
HivePrivilegeObject(HivePrivilegeObject.HivePrivilegeObjectType.LOCAL_URI, 
null, uri);
   }
 
+  protected HivePrivilegeObject getHivePrivilegeObject(DataConnector 
connector) {
+    return new 
HivePrivilegeObject(HivePrivilegeObject.HivePrivilegeObjectType.DATACONNECTOR, 
null,
+        connector.getName(), null, null, 
HivePrivilegeObject.HivePrivObjectActionType.OTHER, null, null,

Review Comment:
   We might need connector type and connector url in authorization service 
right? Can we include them here instead of passing null?



-- 
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