【发布时间】:2015-07-08 09:23:26
【问题描述】:
我尝试使用此类 https://subversion.jfrog.org/jfrog/build-info/trunk/build-info-client/src/main/java/org/jfrog/build/client/PreemptiveHttpClient.java 和 Solr 为 Basic Auth 保护的 Solr 进行 PreEmptive Authentication,但这些方法已被弃用,所以我不知道这是否是一个问题。在 Solr 中查询的情况很好,但是对于索引我在与服务器交谈时发生 IOException:example.com:8983/solr/core1。
HttpSolrClient 构造函数需要一个 httpClient 作为参数来执行抢先授权,因此对于上面的类,因为 httpClient 存储在一个私有变量中,所以我在该变量上使用了一个 getter 来获取 httpClient 并传递给 HttpSolrClient 构造函数。也不确定我是否做对了。
PreemptiveAuthenticate preemp = new PreemptiveAuthenticate("username", "password", 1);
DefaultHttpClient httpClient = preemp.getHttpClient();
System.out.println("Made it to connectSolr after set Authentication");
SolrClient solr = new HttpSolrClient(urlString, httpClient);
我知道像 http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html Example 4.6 这样的示例可以使用 HttpClient 4.3 进行抢先授权,但这是一个测试用例,我看不到通过 HttpClient 进行抢先身份验证的方法。
【问题讨论】:
标签: solr httpclient basic-authentication preemptive