public void configure(DefaultHttpClient httpClient, SolrParams config) { super.configure(httpClient, config); logger.info("Setting up SPNego auth..."); //Enable only SPNEGO authentication scheme. final AuthSchemeRegistry registry = new AuthSchemeRegistry(); registry.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false)); httpClient.setAuthSchemes(registry); // Get the credentials from the JAAS configuration rather than here final Credentials useJaasCreds = new Credentials() { public String getPassword() { return null; } public Principal getUserPrincipal() { return null; } }; final SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory(); httpClient.getCookieSpecs().register(cookieFactory.POLICY_NAME, cookieFactory); httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, cookieFactory.POLICY_NAME); httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, useJaasCreds); httpClient.addRequestInterceptor(bufferedEntityInterceptor); }
/** * Configures {@link DefaultHttpClient}, only sets parameters if they are * present in config. */ public static void configureClient(final DefaultHttpClient httpClient, SolrParams config) { configurer.configure(httpClient, config); synchronized(interceptors) { for(HttpRequestInterceptor interceptor: interceptors) { httpClient.addRequestInterceptor(interceptor); } } }
public void configure(DefaultHttpClient httpClient, SolrParams config) { super.configure(httpClient, config);
public void configure(DefaultHttpClient httpClient, SolrParams config) { super.configure(httpClient, config); logger.info("Setting up SPNego auth..."); //Enable only SPNEGO authentication scheme. final AuthSchemeRegistry registry = new AuthSchemeRegistry(); registry.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false)); httpClient.setAuthSchemes(registry); // Get the credentials from the JAAS configuration rather than here final Credentials useJaasCreds = new Credentials() { public String getPassword() { return null; } public Principal getUserPrincipal() { return null; } }; final SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory(); httpClient.getCookieSpecs().register(cookieFactory.POLICY_NAME, cookieFactory); httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, cookieFactory.POLICY_NAME); httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, useJaasCreds); httpClient.addRequestInterceptor(bufferedEntityInterceptor); }