use of org.apache.solr.client.solrj.impl.PreemptiveAuth in project ddf by codice.
the class HttpClientBuilder method get.
@Override
public final org.apache.http.impl.client.HttpClientBuilder get() {
final org.apache.http.impl.client.HttpClientBuilder httpClientBuilder = HttpClients.custom().setDefaultCookieStore(new BasicCookieStore()).setMaxConnTotal(128).setMaxConnPerRoute(32);
if (useTls()) {
String[] defaultProtocols = AccessController.doPrivileged((PrivilegedAction<String[]>) () -> commaSeparatedToArray(System.getProperty(HTTPS_PROTOCOLS)));
String[] defaultCipherSuites = AccessController.doPrivileged((PrivilegedAction<String[]>) () -> commaSeparatedToArray(System.getProperty(HTTPS_CIPHER_SUITES)));
httpClientBuilder.setSSLSocketFactory(new SSLConnectionSocketFactory(getSslContext(), defaultProtocols, defaultCipherSuites, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER));
}
if (isConfiguredForBasicAuth()) {
httpClientBuilder.setDefaultCredentialsProvider(getCredentialsProvider());
httpClientBuilder.addInterceptorFirst(new PreemptiveAuth(new BasicScheme()));
}
return httpClientBuilder;
}
use of org.apache.solr.client.solrj.impl.PreemptiveAuth in project janusgraph by JanusGraph.
the class SolrIndex method configureSolrClientsForKerberos.
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.");
}
logger.debug("Using kerberos configuration file located at '{}'.", kerberosConfig);
try (Krb5HttpClientBuilder krbBuild = new Krb5HttpClientBuilder()) {
SolrHttpClientBuilder kb = krbBuild.getBuilder();
HttpClientUtil.setHttpClientBuilder(kb);
HttpRequestInterceptor bufferedEntityInterceptor = (request, context) -> {
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);
}
}
Aggregations