Package com.intellij.util.net

Examples of com.intellij.util.net.HttpConfigurable


    params.setConnectionTimeout(timeout); //set connection timeout (how long it takes to connect to remote host)
    params.setSoTimeout(timeout); //set socket timeout (how long it takes to retrieve data from remote host)

    client.getParams().setContentCharset("UTF-8");
    // Configure proxySettings if it is required
    final HttpConfigurable proxySettings = HttpConfigurable.getInstance();
    if (useProxy && proxySettings.USE_HTTP_PROXY && !StringUtil.isEmptyOrSpaces(proxySettings.PROXY_HOST)) {
      client.getHostConfiguration().setProxy(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
      if (proxySettings.PROXY_AUTHENTICATION) {
        client.getState().setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(proxySettings.PROXY_LOGIN,
            proxySettings.getPlainProxyPassword()));
      }
    }
    if (basicAuth != null) {
      client.getParams().setCredentialCharset("UTF-8");
      client.getParams().setAuthenticationPreemptive(true);
View Full Code Here


        .login(host.getUsername())
        .password(host.getPassword());
    Optional<Proxy> proxy = getIntelliJProxyFor(host);
    if (proxy.isPresent()) {
      InetSocketAddress address = (InetSocketAddress) proxy.get().address();
      HttpConfigurable proxySettings = HttpConfigurable.getInstance();
      builder.proxy(address.getHostName(), address.getPort());
      if (proxySettings.PROXY_AUTHENTICATION) {
        builder.proxyLogin(proxySettings.PROXY_LOGIN).proxyPassword(proxySettings.getPlainProxyPassword());
      }
    }
    return builder.build();
  }
View Full Code Here

            hostServer.setUsername(user);
            hostServer.setPassword(password);
        }
        final HttpClient4Connector connector = new HttpClient4Connector(hostServer);
        // check whether IDEA has a proxy set
        HttpConfigurable proxySettings = HttpConfigurable.getInstance();
        if (useProxy && proxySettings.USE_HTTP_PROXY) {
            DefaultHttpClient httpClient = connector.getHttpClient();
            // set proxy authentication if needed
            if (proxySettings.PROXY_AUTHENTICATION) {
                AuthScope authScope = new AuthScope(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
                UsernamePasswordCredentials proxyCredentials = new UsernamePasswordCredentials(
                        proxySettings.PROXY_LOGIN, proxySettings.getPlainProxyPassword());

                httpClient.getCredentialsProvider().setCredentials(authScope, proxyCredentials);
            }
            HttpHost proxy = new HttpHost(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
            httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
View Full Code Here

    return prefix + appDirName + "/doc/html/" + virtualFile.getNameWithoutExtension() + ".html";
  }

  @NotNull
  private static BufferedReader createHttpReader(@NotNull URL url) throws IOException {
    HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
    httpConfigurable.prepareURL(url.toString());
    URLConnection urlConnection = url.openConnection();
    String contentEncoding = urlConnection.getContentEncoding();
    InputStream inputStream = urlConnection.getInputStream();
    //noinspection IOResourceOpenedButNotSafelyClosed
    InputStreamReader inputStreamReader = contentEncoding != null
View Full Code Here

   * Creates new translate helper.
   *
   * @throws Exception the exception
   */
  public TranslateHelper() throws Exception {
    HttpConfigurable httpConfigurable = (HttpConfigurable)
        ApplicationManager.getApplication().getComponent("HttpConfigurable");

    if (httpConfigurable == null) {
      httpConfigurable = HttpConfigurable.getInstance();
    }
View Full Code Here

    urlConnection.setRequestProperty("Accept", "*/*");
    urlConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Maxthon; .NET CLR 1.1.4322)");
    urlConnection.setRequestProperty("Pragma", "no-cache");

    HttpConfigurable httpConfigurable = (HttpConfigurable)
        ApplicationManager.getApplication().getComponent("HttpConfigurable");

    if (httpConfigurable != null) {
      if (httpConfigurable.PROXY_AUTHENTICATION) {
        // proxy user and pass
        urlConnection.setRequestProperty(
            "Proxy-Authorization",
            "Basic " + new sun.misc.BASE64Encoder().encode((httpConfigurable.PROXY_LOGIN + ":" +
                httpConfigurable.getPlainProxyPassword()).getBytes()
            ));
      }
    }

    return urlConnection;
View Full Code Here

    @Override
    public CredentialsProvider extendCredentialProvider(HttpClientBuilder httpClientBuilder,
                                                        CredentialsProvider credentialsProvider,
                                                        GerritAuthData authData) {
        HttpConfigurable proxySettings = HttpConfigurable.getInstance();
        IdeaWideProxySelector ideaWideProxySelector = new IdeaWideProxySelector(proxySettings);

        // This will always return at least one proxy, which can be the "NO_PROXY" instance.
        List<Proxy> proxies = ideaWideProxySelector.select(URI.create(authData.getHost()));

        // Find the first real proxy with an address type we support.
        for (Proxy proxy : proxies) {
            SocketAddress socketAddress = proxy.address();

            if (HttpConfigurable.isRealProxy(proxy) && socketAddress instanceof InetSocketAddress) {
                InetSocketAddress address = (InetSocketAddress) socketAddress;
                HttpHost proxyHttpHost = new HttpHost(address.getHostName(), address.getPort());
                httpClientBuilder.setProxy(proxyHttpHost);

                // Here we use the single username/password that we got from IDEA's settings. It feels kinda strange
                // to use these credential but it's probably what the user expects.
                if (proxySettings.PROXY_AUTHENTICATION) {
                    AuthScope authScope = new AuthScope(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
                    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(proxySettings.PROXY_LOGIN, proxySettings.getPlainProxyPassword());
                    credentialsProvider.setCredentials(authScope, credentials);
                    break;
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.intellij.util.net.HttpConfigurable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.