[英]Authentication of Solr Cloud using zookeeper host string
我想为我的SolrCloud
设置身份验证。 我在Java中使用SolrJ6.5.0
。 我的CloudSolrClient
是通过直接使用Zookeeper
主机定义的:
CloudSolrClient serverCloud = new CloudSolrClient.Builder().
withZkHost(connectionStr).build();
我看到了Deepak Shrivastava和Brian teggart用来验证solr的有用代码。
@Deepak Shrivastava使用HttpSolrClient
而@Brian teggart使用AuthScope
。
我有zookeeper
主机连接字符串而不是solr core
url,所以我不能使用这些代码。
如何为我的solrCloud
设置身份验证?
我也对此问题进行了一周的研究。 您可以尝试以下方法:
public HttpClient httpClient() {
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("solr username", "solr password");
provider.setCredentials(AuthScope.ANY, credentials);
return HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
}
public CloudSolrClient solrClient(HttpClient httpClient) {
CloudSolrClient solrClient = new CloudSolrClient.Builder()
.withZkHost("your zkHost").withHttpClient(httpClient()).build();
solrClient.setDefaultCollection("your collection");
return solrClient;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.