@Override
                public boolean retryRequest(final HttpResponse response, final int executionCount,
                    final HttpContext context) {
                  int statusCode = response.getStatusLine().getStatusCode();
                  boolean sentCredentials = context.getAttribute(Utils.HIVE_SERVER2_SENT_CREDENTIALS) != null &&
                      context.getAttribute(Utils.HIVE_SERVER2_SENT_CREDENTIALS).equals(Utils.HIVE_SERVER2_CONST_TRUE);
                  boolean ret = statusCode == 401 && executionCount <= 1 && !sentCredentials;

                  // Set the context attribute to true which will be interpreted by the request
                  // interceptor
                  if (ret) {
                    context.setAttribute(Utils.HIVE_SERVER2_RETRY_KEY,
                        Utils.HIVE_SERVER2_CONST_TRUE);
                  }
                  return ret;
                }
Add an interceptor to pass username/password in the header.
In https mode, the entire information is encrypted
jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java