<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Java Code example to connect to SOLR using Kerberos and SASL in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/65419#M74559</link>
    <description>&lt;P&gt;I got this to work as follows (but there's a twist when dealing with Eclipse from Windows):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.setProperty("javax.net.ssl.trustStorePassword","xxxxxx");&lt;BR /&gt;System.setProperty("java.security.auth.login.config", "C:\\my_jaas.conf");&lt;BR /&gt;String zkHosts = "zookeeper1.com:2181,zookeeper2.ghp.com:2181,zookeeper3.ghp.com:2181/solr";&lt;/P&gt;&lt;P&gt;Krb5HttpClientBuilder krbBuild = new Krb5HttpClientBuilder();&lt;BR /&gt;SolrHttpClientBuilder kb = krbBuild.getBuilder();&lt;BR /&gt;HttpClientUtil.setHttpClientBuilder(kb);&lt;BR /&gt;CloudSolrClient solrServer = new CloudSolrClient.Builder().withZkHost(zkHosts).build();&lt;/P&gt;&lt;P&gt;String collectionName = "test_col";&lt;BR /&gt;solrServer.setDefaultCollection(collectionName);&lt;BR /&gt;solrServer.connect();&lt;/P&gt;&lt;P&gt;SolrQuery parameters = new SolrQuery();&lt;BR /&gt;parameters.set("q", "*:*");&lt;BR /&gt;try {&lt;BR /&gt;solrServer.commit();&lt;BR /&gt;QueryResponse response = solrServer.query(parameters);&lt;BR /&gt;for (SolrDocument solrDocument : response.getResults()) {&lt;BR /&gt;System.out.println(" " + solrDocument.toString());&lt;BR /&gt;}&lt;BR /&gt;krbBuild.close();&lt;BR /&gt;solrServer.close();&lt;BR /&gt;} catch (SolrServerException | IOException e) {&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are working from a Windows Environment and Windows is generating your TGT Kerberos keys and Kerberos is hooked into AD (that is, not using MIT Kerberos), then you need to update the registry as follows (thanks to Cloudera Systems Engineer Tom Roach):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On windows, to use your kerberos tickets from AD in your&amp;nbsp;&lt;SPAN&gt;Java&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;program&lt;/SPAN&gt;, you need to setup this Windows registry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters&lt;/P&gt;&lt;P&gt;Value Name: AllowTgtSessionKey&lt;/P&gt;&lt;P&gt;Value Type: REG_DWORD&lt;/P&gt;&lt;P&gt;Value: 0x01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;jaas.conf:&lt;/P&gt;&lt;P&gt;Client {&lt;BR /&gt;com.sun.security.auth.module.Krb5LoginModule required&lt;BR /&gt;useKeyTab=false&lt;BR /&gt;useTicketCache=true&lt;BR /&gt;principal="myuser@MYDOMAIN.COM";&lt;BR /&gt;};&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2018 16:02:05 GMT</pubDate>
    <dc:creator>Rebpgh1</dc:creator>
    <dc:date>2018-03-15T16:02:05Z</dc:date>
    <item>
      <title>Java Code example to connect to SOLR using Kerberos and SASL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/64610#M74556</link>
      <description>&lt;P&gt;Does anyone out there have an example of Java code that can connect to a Cloudra SOLR collection (under zookeeper) that uses Kerberos and the correct SASL parameters?&amp;nbsp; &amp;nbsp;Googling brings up some suggestions and some not ready for prime time classes.&amp;nbsp; I'm looking for connection code, not a Morphlines example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp; Rick&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:51:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/64610#M74556</guid>
      <dc:creator>Rebpgh1</dc:creator>
      <dc:date>2022-09-16T12:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Java Code example to connect to SOLR using Kerberos and SASL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/64883#M74557</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you find this info in Cloudera Search documentation - does this help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.cloudera.com/documentation/enterprise/latest/topics/search_using_kerberos.html" target="_blank"&gt;https://www.cloudera.com/documentation/enterprise/latest/topics/search_using_kerberos.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 16:56:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/64883#M74557</guid>
      <dc:creator>nwhite</dc:creator>
      <dc:date>2018-02-23T16:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Java Code example to connect to SOLR using Kerberos and SASL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/64884#M74558</link>
      <description>...and here is a useful blog article:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blog.cloudera.com/blog/2016/10/how-to-secure-apache-solr-collections-and-access-them-programmatically/" target="_blank"&gt;https://blog.cloudera.com/blog/2016/10/how-to-secure-apache-solr-collections-and-access-them-programmatically/&lt;/A&gt;</description>
      <pubDate>Fri, 23 Feb 2018 16:59:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/64884#M74558</guid>
      <dc:creator>nwhite</dc:creator>
      <dc:date>2018-02-23T16:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Java Code example to connect to SOLR using Kerberos and SASL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/65419#M74559</link>
      <description>&lt;P&gt;I got this to work as follows (but there's a twist when dealing with Eclipse from Windows):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.setProperty("javax.net.ssl.trustStorePassword","xxxxxx");&lt;BR /&gt;System.setProperty("java.security.auth.login.config", "C:\\my_jaas.conf");&lt;BR /&gt;String zkHosts = "zookeeper1.com:2181,zookeeper2.ghp.com:2181,zookeeper3.ghp.com:2181/solr";&lt;/P&gt;&lt;P&gt;Krb5HttpClientBuilder krbBuild = new Krb5HttpClientBuilder();&lt;BR /&gt;SolrHttpClientBuilder kb = krbBuild.getBuilder();&lt;BR /&gt;HttpClientUtil.setHttpClientBuilder(kb);&lt;BR /&gt;CloudSolrClient solrServer = new CloudSolrClient.Builder().withZkHost(zkHosts).build();&lt;/P&gt;&lt;P&gt;String collectionName = "test_col";&lt;BR /&gt;solrServer.setDefaultCollection(collectionName);&lt;BR /&gt;solrServer.connect();&lt;/P&gt;&lt;P&gt;SolrQuery parameters = new SolrQuery();&lt;BR /&gt;parameters.set("q", "*:*");&lt;BR /&gt;try {&lt;BR /&gt;solrServer.commit();&lt;BR /&gt;QueryResponse response = solrServer.query(parameters);&lt;BR /&gt;for (SolrDocument solrDocument : response.getResults()) {&lt;BR /&gt;System.out.println(" " + solrDocument.toString());&lt;BR /&gt;}&lt;BR /&gt;krbBuild.close();&lt;BR /&gt;solrServer.close();&lt;BR /&gt;} catch (SolrServerException | IOException e) {&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are working from a Windows Environment and Windows is generating your TGT Kerberos keys and Kerberos is hooked into AD (that is, not using MIT Kerberos), then you need to update the registry as follows (thanks to Cloudera Systems Engineer Tom Roach):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On windows, to use your kerberos tickets from AD in your&amp;nbsp;&lt;SPAN&gt;Java&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;program&lt;/SPAN&gt;, you need to setup this Windows registry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters&lt;/P&gt;&lt;P&gt;Value Name: AllowTgtSessionKey&lt;/P&gt;&lt;P&gt;Value Type: REG_DWORD&lt;/P&gt;&lt;P&gt;Value: 0x01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;jaas.conf:&lt;/P&gt;&lt;P&gt;Client {&lt;BR /&gt;com.sun.security.auth.module.Krb5LoginModule required&lt;BR /&gt;useKeyTab=false&lt;BR /&gt;useTicketCache=true&lt;BR /&gt;principal="myuser@MYDOMAIN.COM";&lt;BR /&gt;};&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 16:02:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Java-Code-example-to-connect-to-SOLR-using-Kerberos-and-SASL/m-p/65419#M74559</guid>
      <dc:creator>Rebpgh1</dc:creator>
      <dc:date>2018-03-15T16:02:05Z</dc:date>
    </item>
  </channel>
</rss>

