org.apache.solr.client.solrj.impl.SolrHttpClientBuilder Java Examples
The following examples show how to use
org.apache.solr.client.solrj.impl.SolrHttpClientBuilder.
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: TestAuthenticationFramework.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder httpClientBuilder) { interceptor = (req, rsp) -> { req.addHeader("username", requestUsername); req.addHeader("password", requestPassword); }; HttpClientUtil.addRequestInterceptor(interceptor); return httpClientBuilder; }
Example #3
Source File: KerberosHttpClientBuilder.java From nifi with Apache License 2.0 | 5 votes |
public SolrHttpClientBuilder getBuilder(SolrHttpClientBuilder builder) { //Enable only SPNEGO authentication scheme. builder.setAuthSchemeRegistryProvider(() -> { Lookup<AuthSchemeProvider> authProviders = RegistryBuilder.<AuthSchemeProvider>create() .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false)) .build(); return authProviders; }); // Get the credentials from the JAAS configuration rather than here Credentials useJaasCreds = new Credentials() { public String getPassword() { return null; } public Principal getUserPrincipal() { return null; } }; HttpClientUtil.setCookiePolicy(SolrPortAwareCookieSpecFactory.POLICY_NAME); builder.setCookieSpecRegistryProvider(() -> { SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory(); Lookup<CookieSpecProvider> cookieRegistry = RegistryBuilder.<CookieSpecProvider> create() .register(SolrPortAwareCookieSpecFactory.POLICY_NAME, cookieFactory).build(); return cookieRegistry; }); builder.setDefaultCredentialsProvider(() -> { CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, useJaasCreds); return credentialsProvider; }); HttpClientUtil.addRequestInterceptor(bufferedEntityInterceptor); return builder; }
Example #4
Source File: PKIAuthenticationPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder builder) { HttpClientUtil.addRequestInterceptor(interceptor); interceptorRegistered = true; return builder; }
Example #5
Source File: KerberosPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder builder) { return kerberosBuilder.getBuilder(builder); }
Example #6
Source File: ConfigurableInternodeAuthHadoopPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder builder) { return factory.getHttpClientBuilder(Optional.ofNullable(builder)); }
Example #7
Source File: HttpParamDelegationTokenPlugin.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder builder) { HttpClientUtil.addRequestInterceptor(interceptor); builder = super.getHttpClientBuilder(builder); return builder; }
Example #8
Source File: SdcSolrHttpClientBuilder.java From datacollector with Apache License 2.0 | 4 votes |
static SolrHttpClientBuilder create() { SolrHttpClientBuilder solrHttpClientBuilder = SolrHttpClientBuilder.create(); final String useSubjectCredentialsProperty = USE_SUBJECT_CREDENTIALS_PROPERTY; String useSubjectCredentialsValue = System.getProperty(useSubjectCredentialsProperty); if (useSubjectCredentialsValue == null) { System.setProperty(useSubjectCredentialsProperty, FALSE); } else if (!useSubjectCredentialsValue.toLowerCase(Locale.ROOT).equals(FALSE)) { LOG.warn(String.format( "System Property: %s set to: %s not false. SPNego authentication may not be successful.", useSubjectCredentialsProperty, useSubjectCredentialsValue )); } solrHttpClientBuilder.setAuthSchemeRegistryProvider(() -> RegistryBuilder.<AuthSchemeProvider>create().register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true) ).build()); SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory(); solrHttpClientBuilder.setCookieSpecRegistryProvider(() -> RegistryBuilder.<CookieSpecProvider>create().register(SolrPortAwareCookieSpecFactory.POLICY_NAME, cookieFactory ).build()); Credentials jassCredentials = new Credentials() { public String getPassword() { return null; } public Principal getUserPrincipal() { return null; } }; CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, jassCredentials); solrHttpClientBuilder.setDefaultCredentialsProvider(() -> credentialsProvider); return solrHttpClientBuilder; }
Example #9
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); }
Example #10
Source File: KerberosHttpClientBuilder.java From nifi with Apache License 2.0 | 4 votes |
public SolrHttpClientBuilder getBuilder() { return getBuilder(HttpClientUtil.getHttpClientBuilder()); }
Example #11
Source File: KerberosHttpClientBuilder.java From nifi with Apache License 2.0 | 4 votes |
@Override public SolrHttpClientBuilder getHttpClientBuilder(Optional<SolrHttpClientBuilder> builder) { return builder.isPresent() ? getBuilder(builder.get()) : getBuilder(); }
Example #12
Source File: HttpClientBuilderPlugin.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * * @return Returns an instance of a SolrHttpClientBuilder to be used for configuring the * HttpClients for use with SolrJ clients. * * @lucene.experimental */ public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder builder);