[
https://issues.apache.org/jira/browse/SOLR-10530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15977947#comment-15977947
]
wangyongxin edited comment on SOLR-10530 at 4/21/17 2:34 AM:
-------------------------------------------------------------
thanks for your comment , is there any demo code for me ? and my solr cloud
instance create by these codes :
CloudSolrClient cloudSolrClient = new
CloudSolrClient.Builder().withZkHost(zkHostString).build();
cloudSolrClient.setParser(new XMLResponseParser());
cloudSolrClient.setDefaultCollection(news_collection);
and I haven't found the class
org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory
in solr-solrj-6.4.2.jar or solr-solrj-6.5.0.jar
and I haven't use SSL
was (Author: wangyongxin):
thanks for your comment , is there any demo code for me ? and my solr cloud
instance create by these codes :
CloudSolrClient cloudSolrClient = new
CloudSolrClient.Builder().withZkHost(zkHostString).build();
cloudSolrClient.setParser(new XMLResponseParser());
cloudSolrClient.setDefaultCollection(news_collection);
and I haven't found the class
org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory
in solr-solrj-6.4.2.jar or solr-solrj-6.5.0.jar
and I don't use SSL
> Basic Authentication Plugin blockUnknown HTTP ERROR 401 require authentication
> ------------------------------------------------------------------------------
>
> Key: SOLR-10530
> URL: https://issues.apache.org/jira/browse/SOLR-10530
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Affects Versions: 6.4.2
> Environment: linux and mac os
> Reporter: wangyongxin
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> when solr cloud use Basic Authentication Plugin, and set blockUnknown = true,
> set username and password in security.json and solr.in.sh, and my solr
> version is 6.4.2, and i created a collection named "news", changed
> managed-schema and solrconfig.xml in zookeeper cloud, and add a jar named
> ik-analyzer.jar into solr webapp lib directory, restart solr clouds,
> everything seems ok, and I use my java web project connected to zookeepers,
> use codes method like :
> public static QueryResponse getResponseWithAuth(CloudSolrClient solr,
> SolrQuery query) throws SolrServerException, IOException {
> QueryRequest req = new QueryRequest(query);
> req.setBasicAuthCredentials(username, password);
> return req.process(solr);
> }
> search in solr with base authentication is working right ! but when I trying
> to delete or update documents with solr like this:
> public static UpdateResponse deleteWithAuth(CloudSolrClient solr, String id)
> throws SolrServerException, IOException {
> UpdateRequest updateRequest = new UpdateRequest();
> updateRequest.setBasicAuthCredentials(username, password);
> updateRequest.setAction(UpdateRequest.ACTION.COMMIT, false, false);
> updateRequest.deleteById(id);
> return updateRequest.process(solr);
> }
> or update method :
> public static UpdateResponse addWithAuth(CloudSolrClient solr,
> SolrInputDocument doc) throws SolrServerException, IOException {
> UpdateRequest updateRequest = new UpdateRequest();
> updateRequest.setBasicAuthCredentials(username, password);
> updateRequest.setAction(UpdateRequest.ACTION.OPTIMIZE, false, false);
> updateRequest.add(doc);
> return updateRequest.process(solr);
> }
> it returns error like this :
> 22:07:54.335 [http-bio-8031-exec-1] ERROR o.a.s.c.s.i.CloudSolrClient -
> Request to collection news failed due to (401)
> org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error
> from server at http://192.168.10.250:8983/solr/news: Expected mime type
> application/xml but got text/html. <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
> <title>Error 401 require authentication</title>
> </head>
> <body><h2>HTTP ERROR 401</h2>
> <p>Problem accessing /solr/news/select. Reason:
> <pre> require authentication</pre></p>
> </body>
> </html>
> , retry? 0
> please help me find out where I am wrong ! thanks
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]