title: Hive impersonation not working with custom authenticator provider
body: <p>I've developed a custom authenticator provider and everything seems OK with regards to authentication: HiveServer2 starts well and authenticated connections are properly validated. Even, simple Hive queries work, such as <code>show tables</code>.</p>
  
  <p><strong>The problem is when I try to execute a query from a remote Hive client. Since I've connected passing my credentials (user + password... well, not really a password, it is a token, but that's not relevant), and Hive configuration is ready for impersonation (see below), I expected HiveServer2 performed the query as my user. Nevertheless, it uses the <code>hive</code> user, which has no permissions on my HDFS user space.</strong></p>
  
  <p>For instance, if I create a table:</p>
  
  <pre><code>&gt; create external table mytable (name string, job string, age string) row format delimited fields terminated by ',' location '/user/frb/testdir'
  Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Got exception: org.apache.hadoop.security.AccessControlException Permission denied: user=hive, access=EXECUTE, inode="/user/frb":frb:frb:drwxr-----
      at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkFsPermission(FSPermissionChecker.java:265)
      at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:251)
      at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkTraverse(FSPermissionChecker.java:205)
      at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:168)
      at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkPermission(FSNamesystem.java:5519)
      at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getFileInfo(FSNamesystem.java:3517)
      at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getFileInfo(NameNodeRpcServer.java:785)
      at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getFileInfo(ClientNamenodeProtocolServerSideTranslatorPB.java:764)
      at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
      at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:585)
      at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:928)
      at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2013)
      at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2009)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:415)
      at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1594)
      at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2007)
  )
  </code></pre>
  
  <p>Regarding relevant configuration parameters, this is my configuration (simplified, not XML like):</p>
  
  <p><code>hive-site.xml</code>:</p>
  
  <pre><code>com.telefonica.iot.idm.endpoint=https://account.lab.fiware.org
  hive.server2.enable.doAs=true
  hive.server2.authentication=CUSTOM
  hive.server2.custom.authentication.class=com.telefonica.iot.cosmos.hive.authprovider.OAuth2AuthenticationProviderImpl
  </code></pre>
  
  <p><code>core-site.xml</code>:</p>
  
  <pre><code>hadoop.proxyuser.hive.groups=*
  hadoop.proxyuser.hive.hosts=*
  </code></pre>
  
  <p>You can have a look on the custom Hive authenticator provider code <a href="https://github.com/telefonicaid/fiware-cosmos/blob/master/cosmos-hive-auth-provider/src/main/java/com/telefonica/iot/cosmos/hive/authprovider/OAuth2AuthenticationProviderImpl.java" rel="noreferrer">here</a>.</p>
  
  <p>I'm using Hive 0.13.0</p>
  
  <p>Can anybody help me, please?</p>