code: public static UserGroupInformation setupProxyUser(Properties jobProps,
        String tokenFile, Logger log) {
      UserGroupInformation proxyUser = null;
  
      if (!HadoopSecureWrapperUtils.shouldProxy(jobProps)) {
        log.info("submitting job as original submitter, not proxying");
        return proxyUser;
      }
  
      // set up hadoop related configurations
      final Configuration conf = new Configuration();
      UserGroupInformation.setConfiguration(conf);
      boolean securityEnabled = UserGroupInformation.isSecurityEnabled();
  
      // setting up proxy user if required
      try {
        String userToProxy = null;
        userToProxy = jobProps.getProperty(HadoopSecurityManager.USER_TO_PROXY);
        if (securityEnabled) {
          proxyUser =
              HadoopSecureWrapperUtils.createSecurityEnabledProxyUser(
                  userToProxy, tokenFile, log);
          log.info("security enabled, proxying as user " + userToProxy);
        } else {
          proxyUser = UserGroupInformation.createRemoteUser(userToProxy);
          log.info("security not enabled, proxying as user " + userToProxy);
        }
      } catch (IOException e) {
        log.error("HadoopSecureWrapperUtils.setupProxyUser threw an IOException",
            e);
      }
  
      return proxyUser;
    }
docs: Sets up the UserGroupInformation proxyUser object so that calling code can do doAs returns null
  if the jobProps does not call for a proxyUser
  
  @param jobProps job properties
  @param tokenFile pass tokenFile if known. Pass null if the tokenFile is in the environmental
  variable
  already.
  @return returns null if no need to run as proxyUser, otherwise returns valid proxyUser that can
  doAs