org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder Java Examples
The following examples show how to use
org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Solr6Index.java From atlas with Apache License 2.0 | 6 votes |
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 = 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); } }
Example #2
Source File: Solr6Index.java From atlas with Apache License 2.0 | 5 votes |
public Solr6Index(final Configuration config) throws BackendException { // Add Kerberos-enabled SolrHttpClientBuilder HttpClientUtil.setHttpClientBuilder(new Krb5HttpClientBuilder().getBuilder()); Preconditions.checkArgument(config!=null); configuration = config; mode = Mode.parse(config.get(SOLR_MODE)); kerberosEnabled = config.get(KERBEROS_ENABLED); dynFields = config.get(DYNAMIC_FIELDS); keyFieldIds = parseKeyFieldsForCollections(config); batchSize = config.get(INDEX_MAX_RESULT_SET_SIZE); ttlField = config.get(TTL_FIELD); waitSearcher = config.get(WAIT_SEARCHER); if (kerberosEnabled) { logger.debug("Kerberos is enabled. Configuring SOLR for Kerberos."); configureSolrClientsForKerberos(); } else { logger.debug("Kerberos is NOT enabled."); logger.debug("KERBEROS_ENABLED name is " + KERBEROS_ENABLED.getName() + " and it is" + (KERBEROS_ENABLED.isOption() ? " " : " not") + " an option."); logger.debug("KERBEROS_ENABLED type is " + KERBEROS_ENABLED.getType().name()); } solrClient = createSolrClient(); createSolrClientPerRequest = config.get(CREATE_SOLR_CLIENT_PER_REQUEST); if(createSolrClientPerRequest) { logger.info("A new Solr Client will be created for direct interation with SOLR."); } else { logger.info("Solr Client will be shared for direct interation with SOLR."); } Solr6Index.instance = this; }
Example #3
Source File: KerberosTestServices.java From lucene-solr with Apache License 2.0 | 5 votes |
public void start() throws Exception { if (brokenLanguagesWithMiniKdc.contains(Locale.getDefault().getLanguage())) { Locale.setDefault(Locale.US); } // There is time lag between selecting a port and trying to bind with it. It's possible that // another service captures the port in between which'll result in BindException. boolean bindException; int numTries = 0; do { try { bindException = false; kdc = getKdc(workDir); kdc.start(); } catch (BindException e) { FileUtils.deleteDirectory(workDir); // clean directory numTries++; if (numTries == 3) { log.error("Failed setting up MiniKDC. Tried {} times.", numTries); throw e; } log.error("BindException encountered when setting up MiniKdc. Trying again."); bindException = true; } } while (bindException); Configuration.setConfiguration(jaasConfiguration); Krb5HttpClientBuilder.regenerateJaasConfiguration(); }
Example #4
Source File: KerberosTestServices.java From lucene-solr with Apache License 2.0 | 4 votes |
public void stop() { if (kdc != null) kdc.stop(); Configuration.setConfiguration(savedConfig); Krb5HttpClientBuilder.regenerateJaasConfiguration(); Locale.setDefault(savedLocale); }
Example #5
Source File: SolrCollectionBootstrapper.java From ranger with Apache License 2.0 | 4 votes |
private void setHttpClientBuilderForKrb() { Krb5HttpClientBuilder krbBuild = new Krb5HttpClientBuilder(); SolrHttpClientBuilder kb = krbBuild.getBuilder(); HttpClientUtil.setHttpClientBuilder(kb); }