Java Code Examples for org.apache.commons.httpclient.auth.AuthScope#ANY_PORT
The following examples show how to use
org.apache.commons.httpclient.auth.AuthScope#ANY_PORT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CredentialsUtils.java From httpclientAuthHelper with Apache License 2.0 | 7 votes |
public static void setNTLMCredentials(HttpClient httpClient, UsernamePasswordCredentials credentials, String domain) { initNTLMv2(); String localHostName; try { localHostName = Inet4Address.getLocalHost().getHostName(); } catch (Exception e) { localHostName = ""; } AuthScope authscope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT); httpClient.getState().setCredentials( authscope, new NTCredentials( credentials.getUserName(), credentials.getPassword(), localHostName, domain)); }
Example 2
Source File: SolrUtils.java From anthelion with Apache License 2.0 | 4 votes |
public static CommonsHttpSolrServer getCommonsHttpSolrServer(JobConf job) throws MalformedURLException { HttpClient client=new HttpClient(); // Check for username/password if (job.getBoolean(SolrConstants.USE_AUTH, false)) { String username = job.get(SolrConstants.USERNAME); LOG.info("Authenticating as: " + username); AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME); client.getState().setCredentials(scope, new UsernamePasswordCredentials(username, job.get(SolrConstants.PASSWORD))); HttpClientParams params = client.getParams(); params.setAuthenticationPreemptive(true); client.setParams(params); } return new CommonsHttpSolrServer(job.get(SolrConstants.SERVER_URL), client); }
Example 3
Source File: SolrUtils.java From nutch-htmlunit with Apache License 2.0 | 4 votes |
public static CommonsHttpSolrServer getCommonsHttpSolrServer(JobConf job) throws MalformedURLException { HttpClient client=new HttpClient(); // Check for username/password if (job.getBoolean(SolrConstants.USE_AUTH, false)) { String username = job.get(SolrConstants.USERNAME); LOG.info("Authenticating as: " + username); AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME); client.getState().setCredentials(scope, new UsernamePasswordCredentials(username, job.get(SolrConstants.PASSWORD))); HttpClientParams params = client.getParams(); params.setAuthenticationPreemptive(true); client.setParams(params); } String serverURL = job.get(SolrConstants.SERVER_URL); return new CommonsHttpSolrServer(serverURL, client); }