class ImpersonatorInterceptor implements Interceptor {

  public static final String IMPERSONATE_USER = "Impersonate-User";

  public static final String NAME = "IMPERSONATOR";

  private final RequestConfig requestConfig;

  public ImpersonatorInterceptor(RequestConfig requestConfig) {
    this.requestConfig = requestConfig;
  }

  @Override
  public void before(BasicBuilder builder, HttpRequest request, RequestTags tags) {<FILL_FUNCTION_BODY>}
}

    RequestConfig config = Optional.ofNullable(tags.getTag(RequestConfig.class)).orElse(requestConfig);
    if (isNotNullOrEmpty(config.getImpersonateUsername())) {

      builder.header(IMPERSONATE_USER, config.getImpersonateUsername());

      String[] impersonateGroups = config.getImpersonateGroups();
      if (isNotNullOrEmpty(impersonateGroups)) {
        for (String group : impersonateGroups) {
          builder.header("Impersonate-Group", group);
        }
      }

      Map<String, List<String>> impersonateExtras = config.getImpersonateExtras();
      if (isNotNullOrEmpty(impersonateExtras)) {
        Collection<?> keys = impersonateExtras.keySet();
        for (Object key : keys) {
          List<String> values = impersonateExtras.get(key);
          if (values != null) {
            for (String value : values) {
              builder.header("Impersonate-Extra-" + key, value);
            }
          }
        }
      }
    }
  
<no_super_class>