2

The follow code works fine but AuthPNames and AuthPolicy are marked as depreciated and I cannot find anything on what to replace it with.

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]
)
Opal
  • 81,889
  • 28
  • 189
  • 210
Andrew Sumner
  • 793
  • 2
  • 12
  • 29

2 Answers2

0

You can find it in the docs:

Opal
  • 81,889
  • 28
  • 189
  • 210
  • @AndrewSummer, is that what You're looking for? – Opal Nov 23 '14 at 11:18
  • Yes, but... I cannot figure out from the documentation how RequestConfig and AuthSchemeProvider should be used. – Andrew Sumner Nov 24 '14 at 21:44
  • @AndrewSumner, I don't know why You unaccepted the answer. You were asking for *what* the classes can be replaced with not *how*. The answer is: it's not possible now. As You can see here http://search.maven.org/#artifactdetails%7Corg.codehaus.groovy.modules.http-builder%7Chttp-builder%7C0.7.1%7Cjar, in http-builder `4.2.1` version of httpcomponents is used, and the classes I mentioned were introduced in `4.3.6`. You need to substitute old library with newer version (no idea if possible - mind the dependencies) or wait till new version of library will be used in http-builder. – Opal Nov 25 '14 at 07:28
  • Great, that was the answer I was after - it can't be done yet. – Andrew Sumner Nov 26 '14 at 20:54
0

You can try following code, it worked for me.

import groovyx.net.http.RESTClient

def restClient = new RESTClient(config.server)

restClient.auth.ntlm config.authUsername, config.authPassword, config.authWorkstation, config.authDomain
Nic Olas
  • 451
  • 2
  • 10