public TTransportFactory getAuthTransFactory() throws LoginException {
    TTransportFactory transportFactory;
    TSaslServerTransport.Factory serverTransportFactory;

    if (isSASLWithKerberizedHadoop()) {
      try {
        serverTransportFactory = saslServer.createSaslServerTransportFactory(
            getSaslProperties());
      } catch (TTransportException e) {
        throw new LoginException(e.getMessage());
      }
      if (authType.isPasswordBasedAuthEnabled()) {
        String authTypeStr = authType.getPasswordBasedAuthStr();
        try {
          serverTransportFactory.addServerDefinition("PLAIN",
              authTypeStr, null, new HashMap<String, String>(),
              new PlainSaslHelper.PlainServerCallbackHandler(authTypeStr));
        } catch (AuthenticationException e) {
          throw new LoginException ("Error setting callback handler" + e);
        }
      }
      transportFactory = saslServer.wrapTransportFactory(serverTransportFactory);
    } else if (authType.isPasswordBasedAuthEnabled()) {
      String authTypeStr = authType.getPasswordBasedAuthStr();
      transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr);
    } else if (authType.isEnabled(HiveAuthConstants.AuthTypes.NOSASL)) {
      transportFactory = new TTransportFactory();
    } else {
      throw new LoginException("Unsupported authentication type " + authType.getAuthTypes());
    }

    String trustedDomain = HiveConf.getVar(conf, ConfVars.HIVE_SERVER2_TRUSTED_DOMAIN).trim();
    if (!trustedDomain.isEmpty()) {
      transportFactory = PlainSaslHelper.getDualPlainTransportFactory(transportFactory, trustedDomain);
    }
    return transportFactory;
  }
This class helps in some aspects of authentication. It creates the proper Thrift classes for the
given configuration as well as helps with authenticating requests.
service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java