[英]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.