presto-hive/src/main/java/io/prestosql/plugin/hive/authentication/KerberosHiveMetastoreAuthentication.java/KerberosHiveMetastoreAuthentication/authenticate
class KerberosHiveMetastoreAuthentication:    @Override
    public TTransport authenticate(TTransport rawTransport, String hiveMetastoreHost, Optional<String> delegationToken)
    {
        try {
            String serverPrincipal = getServerPrincipal(hiveMetastoreServicePrincipal, hiveMetastoreHost);
            String[] names = SaslRpcServer.splitKerberosName(serverPrincipal);
            checkState(names.length == 3,
                    "Kerberos principal name does NOT have the expected hostname part: %s", serverPrincipal);

            Map<String, String> saslProps = ImmutableMap.of(
                    Sasl.QOP, "auth-conf,auth",
                    Sasl.SERVER_AUTH, "true");

            TTransport saslTransport;
            if (delegationToken.isPresent()) {
                saslTransport = new TSaslClientTransport(
                        TOKEN.getMechanismName(),
                        null,
                        null,
                        "default",
                        saslProps,
                        new SaslClientCallbackHandler(decodeDelegationToken(delegationToken.get())),
                        rawTransport);
            }
            else {
                saslTransport = new TSaslClientTransport(
                        KERBEROS.getMechanismName(),
                        null,
                        names[0],
                        names[1],
                        saslProps,
                        null,
                        rawTransport);
            }

            return new TUGIAssumingTransport(saslTransport, authentication.getUserGroupInformation());
        }
        catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }