private static void authorizeCommandThrowEx(SessionState ss, HiveOperationType type,
    List<String> command, String serviceObject) throws HiveAuthzPluginException, HiveAccessControlException {
    HivePrivilegeObject commandObj = HivePrivilegeObject.createHivePrivilegeObject(command);
    HivePrivilegeObject serviceObj = new HivePrivilegeObject(HivePrivilegeObject.HivePrivilegeObjectType.SERVICE_NAME,
      null, serviceObject, null, null, null);
    HiveAuthzContext.Builder ctxBuilder = new HiveAuthzContext.Builder();
    ctxBuilder.setCommandString(Joiner.on(' ').join(command));
    ctxBuilder.setUserIpAddress(ss.getUserIpAddress());
    ctxBuilder.setForwardedAddresses(ss.getForwardedAddresses());
    ss.getAuthorizerV2().checkPrivileges(type, Collections.singletonList(commandObj),
      Collections.singletonList(serviceObj), ctxBuilder.build());
  }
Authorize command of given type, arguments and for service hosts (for Service Type authorization)

@param ss - session state
@param type - operation type
@param command - command args
@param serviceObject - service object
@return null if there was no authorization error. Otherwise returns  CommandProcessorResponse
capturing the authorization error
ql/src/java/org/apache/hadoop/hive/ql/processors/CommandUtil.java