2014-11-21 71 views
2

以下代碼正常工作,但AuthPNamesAuthPolicy被標記爲折舊,我找不到要替換的東西。RESTClient使用ntlm身份驗證的正確方法是什麼?

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] 
) 

回答

-1

您可以在文檔中找到它:

+0

@ArewrewSummer,你在找什麼? – Opal 2014-11-23 11:18:37

+0

是的,但是......我無法從文檔中找出如何使用RequestConfig和AuthSchemeProvider。 – 2014-11-24 21:44:36

+0

@AndrewSumner,我不知道你爲什麼不接受答案。你在問*哪些類可以被替換而不是*如何*。答案是:現在不可能。正如你可以在這裏看到http://search.maven.org/#artifactdetails%7Corg.codehaus.groovy.modules.http-builder%7Chttp-builder%7C0.7.1%7Cjar,在http-builder的'4.2.1'版本使用了httpcomponents,我提到的類是在'4.3.6'中引入的。您需要用新版本替換舊版本庫(如果可能,不知道 - 請注意依賴關係),或者等到http-builder中將使用新版本的庫。 – Opal 2014-11-25 07:28:29

0

您可以嘗試下面的代碼,它爲我工作。

import groovyx.net.http.RESTClient 

def restClient = new RESTClient(config.server) 

restClient.auth.ntlm config.authUsername, config.authPassword, config.authWorkstation, config.authDomain