当前位置: 首页>>代码示例>>Java>>正文


Java HttpConfigurable类代码示例

本文整理汇总了Java中com.intellij.util.net.HttpConfigurable的典型用法代码示例。如果您正苦于以下问题:Java HttpConfigurable类的具体用法?Java HttpConfigurable怎么用?Java HttpConfigurable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpConfigurable类属于com.intellij.util.net包,在下文中一共展示了HttpConfigurable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBuilder

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@NotNull
static HttpClientBuilder getBuilder() {
  final HttpClientBuilder builder = HttpClients.custom().setSSLContext(CertificateManager.getInstance().getSslContext()).
    setMaxConnPerRoute(100000).setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE);

  final HttpConfigurable proxyConfigurable = HttpConfigurable.getInstance();
  final List<Proxy> proxies = proxyConfigurable.getOnlyBySettingsSelector().select(URI.create(EduStepicNames.STEPIC_URL));
  final InetSocketAddress address = proxies.size() > 0 ? (InetSocketAddress)proxies.get(0).address() : null;
  if (address != null) {
    builder.setProxy(new HttpHost(address.getHostName(), address.getPort()));
  }
  final ConfirmingTrustManager trustManager = CertificateManager.getInstance().getTrustManager();
  try {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, new TrustManager[]{trustManager}, new SecureRandom());
    builder.setSSLContext(sslContext);
  }
  catch (NoSuchAlgorithmException | KeyManagementException e) {
    LOG.error(e.getMessage());
  }
  return builder;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:EduStepicClient.java

示例2: getReaderByUrl

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@Nullable
public static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi) throws IOException {
    if (surl.startsWith(JAR_PROTOCOL)) {
        VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));

        if (file == null) {
            return null;
        }

        return new StringReader(VfsUtil.loadText(file));
    }

    URL url = BrowserUtil.getURL(surl);
    if (url == null) {
        return null;
    }
    httpConfigurable.prepareURL(url.toString());
    final URLConnection urlConnection = url.openConnection();
    final String contentEncoding = urlConnection.getContentEncoding();
    final InputStream inputStream =
            pi != null ? UrlConnectionUtil.getConnectionInputStreamWithException(urlConnection, pi) : urlConnection.getInputStream();
    //noinspection IOResourceOpenedButNotSafelyClosed
    return contentEncoding != null ? new InputStreamReader(inputStream, contentEncoding) : new InputStreamReader(inputStream);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:25,代码来源:UrlUtil.java

示例3: getNetworkConfig

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@NotNull
private Config getNetworkConfig(@NotNull ApplicationSettings settings) {
    ProxyConfig proxyConfig;
    try {
        final HttpConfigurable iConfig = HttpConfigurable.getInstance();
        if (iConfig.isHttpProxyEnabledForUrl(settings.serverRoot)) {
            proxyConfig = new ProxyConfig(iConfig.PROXY_HOST, iConfig.PROXY_PORT, iConfig.getProxyLogin(), iConfig.getPlainProxyPassword());
        } else {
            proxyConfig = null;
        }
    } catch (Exception ignored) {
        // if that fails, we pretend there is no proxy. This might fail do to subtle changes in the HttpConfigurable class between intellij versions.
        proxyConfig = null;
    }
    return new Config(settings.apiKey, settings.userId, settings.workspaceId, settings.serverRoot,
            settings.trackingRoot, settings.isTrackingEnabled, settings.connectTimeout, settings.requestTimeout,
            settings.isApacheLoggingEnabled, settings.isJsonDebugEnabled, proxyConfig, applicationUserAgent);
}
 
开发者ID:samebug,项目名称:samebug-idea-plugin,代码行数:19,代码来源:IdeaSamebugPlugin.java

