@Override protected CookieSpecRegistry createCookieSpecRegistry() { CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register( CookiePolicy.BEST_MATCH, new BestMatchSpecFactory()); registry.register( CookiePolicy.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()); registry.register( CookiePolicy.NETSCAPE, new NetscapeDraftSpecFactory()); registry.register( CookiePolicy.RFC_2109, new RFC2109SpecFactory()); registry.register( CookiePolicy.RFC_2965, new RFC2965SpecFactory()); return registry; }
/** * Gets the {@link CookieSpec cookie specification} with the given name. * * @param name the {@link CookieSpec cookie specification} identifier * * @return {@link CookieSpec cookie specification} * * @throws IllegalStateException if a policy with the given name cannot be found */ public synchronized CookieSpec getCookieSpec(final String name) throws IllegalStateException { return getCookieSpec(name, null); }
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); }
@Override protected DefaultHttpClient createHttpClient(UrlBuilder url, BindingSession session) { // set params HttpParams params = createDefaultHttpParams(session); params.setParameter(ClientPNames.COOKIE_POLICY, IGNORE_COOKIES); // set max connection String maxConnStr = System.getProperty("http.maxConnections", "5"); int maxConn = 5; try { maxConn = Integer.parseInt(maxConnStr); } catch (NumberFormatException nfe) { // ignore } params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, maxConn * 4); params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(maxConn)); // set up scheme registry SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", getSSLSocketFactory(url, session), 443)); // set up connection manager ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(params, registry); // set up proxy ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(registry, null); // set up client DefaultHttpClient httpclient = new DefaultHttpClient(connManager, params); httpclient.setRoutePlanner(routePlanner); httpclient.getCookieSpecs().register(IGNORE_COOKIES, new IgnoreSpecFactory()); return httpclient; }
/** * Creates a http client that sends cookies to every domain, not just the originator * * As we don't actually have a load balancer for the clustering tests, we use this instead. * * @return a http client that gives free cookies to everybody */ public static DefaultHttpClient relaxedCookieHttpClient() { DefaultHttpClient client = new DefaultHttpClient(); final CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register("best-match", new CookieSpecFactory() { @Override public CookieSpec newInstance(final HttpParams params) { return new RelaxedBrowserCompatSpec(); } }); client.setCookieSpecs(registry); return client; }
CookieSpec cookieSpec = registry.getCookieSpec(policy, request.getParams());
client.getCookieSpecs().register("bestmatchwithurl", csf); client.getParams().setParameter(ClientPNames.COOKIE_POLICY, "bestmatchwithurl");
@Override protected CookieSpecRegistry createCookieSpecRegistry() { CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register( CookiePolicy.BEST_MATCH, new BestMatchSpecFactory()); registry.register( CookiePolicy.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()); registry.register( CookiePolicy.NETSCAPE, new NetscapeDraftSpecFactory()); registry.register( CookiePolicy.RFC_2109, new RFC2109SpecFactory()); registry.register( CookiePolicy.RFC_2965, new RFC2965SpecFactory()); return registry; }
/** * Gets the {@link CookieSpec cookie specification} with the given name. * * @param name the {@link CookieSpec cookie specification} identifier * * @return {@link CookieSpec cookie specification} * * @throws IllegalStateException if a policy with the given name cannot be found */ public CookieSpec getCookieSpec(final String name) throws IllegalStateException { return getCookieSpec(name, null); }
client.getCookieSpecs().register("bestmatchwithurl", csf); client.getParams().setParameter(ClientPNames.COOKIE_POLICY, "bestmatchwithurl");
@Override protected CookieSpecRegistry createCookieSpecRegistry() { CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register( CookiePolicy.BEST_MATCH, new BestMatchSpecFactory()); registry.register( CookiePolicy.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()); registry.register( CookiePolicy.NETSCAPE, new NetscapeDraftSpecFactory()); registry.register( CookiePolicy.RFC_2109, new RFC2109SpecFactory()); registry.register( CookiePolicy.RFC_2965, new RFC2965SpecFactory()); return registry; }
/** * Gets the {@link CookieSpec cookie specification} with the given name. * * @param name the {@link CookieSpec cookie specification} identifier * * @return {@link CookieSpec cookie specification} * * @throws IllegalStateException if a policy with the given name cannot be found */ public synchronized CookieSpec getCookieSpec(final String name) throws IllegalStateException { return getCookieSpec(name, null); }
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); }
@Override protected CookieSpecRegistry createCookieSpecRegistry() { CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register( CookiePolicy.BEST_MATCH, new BestMatchSpecFactory()); registry.register( CookiePolicy.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()); registry.register( CookiePolicy.NETSCAPE, new NetscapeDraftSpecFactory()); registry.register( CookiePolicy.RFC_2109, new RFC2109SpecFactory()); registry.register( CookiePolicy.RFC_2965, new RFC2965SpecFactory()); return registry; }
/** * Gets the {@link CookieSpec cookie specification} with the given name. * * @param name the {@link CookieSpec cookie specification} identifier * * @return {@link CookieSpec cookie specification} * * @throws IllegalStateException if a policy with the given name cannot be found */ public CookieSpec getCookieSpec(final String name) throws IllegalStateException { return getCookieSpec(name, null); }
private <T> T executeRequest(final HttpRequestBase httpRequest, final HttpClientRequest<T> httpClientRequest) throws IOException { final DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, setFollowRedirects(params, httpClientRequest)); httpClient.getCookieSpecs().register(NessCookieSpecFactory.NESS_COOKIE_POLICY, new NessCookieSpecFactory()); httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(retries, false));
@Override protected CookieSpecRegistry createCookieSpecRegistry() { CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register( CookiePolicy.BEST_MATCH, new BestMatchSpecFactory()); registry.register( CookiePolicy.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()); registry.register( CookiePolicy.NETSCAPE, new NetscapeDraftSpecFactory()); registry.register( CookiePolicy.RFC_2109, new RFC2109SpecFactory()); registry.register( CookiePolicy.RFC_2965, new RFC2965SpecFactory()); return registry; }
/** * Gets the {@link CookieSpec cookie specification} with the given name. * * @param name the {@link CookieSpec cookie specification} identifier * * @return {@link CookieSpec cookie specification} * * @throws IllegalStateException if a policy with the given name cannot be found */ public CookieSpec getCookieSpec(final String name) throws IllegalStateException { return getCookieSpec(name, null); }
protected CookieSpecRegistry createCookieSpecRegistry() { final CookieSpecRegistry registry = new CookieSpecRegistry(); registry.register( CookiePolicy.BEST_MATCH, new BestMatchSpecFactory()); registry.register( CookiePolicy.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()); registry.register( CookiePolicy.NETSCAPE, new NetscapeDraftSpecFactory()); registry.register( CookiePolicy.RFC_2109, new RFC2109SpecFactory()); registry.register( CookiePolicy.RFC_2965, new RFC2965SpecFactory()); registry.register( CookiePolicy.IGNORE_COOKIES, new IgnoreSpecFactory()); return registry; }
/** * Gets the {@link CookieSpec cookie specification} with the given name. * * @param name the {@link CookieSpec cookie specification} identifier * * @return {@link CookieSpec cookie specification} * * @throws IllegalStateException if a policy with the given name cannot be found */ public CookieSpec getCookieSpec(final String name) throws IllegalStateException { return getCookieSpec(name, null); }