Skip to content

Commit

Permalink
[solr,solr6] Add support for Kerberized Solr (brianfrankcooper#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
risdenk authored and busbey committed Jan 11, 2017
1 parent a37bc78 commit 8b0548a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions solr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ LICENSE file.
<artifactId>solr-solrj</artifactId>
<version>${solr.version}</version>
</dependency>
<!-- commons-codec required for Solr Kerberos support -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions solr/src/main/java/com/yahoo/ycsb/db/solr/SolrClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.client.solrj.SolrServerException;
Expand Down Expand Up @@ -71,6 +73,13 @@ public void init() throws DBException {
.parseInt(props.getProperty("solr.commit.within.time", DEFAULT_COMMIT_WITHIN_TIME));
batchMode = Boolean.parseBoolean(props.getProperty("solr.batch.mode", DEFAULT_BATCH_MODE));


String jaasConfPath = props.getProperty("solr.jaas.conf.path");
if(jaasConfPath != null) {
System.setProperty("java.security.auth.login.config", jaasConfPath);
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
}

// Check if Solr cluster is running in SolrCloud or Stand-alone mode
Boolean cloudMode = Boolean.parseBoolean(props.getProperty("solr.cloud", DEFAULT_CLOUD_MODE));
System.err.println("Solr Cloud Mode = " + cloudMode);
Expand Down
6 changes: 6 additions & 0 deletions solr6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ LICENSE file.
<artifactId>solr-solrj</artifactId>
<version>${solr6.version}</version>
</dependency>
<!-- commons-codec required for Solr Kerberos support -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
Expand Down
8 changes: 8 additions & 0 deletions solr6/src/main/java/com/yahoo/ycsb/db/solr6/SolrClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.client.solrj.SolrServerException;
Expand Down Expand Up @@ -71,6 +73,12 @@ public void init() throws DBException {
.parseInt(props.getProperty("solr.commit.within.time", DEFAULT_COMMIT_WITHIN_TIME));
batchMode = Boolean.parseBoolean(props.getProperty("solr.batch.mode", DEFAULT_BATCH_MODE));

String jaasConfPath = props.getProperty("solr.jaas.conf.path");
if(jaasConfPath != null) {
System.setProperty("java.security.auth.login.config", jaasConfPath);
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
}

// Check if Solr cluster is running in SolrCloud or Stand-alone mode
Boolean cloudMode = Boolean.parseBoolean(props.getProperty("solr.cloud", DEFAULT_CLOUD_MODE));
System.err.println("Solr Cloud Mode = " + cloudMode);
Expand Down

0 comments on commit 8b0548a

Please sign in to comment.