@Override
  public String requestURL(String url, String requestType, final ImpersonatorSetting impersonatorSetting) {
    String result = "";
    BufferedReader rd;
    String line;

    if (url.toLowerCase().contains(impersonatorSetting.getDoAsParamName().toLowerCase())) {
      throw new IllegalArgumentException("URL cannot contain \"" + impersonatorSetting.getDoAsParamName() + "\" parameter");
    }

    try {
      String username = impersonatorSetting.getUsername();
      if (username != null) {
        URIBuilder builder = new URIBuilder(url);
        builder.addParameter(impersonatorSetting.getDoAsParamName(), username);
        url = builder.build().toString();
      }

      HttpURLConnection connection = urlStreamProvider.processURL(url, requestType, (String) null, null);

      int responseCode = connection.getResponseCode();
      InputStream resultInputStream;
      if (responseCode >= ProxyService.HTTP_ERROR_RANGE_START) {
        resultInputStream = connection.getErrorStream();
      } else {
        resultInputStream = connection.getInputStream();
      }

      rd = new BufferedReader(new InputStreamReader(resultInputStream));

      line = rd.readLine();
      while (line != null) {
        result += line;
        line = rd.readLine();
      }
      rd.close();
    } catch (Exception e) {
      LOG.error("Exception caught processing impersonator request.", e);
    }
    return result;
  }
Returns the result of the HTTP request by setting the "doAs" impersonation for the query param and username
in @param impersonatorSetting.
@param url URL to request
@param requestType HTTP Request type: GET, PUT, POST, DELETE, etc.
@param impersonatorSetting Setting class with default values for username and doAs param name.
                          To use different values, call the setters of the object.
@return Return a response as a String
ambari-server/src/main/java/org/apache/ambari/server/view/HttpImpersonatorImpl.java