@Override
  protected void addHttpAuthHeader(HttpRequest httpRequest, HttpContext httpContext)
      throws Exception {
    String port = String.valueOf(browserClient.getPort());
    String token = browserClient.getServerResponse() == null ? null
        : browserClient.getServerResponse().getToken();
    String clientIdentifier = browserClient.getClientIdentifier();
    if (token != null && !token.isEmpty()) {
      httpRequest.addHeader(HttpHeaders.AUTHORIZATION, HttpAuthUtils.BEARER + " " + token);
      httpRequest.addHeader(HiveSamlUtils.SSO_CLIENT_IDENTIFIER, clientIdentifier);
      httpRequest.removeHeaders(HiveSamlUtils.SSO_TOKEN_RESPONSE_PORT);
    } else {
      LOG.debug("Adding response port {}", port);
      httpRequest.addHeader(HiveSamlUtils.SSO_TOKEN_RESPONSE_PORT, port);
    }
  }
This implements the logic to intercept the HTTP requests from the Hive Jdbc connection
and add the bearer token and client identifier to the headers from the underlying
{@link IJdbcBrowserClient}.
jdbc/src/java/org/apache/hive/jdbc/saml/HttpSamlAuthRequestInterceptor.java