【问题标题】:TargetAuthenticationStrategy, change order of preferenceTargetAuthenticationStrategy,更改偏好顺序
【发布时间】:2013-12-19 15:31:49
【问题描述】:

Apache 4.3.x 按优先顺序记录以下身份验证方案:

[negotiate, Kerberos, NTLM, Digest, Basic]

如何更改此订单?

我尝试了以下方法:

 DefaultHttpClient httpclient = new DefaultHttpClient(ccm, params);
 // Choose BASIC over DIGEST for proxy authentication
 List<String> authpref = new ArrayList<String>();
 authpref.add(AuthPolicy.BASIC);
 authpref.add(AuthPolicy.DIGEST);
 httpclient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);

但这在 4.3.X 中已被弃用,所以也许更好的问题是如何在 4.3.x 中执行上述操作?

【问题讨论】:

    标签: java apache authentication apache-httpclient-4.x


    【解决方案1】:

    应该差不多

    RequestConfig config = RequestConfig.custom()
            .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC, AuthSchemes.DIGEST))
            .build();
    CloseableHttpClient httpClient = HttpClients.custom()
            .setDefaultRequestConfig(config)
            .build();
    

    【讨论】:

      猜你喜欢
      • 2022-01-25
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      相关资源
      最近更新 更多