List of usage examples for org.apache.solr.client.solrj.impl PreemptiveAuth PreemptiveAuth
public PreemptiveAuth(AuthScheme authScheme)
From source file:org.codice.solr.factory.impl.HttpClientBuilder.java
License:Open Source License
public 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)); }/*from www . jav a 2s . c o m*/ if (isConfiguredForBasicAuth()) { httpClientBuilder.setDefaultCredentialsProvider(getCredentialsProvider()); httpClientBuilder.addInterceptorFirst(new PreemptiveAuth(new BasicScheme())); } return httpClientBuilder; }
From source file:org.janusgraph.diskstorage.solr.SolrIndex.java
License:Apache License
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. j ava 2 s. com*/ 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); } }