示例4: createVersionsUrl

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@Nullable
private URL createVersionsUrl() {
  final String serviceUrl = getServiceUrl();
  if (StringUtil.isNotEmpty(serviceUrl)) {
    try {
      final String url = serviceUrl + "/" + FILE_NAME;
      HttpConfigurable.getInstance().prepareURL(url);

      return new URL(url);
    }
    catch (MalformedURLException ignored) {
    }
    catch (IOException e) {
      // no route to host, unknown host, etc.
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LibraryJarStatisticsService.java

示例5: createSoap

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@NotNull
private MantisConnectPortType createSoap() throws Exception {
  if (isUseProxy()) {
    for (KeyValue<String, String> pair : HttpConfigurable.getJvmPropertiesList(false, null)) {
      String key = pair.getKey(), value = pair.getValue();
      // Axis uses another names for username and password properties
      // see http://axis.apache.org/axis/java/client-side-axis.html for complete list
      if (key.equals(JavaProxyProperty.HTTP_USERNAME)) {
        AxisProperties.setProperty("http.proxyUser", value);
      }
      else if (key.equals(JavaProxyProperty.HTTP_PASSWORD)) {
        AxisProperties.setProperty("http.proxyPassword", value);
      }
      else {
        AxisProperties.setProperty(key, value);
      }
    }
  }
  return new MantisConnectLocator().getMantisConnectPort(new URL(getUrl() + SOAP_API_LOCATION));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MantisRepository.java

示例6: configureHttpClient

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
protected void configureHttpClient(HttpClient client) {
  client.getParams().setConnectionManagerTimeout(3000);
  client.getParams().setSoTimeout(TaskSettings.getInstance().CONNECTION_TIMEOUT);
  if (isUseProxy()) {
    HttpConfigurable proxy = HttpConfigurable.getInstance();
    client.getHostConfiguration().setProxy(proxy.PROXY_HOST, proxy.PROXY_PORT);
    if (proxy.PROXY_AUTHENTICATION) {
      AuthScope authScope = new AuthScope(proxy.PROXY_HOST, proxy.PROXY_PORT);
      Credentials credentials = getCredentials(proxy.PROXY_LOGIN, proxy.getPlainProxyPassword(), proxy.PROXY_HOST);
      client.getState().setProxyCredentials(authScope, credentials);
    }
  }
  if (isUseHttpAuthentication()) {
    client.getParams().setCredentialCharset("UTF-8");
    client.getParams().setAuthenticationPreemptive(true);
    client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(getUsername(), getPassword()));
  }
  else {
    client.getState().clearCredentials();
    client.getParams().setAuthenticationPreemptive(false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:BaseRepositoryImpl.java

示例7: setupSshAuthenticator

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
private void setupSshAuthenticator() throws IOException {
  GitXmlRpcSshService ssh = ServiceManager.getService(GitXmlRpcSshService.class);
  myEnv.put(GitSSHHandler.GIT_SSH_ENV, ssh.getScriptPath().getPath());
  mySshHandler = ssh.registerHandler(new GitSSHGUIHandler(myProject));
  myEnvironmentCleanedUp = false;
  myEnv.put(GitSSHHandler.SSH_HANDLER_ENV, Integer.toString(mySshHandler));
  int port = ssh.getXmlRcpPort();
  myEnv.put(GitSSHHandler.SSH_PORT_ENV, Integer.toString(port));
  LOG.debug(String.format("handler=%s, port=%s", mySshHandler, port));

  final HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
  boolean useHttpProxy = httpConfigurable.USE_HTTP_PROXY && !isSshUrlExcluded(httpConfigurable, ObjectUtils.assertNotNull(myUrls));
  myEnv.put(GitSSHHandler.SSH_USE_PROXY_ENV, String.valueOf(useHttpProxy));

  if (useHttpProxy) {
    myEnv.put(GitSSHHandler.SSH_PROXY_HOST_ENV, StringUtil.notNullize(httpConfigurable.PROXY_HOST));
    myEnv.put(GitSSHHandler.SSH_PROXY_PORT_ENV, String.valueOf(httpConfigurable.PROXY_PORT));
    boolean proxyAuthentication = httpConfigurable.PROXY_AUTHENTICATION;
    myEnv.put(GitSSHHandler.SSH_PROXY_AUTHENTICATION_ENV, String.valueOf(proxyAuthentication));

    if (proxyAuthentication) {
      myEnv.put(GitSSHHandler.SSH_PROXY_USER_ENV, StringUtil.notNullize(httpConfigurable.PROXY_LOGIN));
      myEnv.put(GitSSHHandler.SSH_PROXY_PASSWORD_ENV, StringUtil.notNullize(httpConfigurable.getPlainProxyPassword()));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GitHandler.java

示例8: getIdeaDefinedProxy

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@Nullable
public static Proxy getIdeaDefinedProxy(@NotNull final SVNURL url) {
  // SVNKit authentication implementation sets repositories as noProxy() to provide custom proxy authentication logic - see for instance,
  // SvnAuthenticationManager.getProxyManager(). But noProxy() setting is not cleared correctly in all cases - so if svn command
  // (for command line) is executed on thread where repository url was added as noProxy() => proxies are not retrieved for such commands
  // and execution logic is incorrect.

  // To prevent such behavior repositoryUrl is manually removed from noProxy() list (for current thread).
  // NOTE, that current method is only called from code flows for executing commands through command line client and should not be called
  // from SVNKit code flows.
  CommonProxy.getInstance().removeNoProxy(url.getProtocol(), url.getHost(), url.getPort());

  final List<Proxy> proxies = CommonProxy.getInstance().select(URI.create(url.toString()));
  if (proxies != null && !proxies.isEmpty()) {
    for (Proxy proxy : proxies) {
      if (HttpConfigurable.isRealProxy(proxy) && Proxy.Type.HTTP.equals(proxy.type())) {
        return proxy;
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AuthenticationService.java

示例9: getProxyLogin

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
/**
 * Find the proxy login username
 *
 * @return
 */
public static String getProxyLogin() {
    try {
        // try to get login name using method existing in IDEA release 163.1188 and above
        final Method proxyLoginMethod = HttpConfigurable.getInstance().getClass().getDeclaredMethod(PROXY_LOGIN_METHOD);
        return (String) proxyLoginMethod.invoke(HttpConfigurable.getInstance(), null);
    } catch (Exception newImplementationException) {
        try {
            logger.warn("Failed to get proxy login using getProxyLogin() so attempting old way", newImplementationException);
            // try to get login name using global variable existing before IDEA release 163.1188
            final Field proxyLoginField = HttpConfigurable.getInstance().getClass().getDeclaredField(PROXY_LOGIN_FIELD);
            return (String) proxyLoginField.get(HttpConfigurable.getInstance());
        } catch (Exception oldImplementationException) {
            logger.warn("Failed to get proxy login using PROXY_LOGIN field", oldImplementationException);
            return StringUtils.EMPTY;
        }
    }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:23,代码来源:BackCompatibleUtils.java

示例10: doOKAction

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@Override
protected void doOKAction() {
  if (shouldPromptForProxyPassword(false)) {
    HttpConfigurable hc = HttpConfigurable.getInstance();
    hc.setPlainProxyPassword(myLoginForm.getProxyPassword());
  }

  if (myLoginForm.getCredentials().getType() == Credentials.Type.Alternate && "http".equals(getUri().getScheme())) {
    if (Messages.showYesNoDialog(myLoginForm.getContentPane(),
                                 "You're about to send your credentials over unsecured HTTP connection. Continue?", getTitle(),
                                 null) != Messages.YES) {
      return;
    }
  }

  if (myOkActionCallback == null || myOkActionCallback.value(this)) {
    super.doOKAction();
  }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:20,代码来源:TfsLoginDialog.java

示例11: getCurrent

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
public static HTTPProxyInfo getCurrent() {
  // axis will override the higher-level settings with system properties, so explicitly clear them
  CommonProxy.isInstalledAssertion();

  if (TFSConfigurationManager.getInstance().useIdeaHttpProxy()) {
    final HttpConfigurable hc = HttpConfigurable.getInstance();
    if (hc.USE_HTTP_PROXY) {
      if (hc.PROXY_AUTHENTICATION) {
        // here we assume proxy auth dialog was shown if needed, see promptForPassword() caller
        return new HTTPProxyInfo(hc.PROXY_HOST, hc.PROXY_PORT, hc.PROXY_LOGIN, hc.getPlainProxyPassword());
      }
      else {
        return new HTTPProxyInfo(hc.PROXY_HOST, hc.PROXY_PORT, null, null);
      }
    }
  }
  return new HTTPProxyInfo(null, -1, null, null);
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:19,代码来源:HTTPProxyInfo.java

示例12: execute

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
/**
 * Spuštění stahování
 *
 * @param project       aktuální projekt
 * @param tagName       aktuální release
 * @param task          akce, která se spustí při stahování
 */
private void execute( @NotNull Project project, @NotNull String tagName, @NotNull Consumer<HttpURLConnection> task)
{
    HttpURLConnection connection = null;
    try
    {
        connection = HttpConfigurable.getInstance().openHttpConnection( String.format( ZIP_URL_PATTERN, tagName, tagName ) );
        task.consume(connection);
    }
    catch (IOException e)
    {
        warn(project, e.getMessage()) ;
    }
    finally
    {
        if (connection != null)
        {
            connection.disconnect();
        }
    }
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgentIntelliJ,代码行数:28,代码来源:HotswapAgentIntegration.java

示例13: post

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
private static HttpURLConnection post(URL url, byte[] bytes) throws IOException {
  HttpURLConnection connection = (HttpURLConnection)HttpConfigurable.getInstance().openConnection(url.toString());

  connection.setReadTimeout(10 * 1000);
  connection.setConnectTimeout(10 * 1000);
  connection.setRequestMethod(HTTP_POST);
  connection.setDoInput(true);
  connection.setDoOutput(true);
  connection.setRequestProperty(HTTP_CONTENT_TYPE, String.format("%s; charset=%s", HTTP_WWW_FORM, ENCODING));
  connection.setRequestProperty(HTTP_CONTENT_LENGTH, Integer.toString(bytes.length));

  OutputStream out = new BufferedOutputStream(connection.getOutputStream());
  try {
    out.write(bytes);
    out.flush();
  } finally {
    out.close();
  }

  return connection;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:ITNProxy.java

示例14: getReaderByUrl

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
@Nullable
private static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi)
  throws IOException
{
  if (surl.startsWith(JAR_PROTOCOL)) {
    VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));

    if (file == null) {
      return null;
    }

    return new StringReader(VfsUtilCore.loadText(file));
  }

  URL url = BrowserUtil.getURL(surl);
  if (url == null) {
    return null;
  }
  final URLConnection urlConnection = httpConfigurable.openConnection(url.toString());
  final String contentEncoding = guessEncoding(url);
  final InputStream inputStream =
    pi != null ? UrlConnectionUtil.getConnectionInputStreamWithException(urlConnection, pi) : urlConnection.getInputStream();
  //noinspection IOResourceOpenedButNotSafelyClosed
  return contentEncoding != null ? new MyReader(inputStream, contentEncoding) : new MyReader(inputStream);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:AbstractExternalFilter.java

示例15: configureHttpClient

import com.intellij.util.net.HttpConfigurable; //导入依赖的package包/类
protected void configureHttpClient(HttpClient client) {
  client.getParams().setConnectionManagerTimeout(3000);
  client.getParams().setSoTimeout(TaskSettings.getInstance().CONNECTION_TIMEOUT);
  if (isUseProxy()) {
    HttpConfigurable proxy = HttpConfigurable.getInstance();
    client.getHostConfiguration().setProxy(proxy.PROXY_HOST, proxy.PROXY_PORT);
    if (proxy.PROXY_AUTHENTICATION) {
      AuthScope authScope = new AuthScope(proxy.PROXY_HOST, proxy.PROXY_PORT);
      Credentials credentials = getCredentials(proxy.PROXY_LOGIN, proxy.getPlainProxyPassword(), proxy.PROXY_HOST);
      client.getState().setProxyCredentials(authScope, credentials);
    }
  }
  if (isUseHttpAuthentication()) {
    client.getParams().setCredentialCharset("UTF-8");
    client.getParams().setAuthenticationPreemptive(true);
    client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(getUsername(), getPassword()));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:BaseRepositoryImpl.java


注:本文中的com.intellij.util.net.HttpConfigurable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。