This is handled for you by hadoop simply by setting this:

+    // set this so that UGI set to correct user in unsecure mode
+    Apps.addToEnvironment(env, "HADOOP_USER_NAME", args.amUser)