public static TTransport createSubjectAssumedTransport(String principal, String host,
    TTransport underlyingTransport, Map<String, String> saslProps) throws IOException {
    String resolvedPrincipal = SecurityUtil.getServerPrincipal(principal, host);
    String[] names = resolvedPrincipal.split("[/@]");
    try {
      TTransport saslTransport =
        new TSaslClientTransport("GSSAPI", null, names[0], names[1], saslProps, null,
          underlyingTransport);
      return new TSubjectAssumingTransport(saslTransport);
    } catch (SaslException | TTransportException se) {
      throw new IOException("Could not instantiate transport", se);
    }
  }
Helper to wrap the {@code underlyingTransport} into an assumed kerberos principal.
The function is used for kerberos based authentication, where {@code kerberosAuthType}
is set to {@code fromSubject}. If also performs a substitution of {@code _HOST} to the
local host name, if required.

@param principal The kerberos principal to assume
@param host Host, used to replace the {@code _HOST} with
@param underlyingTransport The I/O transport to wrap
@param saslProps SASL property map
@return The wrapped transport
@throws IOException
service/src/java/org/apache/hive/service/auth/KerberosSaslHelper.java