title: WinRM(WsMan) and NTLM authentication
body: <p>I'm trying to use NTLM authentication during WsMan connection. But the problem that WinRm doesn't support NTLM scheme directly.
  Here is response headers:</p>
  
  <pre><code>21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "HTTP/1.1 401 [\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "Server: Microsoft-HTTPAPI/2.0[\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "WWW-Authenticate: Negotiate[\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "WWW-Authenticate: Kerberos[\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "WWW-Authenticate: CredSSP[\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "Date: Thu, 10 Aug 2017 18:57:33 GMT[\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "Connection: close[\r][\n]"
  21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 &lt;&lt; "Content-Length: 0[\r][\n]"
  </code></pre>
  
  <p>NTLM scheme is not mentioned in official documentation 
  <a href="https://docs.microsoft.com/en-us/powershell/module/Microsoft.WsMan.Management/Get-WSManInstance?view=powershell-5.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/powershell/module/Microsoft.WsMan.Management/Get-WSManInstance?view=powershell-5.1</a></p>
  
  <p>But it says </p>
  
  <blockquote>
    <p>Negotiate. Negotiate is a challenge-response scheme that negotiates
    with the server or proxy to determine the scheme to use for
    authentication. For example, this parameter value allows for
    negotiation to determine whether the Kerberos protocol or NTLM is
    used.</p>
  </blockquote>
  
  <p>I'm trying to use SPNEGO schema</p>
  
  <pre><code>RegistryBuilder&lt;AuthSchemeProvider&gt; builder = RegistryBuilder.&lt;AuthSchemeProvider&gt;create().register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory());
  </code></pre>
  
  <p>But at the end, it fails <a href="https://pastebin.com/gGNEHGpx" rel="nofollow noreferrer">https://pastebin.com/gGNEHGpx</a>
  So it looks like NTLM is sub-mechanism of SPNEGO, but how to use it correctly with Apache http-client?</p>