List of usage examples for org.apache.http.auth NTCredentials NTCredentials
public NTCredentials(final String userName, final String password, final String workstation, final String domain)
From source file:org.jasig.portlet.calendar.adapter.exchange.ExchangeCredentialsInitializationService.java
public void initialize(PortletRequest request) { Object credentials;/* w w w. java 2 s .com*/ PortletPreferences prefs = request.getPreferences(); // 1. Exchange Impersonation if (usesExchangeImpersonation(request)) { String exchangeImpersonationUsername = prefs.getValue(PREFS_IMPERSONATION_USERNAME, ""); String exchangeImpersonationPassword = prefs.getValue(PREFS_IMPERSONATION_PASSWORD, ""); //do not fill in the domain field else authentication fails with a 503, service not available response credentials = new NTCredentials(exchangeImpersonationUsername, exchangeImpersonationPassword, "paramDoesNotSeemToMatter", ""); logger.debug("Creating Exchange Impersonation credentials for EWS call"); } else { // Get the password from the UserInfo map. @SuppressWarnings("unchecked") Map<String, String> userInfo = (Map<String, String>) request.getAttribute(PortletRequest.USER_INFO); String password = userInfo.get(passwordAttribute); if (password == null) { throw new CalendarException( "Required user attribute password is null. Insure user-attribute password" + " is enabled in portlet.xml and CAS ClearPass is configured properly"); } // 2. If the domain is specified, return NT credentials from the username, password, and domain. String ntDomain = getNtlmDomain(request); if (StringUtils.isNotBlank(ntDomain)) { String username = userInfo.get(usernameAttribute); credentials = createNTCredentials(ntDomain, username, password); logger.debug("Creating NT credentials for {}", username); } else { // 3. Otherwise construct credentials from the email address and password for Office365 integration. String emailAddress = userInfo.get(this.mailAttribute); if (emailAddress == null) { throw new CalendarException( "Required user attribute email address is null. Insure user-attribute mail" + " is enabled in portlet.xml and populated via LDAP or other approach"); } credentials = new UsernamePasswordCredentials(emailAddress, password); logger.debug("Creating simple username/password credentials for {}", emailAddress); } } // cache the credentials object to this thread RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes == null) { requestAttributes = new PortletRequestAttributes(request); RequestContextHolder.setRequestAttributes(requestAttributes); } requestAttributes.setAttribute(ExchangeWsCredentialsProvider.EXCHANGE_CREDENTIALS_ATTRIBUTE, credentials, RequestAttributes.SCOPE_SESSION); }
From source file:microsoft.exchange.webservices.data.core.request.HttpClientWebRequest.java
/** * Prepares the request by setting appropriate headers, authentication, timeouts, etc. *///from ww w . j av a2 s. com @Override public void prepareConnection() { httpPost = new HttpPost(getUrl().toString()); // Populate headers. httpPost.addHeader("Content-type", getContentType()); httpPost.addHeader("User-Agent", getUserAgent()); httpPost.addHeader("Accept", getAccept()); httpPost.addHeader("Keep-Alive", "300"); httpPost.addHeader("Connection", "Keep-Alive"); if (isAcceptGzipEncoding()) { httpPost.addHeader("Accept-Encoding", "gzip,deflate"); } if (getHeaders() != null) { for (Map.Entry<String, String> httpHeader : getHeaders().entrySet()) { httpPost.addHeader(httpHeader.getKey(), httpHeader.getValue()); } } // Build request configuration. // Disable Kerberos in the preferred auth schemes - EWS should usually allow NTLM or Basic auth RequestConfig.Builder requestConfigBuilder = RequestConfig.custom().setAuthenticationEnabled(true) .setConnectionRequestTimeout(getTimeout()).setConnectTimeout(getTimeout()) .setRedirectsEnabled(isAllowAutoRedirect()).setSocketTimeout(getTimeout()) .setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.BASIC)) .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.BASIC)); CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); // Add proxy credential if necessary. WebProxy proxy = getProxy(); if (proxy != null) { HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); requestConfigBuilder.setProxy(proxyHost); if (proxy.hasCredentials()) { NTCredentials proxyCredentials = new NTCredentials(proxy.getCredentials().getUsername(), proxy.getCredentials().getPassword(), "", proxy.getCredentials().getDomain()); credentialsProvider.setCredentials(new AuthScope(proxyHost), proxyCredentials); } } // Add web service credential if necessary. if (isAllowAuthentication() && getUsername() != null) { NTCredentials webServiceCredentials = new NTCredentials(getUsername(), getPassword(), "", getDomain()); credentialsProvider.setCredentials(new AuthScope(AuthScope.ANY), webServiceCredentials); } httpContext.setCredentialsProvider(credentialsProvider); httpPost.setConfig(requestConfigBuilder.build()); }
From source file:org.apache.manifoldcf.authorities.authorities.jira.JiraSession.java
/** * Constructor. Create a session.//from w ww .j av a 2 s . c o m */ public JiraSession(String clientId, String clientSecret, String protocol, String host, int port, String path, String proxyHost, int proxyPort, String proxyDomain, String proxyUsername, String proxyPassword) throws ManifoldCFException { this.host = new HttpHost(host, port, protocol); this.path = path; this.clientId = clientId; this.clientSecret = clientSecret; int socketTimeout = 900000; int connectionTimeout = 60000; javax.net.ssl.SSLSocketFactory httpsSocketFactory = KeystoreManagerFactory.getTrustingSecureSocketFactory(); SSLConnectionSocketFactory myFactory = new SSLConnectionSocketFactory( new InterruptibleSocketFactory(httpsSocketFactory, connectionTimeout), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); connectionManager = new PoolingHttpClientConnectionManager(); CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); // If authentication needed, set that if (clientId != null) { credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(clientId, clientSecret)); } RequestConfig.Builder requestBuilder = RequestConfig.custom().setCircularRedirectsAllowed(true) .setSocketTimeout(socketTimeout).setStaleConnectionCheckEnabled(true).setExpectContinueEnabled(true) .setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout); // If there's a proxy, set that too. if (proxyHost != null && proxyHost.length() > 0) { // Configure proxy authentication if (proxyUsername != null && proxyUsername.length() > 0) { if (proxyPassword == null) proxyPassword = ""; if (proxyDomain == null) proxyDomain = ""; credentialsProvider.setCredentials(new AuthScope(proxyHost, proxyPort), new NTCredentials(proxyUsername, proxyPassword, currentHost, proxyDomain)); } HttpHost proxy = new HttpHost(proxyHost, proxyPort); requestBuilder.setProxy(proxy); } httpClient = HttpClients.custom().setConnectionManager(connectionManager).setMaxConnTotal(1) .disableAutomaticRetries().setDefaultRequestConfig(requestBuilder.build()) .setDefaultSocketConfig( SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build()) .setDefaultCredentialsProvider(credentialsProvider).setSSLSocketFactory(myFactory) .setRequestExecutor(new HttpRequestExecutor(socketTimeout)) .setRedirectStrategy(new DefaultRedirectStrategy()).build(); }
From source file:org.apache.manifoldcf.crawler.connectors.confluence.ConfluenceSession.java
public ConfluenceSession(String clientId, String clientSecret, String protocol, String host, int port, String path, String proxyHost, int proxyPort, String proxyDomain, String proxyUsername, String proxyPassword) throws ManifoldCFException { this.host = new HttpHost(host, port, protocol); this.path = path; this.clientId = clientId; this.clientSecret = clientSecret; int socketTimeout = 900000; int connectionTimeout = 60000; javax.net.ssl.SSLSocketFactory httpsSocketFactory = KeystoreManagerFactory.getTrustingSecureSocketFactory(); SSLConnectionSocketFactory myFactory = new SSLConnectionSocketFactory( new InterruptibleSocketFactory(httpsSocketFactory, connectionTimeout), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); connectionManager = new PoolingHttpClientConnectionManager(); CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); // If authentication needed, set that if (clientId != null) { credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(clientId, clientSecret)); }/*w w w. j a va 2 s. co m*/ RequestConfig.Builder requestBuilder = RequestConfig.custom().setCircularRedirectsAllowed(true) .setSocketTimeout(socketTimeout).setStaleConnectionCheckEnabled(true).setExpectContinueEnabled(true) .setConnectTimeout(connectionTimeout).setConnectionRequestTimeout(socketTimeout); // If there's a proxy, set that too. if (proxyHost != null && proxyHost.length() > 0) { // Configure proxy authentication if (proxyUsername != null && proxyUsername.length() > 0) { if (proxyPassword == null) proxyPassword = ""; if (proxyDomain == null) proxyDomain = ""; credentialsProvider.setCredentials(new AuthScope(proxyHost, proxyPort), new NTCredentials(proxyUsername, proxyPassword, currentHost, proxyDomain)); } HttpHost proxy = new HttpHost(proxyHost, proxyPort); requestBuilder.setProxy(proxy); } httpClient = HttpClients.custom().setConnectionManager(connectionManager).setMaxConnTotal(1) .disableAutomaticRetries().setDefaultRequestConfig(requestBuilder.build()) .setDefaultSocketConfig( SocketConfig.custom().setTcpNoDelay(true).setSoTimeout(socketTimeout).build()) .setDefaultCredentialsProvider(credentialsProvider).setSSLSocketFactory(myFactory) .setRequestExecutor(new HttpRequestExecutor(socketTimeout)) .setRedirectStrategy(new DefaultRedirectStrategy()).build(); }
From source file:cn.ctyun.amazonaws.http.HttpClientFactory.java
/** * Creates a new HttpClient object using the specified AWS * ClientConfiguration to configure the client. * * @param config//from w ww . j a va 2 s .c om * Client configuration options (ex: proxy settings, connection * limits, etc). * * @return The new, configured HttpClient. */ public HttpClient createHttpClient(ClientConfiguration config) { /* Set HTTP client parameters */ HttpParams httpClientParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpClientParams, config.getConnectionTimeout()); HttpConnectionParams.setSoTimeout(httpClientParams, config.getSocketTimeout()); HttpConnectionParams.setStaleCheckingEnabled(httpClientParams, true); HttpConnectionParams.setTcpNoDelay(httpClientParams, true); int socketSendBufferSizeHint = config.getSocketBufferSizeHints()[0]; int socketReceiveBufferSizeHint = config.getSocketBufferSizeHints()[1]; if (socketSendBufferSizeHint > 0 || socketReceiveBufferSizeHint > 0) { HttpConnectionParams.setSocketBufferSize(httpClientParams, Math.max(socketSendBufferSizeHint, socketReceiveBufferSizeHint)); } /* Set connection manager */ ThreadSafeClientConnManager connectionManager = ConnectionManagerFactory .createThreadSafeClientConnManager(config, httpClientParams); DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpClientParams); httpClient.setRedirectStrategy(new LocationHeaderNotRequiredRedirectStrategy()); try { Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory()); SSLSocketFactory sf = new SSLSocketFactory(SSLContext.getDefault(), SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme("https", 443, sf); SchemeRegistry sr = connectionManager.getSchemeRegistry(); sr.register(http); sr.register(https); } catch (NoSuchAlgorithmException e) { throw new AmazonClientException("Unable to access default SSL context", e); } /* * If SSL cert checking for endpoints has been explicitly disabled, * register a new scheme for HTTPS that won't cause self-signed certs to * error out. */ if (System.getProperty("com.amazonaws.sdk.disableCertChecking") != null) { Scheme sch = new Scheme("https", 443, new TrustingSocketFactory()); httpClient.getConnectionManager().getSchemeRegistry().register(sch); } /* Set proxy if configured */ String proxyHost = config.getProxyHost(); int proxyPort = config.getProxyPort(); if (proxyHost != null && proxyPort > 0) { AmazonHttpClient.log .info("Configuring Proxy. Proxy Host: " + proxyHost + " " + "Proxy Port: " + proxyPort); HttpHost proxyHttpHost = new HttpHost(proxyHost, proxyPort); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHttpHost); String proxyUsername = config.getProxyUsername(); String proxyPassword = config.getProxyPassword(); String proxyDomain = config.getProxyDomain(); String proxyWorkstation = config.getProxyWorkstation(); if (proxyUsername != null && proxyPassword != null) { httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort), new NTCredentials(proxyUsername, proxyPassword, proxyWorkstation, proxyDomain)); } } return httpClient; }
From source file:jetbrains.buildServer.commitPublisher.github.api.impl.HttpClientWrapperImpl.java
private void setupProxy(DefaultHttpClient httpclient) { final String httpProxy = TeamCityProperties.getProperty("teamcity.github.http.proxy.host"); if (StringUtil.isEmptyOrSpaces(httpProxy)) return;/*ww w . j av a 2 s . c o m*/ final int httpProxyPort = TeamCityProperties.getInteger("teamcity.github.http.proxy.port", -1); if (httpProxyPort <= 0) return; LOG.info("TeamCity.GitHub will use proxy: " + httpProxy + ", port " + httpProxyPort); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(httpProxy, httpProxyPort)); final String httpProxyUser = TeamCityProperties.getProperty("teamcity.github.http.proxy.user"); final String httpProxyPassword = TeamCityProperties.getProperty("teamcity.github.http.proxy.password"); final String httpProxyDomain = TeamCityProperties.getProperty("teamcity.github.http.proxy.domain"); final String httpProxyWorkstation = TeamCityProperties .getProperty("teamcity.github.http.proxy.workstation"); if (StringUtil.isEmptyOrSpaces(httpProxyUser) || StringUtil.isEmptyOrSpaces(httpProxyPassword)) return; final Credentials creds; if (StringUtil.isEmptyOrSpaces(httpProxyDomain) || StringUtil.isEmptyOrSpaces(httpProxyWorkstation)) { LOG.info("TeamCity.GitHub will use proxy credentials: " + httpProxyUser); creds = new UsernamePasswordCredentials(httpProxyUser, httpProxyPassword); } else { LOG.info("TeamCity.GitHub will use proxy NT credentials: " + httpProxyDomain + "/" + httpProxyUser); creds = new NTCredentials(httpProxyUser, httpProxyPassword, httpProxyWorkstation, httpProxyDomain); } httpclient.getCredentialsProvider().setCredentials(new AuthScope(httpProxy, httpProxyPort), creds); }
From source file:com.servoy.extensions.plugins.http.BaseRequest.java
private Response executeRequest(String userName, String password, String workstation, String domain, boolean windowsAuthentication) throws Exception { HttpEntity entity = buildEntity();/*from w w w . ja va2s . c om*/ if (entity != null) ((HttpEntityEnclosingRequestBase) method).setEntity(entity); Iterator<String> it = headers.keySet().iterator(); while (it.hasNext()) { String name = it.next(); String[] values = headers.get(name); for (String value : values) { method.addHeader(name, value); } } if (!Utils.stringIsEmpty(userName)) { BasicCredentialsProvider bcp = new BasicCredentialsProvider(); URL _url = HttpProvider.createURLFromString(url, access); Credentials cred = null; if (windowsAuthentication) { if (context == null) { context = new BasicHttpContext(); } cred = new NTCredentials(userName, password, workstation, domain); } else { cred = new UsernamePasswordCredentials(userName, password); } bcp.setCredentials(new AuthScope(_url.getHost(), _url.getPort()), cred); client.setCredentialsProvider(bcp); } return new Response(client.execute(method, context)); }
From source file:com.sinacloud.scs.http.HttpClientFactory.java
/** * Creates a new HttpClient object using the specified AWS * ClientConfiguration to configure the client. * * @param config/* w ww. j a va 2 s . c o m*/ * Client configuration options (ex: proxy settings, connection * limits, etc). * * @return The new, configured HttpClient. */ @SuppressWarnings("deprecation") public HttpClient createHttpClient(ClientConfiguration config) { /* Set HTTP client parameters */ HttpParams httpClientParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpClientParams, config.getConnectionTimeout()); HttpConnectionParams.setSoTimeout(httpClientParams, config.getSocketTimeout()); HttpConnectionParams.setStaleCheckingEnabled(httpClientParams, true); HttpConnectionParams.setTcpNoDelay(httpClientParams, true); int socketSendBufferSizeHint = config.getSocketBufferSizeHints()[0]; int socketReceiveBufferSizeHint = config.getSocketBufferSizeHints()[1]; if (socketSendBufferSizeHint > 0 || socketReceiveBufferSizeHint > 0) { HttpConnectionParams.setSocketBufferSize(httpClientParams, Math.max(socketSendBufferSizeHint, socketReceiveBufferSizeHint)); } PoolingClientConnectionManager connectionManager = ConnectionManagerFactory .createPoolingClientConnManager(config, httpClientParams); SdkHttpClient httpClient = new SdkHttpClient(connectionManager, httpClientParams); if (config.getMaxErrorRetry() > 0) httpClient.setHttpRequestRetryHandler(SdkHttpRequestRetryHandler.Singleton); // httpClient.setRedirectStrategy(new LocationHeaderNotRequiredRedirectStrategy()); try { Scheme http = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80); SSLSocketFactory sf = new SSLSocketFactory(SSLContext.getDefault(), SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme("https", sf, 443); SchemeRegistry sr = connectionManager.getSchemeRegistry(); sr.register(http); sr.register(https); } catch (NoSuchAlgorithmException e) { throw new SCSClientException("Unable to access default SSL context", e); } // /* // * If SSL cert checking for endpoints has been explicitly disabled, // * register a new scheme for HTTPS that won't cause self-signed certs to // * error out. // */ // if (System.getProperty(DISABLE_CERT_CHECKING_SYSTEM_PROPERTY) != null) { Scheme sch = new Scheme("https", 443, new TrustingSocketFactory()); httpClient.getConnectionManager().getSchemeRegistry().register(sch); // } /* Set proxy if configured */ String proxyHost = config.getProxyHost(); int proxyPort = config.getProxyPort(); if (proxyHost != null && proxyPort > 0) { // AmazonHttpClient.log.info("Configuring Proxy. Proxy Host: " + proxyHost + " " + "Proxy Port: " + proxyPort); HttpHost proxyHttpHost = new HttpHost(proxyHost, proxyPort); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHttpHost); String proxyUsername = config.getProxyUsername(); String proxyPassword = config.getProxyPassword(); String proxyDomain = config.getProxyDomain(); String proxyWorkstation = config.getProxyWorkstation(); if (proxyUsername != null && proxyPassword != null) { httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort), new NTCredentials(proxyUsername, proxyPassword, proxyWorkstation, proxyDomain)); } } return httpClient; }
From source file:com.alu.e3.gateway.loadbalancer.E3HttpClientConfigurer.java
/** * Sets global PROXY for HttpClient/*from w w w .j av a2s . co m*/ * @param client HttpClient * @param params of the PROXY */ private void setForwardProxy(HttpClient client, HttpParams params) { if (forwardProxy != null) { if (client instanceof DefaultHttpClient) { String host = forwardProxy.getProxyHost(); Integer port = new Integer(forwardProxy.getProxyPort()); if (host != null && port != null) { HttpHost httpHost = new HttpHost(host, port); ConnRouteParamBean connRouteParamBean = new ConnRouteParamBean(params); connRouteParamBean.setDefaultProxy(httpHost); String user = forwardProxy.getProxyUser(); String pass = forwardProxy.getProxyPass(); if (user != null && pass != null) { Credentials credentials = null; String ntdomain = null; //targetHost.getForwardProxy().getProxyNtDomain; String ntworkstation = null; //targetHost.getForwardProxy().getProxyNtWorkstation(); if (ntdomain != null || ntworkstation != null) { credentials = new NTCredentials(user, pass, ntworkstation, ntdomain); } else { credentials = new UsernamePasswordCredentials(user, pass); } AuthScope authscope = new AuthScope(host, port); DefaultHttpClient defaultHttpClient = (DefaultHttpClient) client; defaultHttpClient.getCredentialsProvider().setCredentials(authscope, credentials); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("The proxy is set with no user or password information"); } } } else { LOGGER.error("Unable to set proxy settings: Host or Port are NULL"); } } else { LOGGER.error("Unable to set proxy settings: Unsupported HttpClient implementation"); } } }
From source file:pt.lunacloud.http.HttpClientFactory.java
/** * Creates a new HttpClient object using the specified AWS * ClientConfiguration to configure the client. * * @param config/*from w ww .j a v a 2 s . c o m*/ * Client configuration options (ex: proxy settings, connection * limits, etc). * * @return The new, configured HttpClient. */ public HttpClient createHttpClient(ClientConfiguration config) { /* Form User-Agent information */ String userAgent = config.getUserAgent(); if (!(userAgent.equals(ClientConfiguration.DEFAULT_USER_AGENT))) { userAgent += ", " + ClientConfiguration.DEFAULT_USER_AGENT; } /* Set HTTP client parameters */ HttpParams httpClientParams = new BasicHttpParams(); HttpProtocolParams.setUserAgent(httpClientParams, userAgent); HttpConnectionParams.setConnectionTimeout(httpClientParams, config.getConnectionTimeout()); HttpConnectionParams.setSoTimeout(httpClientParams, config.getSocketTimeout()); HttpConnectionParams.setStaleCheckingEnabled(httpClientParams, false); HttpConnectionParams.setTcpNoDelay(httpClientParams, true); int socketSendBufferSizeHint = config.getSocketBufferSizeHints()[0]; int socketReceiveBufferSizeHint = config.getSocketBufferSizeHints()[1]; if (socketSendBufferSizeHint > 0 || socketReceiveBufferSizeHint > 0) { HttpConnectionParams.setSocketBufferSize(httpClientParams, Math.max(socketSendBufferSizeHint, socketReceiveBufferSizeHint)); } /* Set connection manager */ ThreadSafeClientConnManager connectionManager = ConnectionManagerFactory .createThreadSafeClientConnManager(config, httpClientParams); DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpClientParams); httpClient.setRedirectStrategy(new LocationHeaderNotRequiredRedirectStrategy()); try { Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory()); SSLSocketFactory sf = new SSLSocketFactory(SSLContext.getDefault(), SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme("https", 443, sf); SchemeRegistry sr = connectionManager.getSchemeRegistry(); sr.register(http); sr.register(https); } catch (NoSuchAlgorithmException e) { throw new LunacloudClientException("Unable to access default SSL context"); } /* * If SSL cert checking for endpoints has been explicitly disabled, * register a new scheme for HTTPS that won't cause self-signed certs to * error out. */ if (System.getProperty("com.amazonaws.sdk.disableCertChecking") != null) { Scheme sch = new Scheme("https", 443, new TrustingSocketFactory()); httpClient.getConnectionManager().getSchemeRegistry().register(sch); } /* Set proxy if configured */ String proxyHost = config.getProxyHost(); int proxyPort = config.getProxyPort(); if (proxyHost != null && proxyPort > 0) { AmazonHttpClient.log .info("Configuring Proxy. Proxy Host: " + proxyHost + " " + "Proxy Port: " + proxyPort); HttpHost proxyHttpHost = new HttpHost(proxyHost, proxyPort); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHttpHost); String proxyUsername = config.getProxyUsername(); String proxyPassword = config.getProxyPassword(); String proxyDomain = config.getProxyDomain(); String proxyWorkstation = config.getProxyWorkstation(); if (proxyUsername != null && proxyPassword != null) { httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort), new NTCredentials(proxyUsername, proxyPassword, proxyWorkstation, proxyDomain)); } } return httpClient; }