client.getHostConfiguration().setProxy(name, port); Credentials credentials = createCredentials(userName, password); AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
client.getHostConfiguration().setProxy(proxyHost, proxyPort); if (StringUtils.isNotBlank(proxyUser)) { client.getState().setProxyCredentials(AuthScope.ANY,
throw new IllegalArgumentException("HttpMethod parameter may not be null"); HostConfiguration defaulthostconfig = getHostConfiguration(); if (hostconfig == null) { hostconfig = defaulthostconfig;
/** * @param username * @param password * @param httpClient */ public static void setCredentials(String username, String password, HttpClient httpClient) { if (username != null && password != null && httpClient != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Setting credentials with username " + username + " for host " + httpClient.getHostConfiguration().getHost() + ":" + httpClient.getHostConfiguration().getPort()); } httpClient.getParams().setAuthenticationPreemptive(true); httpClient.getState().setCredentials( new AuthScope(httpClient.getHostConfiguration().getHost(), httpClient.getHostConfiguration().getPort(), AuthScope.ANY_REALM), new UsernamePasswordCredentials(username, password)); } }
"Found 'http.proxyHost' Java System property. Using it as proxy server. Port: " + proxyPort); HostConfiguration hostConfig = client.getHostConfiguration(); if (nonProxyHostProp != null) { if (nonProxyHostProp.startsWith("\"")) {
"Found 'http.proxyHost' Java System property. Using it as proxy server. Port: " + proxyPort); HostConfiguration hostConfig = client.getHostConfiguration(); hostConfig.setProxy(proxyHost, proxyPort);
/** * @param proxy * @param httpClient */ public static void setProxy(Proxy proxy, HttpClient httpClient) { if (proxy != null && httpClient != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Setting proxy with host " + proxy.getHost() + " and port " + proxy.getPort() + " for host " + httpClient.getHostConfiguration().getHost() + ":" + httpClient.getHostConfiguration().getPort()); } httpClient.getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort()); if (proxy.getUserName() != null && proxy.getPassword() != null) { httpClient.getState().setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(proxy.getUserName(), proxy.getPassword())); } } }
private void checkProxy(Proxy proxy) { if (proxy != null) { client.getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort()); if (proxy.getUserName() != null) { Credentials proxyCreds = new UsernamePasswordCredentials(proxy.getUserName(), proxy.getPassword()); client.getState().setProxyCredentials(AuthScope.ANY, proxyCreds); } } }
private void resolveHttpParams(HttpParams params) { if (params != null) { if (params.getProxy() != null) { InetSocketAddress socketAddress = (InetSocketAddress) params .getProxy().address(); httpClient.getHostConfiguration().setProxy( socketAddress.getHostName(), socketAddress.getPort()); } if (params.getSSLContext() != null) { Protocol.registerProtocol("https", new Protocol("https", new SSLProtocolSocketFactory(params.getSSLContext()), 443)); } httpClient.getHttpConnectionManager().getParams() .setConnectionTimeout(params.getConnectTimeout()); } }
@Override public void setRobotProxy(String host, int port) { http.getHostConfiguration().setProxy(host, port); } }
void setProxy(Proxy proxy) { if(sessionClient == null) return; if(proxy != null && proxy.host != null) sessionClient.getHostConfiguration().setProxy(proxy.host, proxy.port); }
protected String getUri(String... paths) { String uri = client.getHostConfiguration().getHostURL(); for (String path : paths) { uri += '/' + path; } return uri; }
private HttpClient getClient() { HttpClient client = new HttpClient(); if( proxyHost != null ) { client.getHostConfiguration().setProxy(proxyHost, proxyPort); } return client; }
/** * Create a new Client. The client will not use authentication by default. */ public Client() { client = new HttpClient(); client.getParams().setParameter("http.socket.timeout", new Integer(DEFAULT_TIMEOUT)); log.debug("proxy host: " + client.getHostConfiguration().getProxyHost()); log.debug("proxy port: " + client.getHostConfiguration().getProxyPort()); doAuthentication = false; }
protected HttpClient getDefaultHttpClient(String httpHost, int httpPort) { HttpClient httpClient = constructHttpClient(); httpClient.getHostConfiguration().setHost(httpHost, httpPort); return httpClient; }
protected HttpConnection getConnection() { return client.getHttpConnectionManager().getConnection( client.getHostConfiguration() ); }
/** * {@inheritDoc} */ @Override public void onProxyChange(ProxySettings proxySettings) { if (proxySettings.isEnabled()) { client = new HttpClient(); client.getHostConfiguration().setProxy(proxySettings.getProxyHost(), proxySettings.getProxyPort()); } else { client = new HttpClient(); } }
private void initHttpClient() { m_client = new HttpClient(); ProxyManager proxyManager = new ProxyManager(); ProxyHost proxy = proxyManager.getProxyHost(getURL()); if (proxy != null) { LOG.debug("for server " + getURL() + " using proxy: '" + proxy.getHostName() + "'"); } else { LOG.debug("for server " + getURL() + " not using proxy!"); } m_client.getHostConfiguration().setProxyHost(proxy); m_client.getState().setProxyCredentials(AuthScope.ANY, proxyManager.getProxyCredentials(getURL())); }
protected void updateContext( ProxyRepository repository, RemoteStorageContext ctx ) { HttpClient httpClient = new HttpClient( new CustomMultiThreadedHttpConnectionManager() ); HttpClientProxyUtil.applyProxyToHttpClient( httpClient, ctx, getLogger() ); ctx.putContextObject( CTX_KEY_CLIENT, httpClient ); ctx.putContextObject( CTX_KEY_HTTP_CONFIGURATION, httpClient.getHostConfiguration() ); // NEXUS-3338: we don't know afer config change is remote S3 (url changed maybe) ctx.putContextObject( CTX_KEY_S3_FLAG, new BooleanFlagHolder() ); }
protected HttpClient getHttpsClient(String httpsHost, int httpsPort) { // Configure a custom SSL socket factory that will enforce mutual authentication HttpClient httpClient = constructHttpClient(); HttpHostFactory hostFactory = new HttpHostFactory(new Protocol("https", sslSocketFactory, httpsPort)); httpClient.setHostConfiguration(new HostConfigurationWithHostFactory(hostFactory)); httpClient.getHostConfiguration().setHost(httpsHost, httpsPort, "https"); return httpClient; }