HIVE-6837 and related issues:
Notice that if withImpersonation is set to true, we're using TSetIpAddressProcessor.getUserIpAddress() to get the IP address which is wrong for a kerberized setup (should use HiveAuthFactory#getIpAddress).
2. Also, in case of a kerberized setup, we're wrapping the transport in a doAs (with UGI of the HiveServer2 process) which doesn't make sense to me: https://github.com/apache/hive/blob/trunk/shims/common-secure/src/main/java/org/apache/hadoop/hive/thrift/HadoopThriftAuthBridge20S.java#L335.
3. The name TSetIpAddressProcessor should be replaced with something more meaningful like TPlainSASLProcessor.
4. Consolidate thread locals used for username, ipaddress
5. Do not directly use TSetIpAddressProcessor; get it via factory like here: