Hello All,
Can someone provide an example to connect Kerberos solr using solrj9.61
which uses Http2SolrClient and CloudHttp2SolrClient (when solr cloud
enabled).
Just setting up below properties not working
System.setProperty("java.security.krb5.conf", "/path/to/krb5.conf");
System.setProperty("java.security.auth.login.config", "/path/to/jaas.conf");
System.setProperty("solr.kerberos.jaas.appname", "Client");
Earlier with solrj8.7 where I used HttpClient, I was additionally
performing below steps and so it was working fine.But its not working for
solr9 and uses Http2SolrClient .
private void configureSolrClientsForKerberos() throws
PermanentBackendException {
String kerberosConfig =
System.getProperty("java.security.auth.login.config");
if (kerberosConfig == null) {
throw new PermanentBackendException(
"Unable to configure kerberos for solr client. System
property 'java.security.auth.login.config' is not set.");
}/*from w w w .jav a2 s. c o m*/
logger.debug("Using kerberos configuration file located at '{}'.",
kerberosConfig); try (Krb5HttpClientBuilder krbBuild = new
Krb5HttpClientBuilder()) {
SolrHttpClientBuilder kb = krbBuild.getBuilder();
HttpClientUtil.setHttpClientBuilder(kb);
HttpRequestInterceptor bufferedEntityInterceptor = new
HttpRequestInterceptor() {
@Override
public void process(HttpRequest request, HttpContext
context) throws HttpException, IOException {
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntityEnclosingRequest enclosingRequest =
((HttpEntityEnclosingRequest) request);
HttpEntity requestEntity = enclosingRequest.getEntity();
enclosingRequest.setEntity(new
BufferedHttpEntity(requestEntity));
}
}
};
HttpClientUtil.addRequestInterceptor(bufferedEntityInterceptor);
HttpRequestInterceptor preemptiveAuth = new PreemptiveAuth(new
KerberosScheme());
HttpClientUtil.addRequestInterceptor(preemptiveAuth);
}
}
--
*Thanks&Regards*
*Prasad Bezavada*