简体   繁体   English

配置org.apache.http.impl.client.DefaultHttpClient使用默认的Authenticator

[英]Configuring org.apache.http.impl.client.DefaultHttpClient to use the default Authenticator

I am attempting to use DefaultHttpClient over a proxy with basic authentication. 我正在尝试通过具有基本身份验证的代理使用DefaultHttpClient。 Setting the client to use the default ProxySelector is (sort of) straight forward: 将客户端设置为使用默认的ProxySelector是(很简单)的:

DefaultHttpClient client = new DefaultHttpClient();
client.setRoutePlanner(new ProxySelectorRoutePlanner(
    client.getConnectionManager().getSchemeRegistry(),
    null));

However, this doesn't configure the client to use the default Authenticator. 但是,这不会将客户端配置为使用默认的Authenticator。 Is there a way to do this, or am I forced to setup the authentication explicitly? 有没有办法做到这一点,还是我被迫明确设置身份验证?

您可以实现一个自定义CredentialsProvider ,它将用户凭据的解析委派给默认的Authenticator。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何告诉org.apache.http.impl.client.DefaultHttpClient使用OWASP Zed攻击代理(ZAP) - How do I tell org.apache.http.impl.client.DefaultHttpClient to use the OWASP Zed Attack Proxy (ZAP) 具有PHP,MySQL的Android登录注册系统,错误为“ java.lang.NoSuchMethodError:org.apache.http.impl.client.DefaultHttpClient.execute” - Android Login Registration System with PHP, MySQL with error 'java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute' org.apache.http.impl.client.CloseableHttpClient代理验证 - org.apache.http.impl.client.CloseableHttpClient Proxy Authentication org.apache.http.client-4.3.6:java.lang.NoClassDefFoundError:org.apache.http.impl.conn.PoolingHttpClientConnectionManager - org.apache.http.client-4.3.6: java.lang.NoClassDefFoundError: org.apache.http.impl.conn.PoolingHttpClientConnectionManager 当org.apache.http.impl.client.CloseableHttpClient返回404 / NOT_FOUND时,wget返回200 / OK - wget returns 200/OK while org.apache.http.impl.client.CloseableHttpClient returns 404/NOT_FOUND org.apache.http.impl.client.DefaultRequestDirector方法executeSB(Galaxy S5) - org.apache.http.impl.client.DefaultRequestDirector method executeSB (Galaxy S5) Android Studio:Unirest-Java找不到类“ org.apache.http.impl.client.CloseableHttpClient” - Android Studio: Unirest-Java Could not find class 'org.apache.http.impl.client.CloseableHttpClient' 使用org.apache.http.impl.client.ProxyClient通过代理隧道访问HTTPS Web服务 - Accessing HTTPS web services through proxy tunnel using org.apache.http.impl.client.ProxyClient java.lang.ClassNotFoundException:org.apache.http.impl.client.cache.CacheConfig - java.lang.ClassNotFoundException: org.apache.http.impl.client.cache.CacheConfig 动态配置Apache Http客户端 - Dynamically configuring Apache Http client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM