public static String getKerberosServiceTicket(String principal, String host, String serverHttpUrl,
      Subject loggedInSubject) throws Exception {
    String serverPrincipal = HadoopThriftAuthBridge.getBridge().getServerPrincipal(principal, host);
    if (loggedInSubject != null) {
      return Subject.doAs(loggedInSubject, new HttpKerberosClientAction(serverPrincipal, serverHttpUrl));
    } else {
      // JAAS login from ticket cache to setup the client UserGroupInformation
      UserGroupInformation clientUGI = HadoopThriftAuthBridge.getBridge().getCurrentUGIWithConf("kerberos");
      return clientUGI.doAs(new HttpKerberosClientAction(serverPrincipal, serverHttpUrl));
    }
  }
@return Stringified Base64 encoded kerberosAuthHeader on success
@throws Exception
service/src/java/org/apache/hive/service/auth/HttpAuthUtils.java