class HttpTransportFactory extends BaseHttpTransportFactory {

  @Override
  public void setConf(AbstractConfig config) {
    HttpTransportConfig httpConfig = (HttpTransportConfig) config;

    BasicHttpAuthConfig auth = (BasicHttpAuthConfig) httpConfig.getBasicHttpAuth();
    if (auth != null) {
      byte[] encodedAuth =
          Base64.encodeBase64((auth.getUsername() + ":" + auth.getPassword()).getBytes());

      httpConfig.addHttpHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
    }

    super.setConf(config);
  }

}