【问题标题】:What is the correct way of using ntlm authentication with RESTClient?将 ntlm 身份验证与 RESTClient 一起使用的正确方法是什么?
【发布时间】:2014-11-21 04:32:02
【问题描述】:

以下代码工作正常,但 AuthPNamesAuthPolicy 被标记为已弃用,我找不到任何关于替换它的内容。

import groovyx.net.http.RESTClient

def restClient = new RESTClient(config.server)

restClient.client.credentialsProvider.setCredentials(
   AuthScope.ANY, 
   new NTCredentials(
      config.authUsername, 
      config.authPassword, 
      config.authWorkstation, 
      config.authDomain)
)
restClient.client.params.setParameter(
   AuthPNames.TARGET_AUTH_PREF, 
   [AuthPolicy.NTLM]
)

【问题讨论】:

    标签: groovy httpbuilder


    【解决方案1】:

    您可以在文档中找到它:

    【讨论】:

    • @AndrewSummer,这就是你要找的吗?
    • 是的,但是...我无法从文档中弄清楚应该如何使用 RequestConfig 和 AuthSchemeProvider。
    • @AndrewSumner,我不知道你为什么不接受这个答案。您问的是 what 类可以替换为 not how。答案是:现在不可能。正如您在这里看到的search.maven.org/…,在http-builder 4.2.1 中使用了httpcomponents 版本,而我提到的类在4.3.6 中进行了介绍。您需要用新版本替换旧库(不知道是否可能 - 请注意依赖项)或等到新版本的库将在 http-builder 中使用。
    • 太棒了,这就是我想要的答案 - 现在还不能完成。
    【解决方案2】:

    你可以试试下面的代码,它对我有用。

    import groovyx.net.http.RESTClient
    
    def restClient = new RESTClient(config.server)
    
    restClient.auth.ntlm config.authUsername, config.authPassword, config.authWorkstation, config.authDomain
    

    【讨论】:

      猜你喜欢
      • 2021-07-04
      • 2015-01-25
      • 2012-09-20
      • 2019-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-30
      相关资源
      最近更新 更多