title: authenticate with ntlm (or kerberos) using java UrlConnection
body: <p>I need to consume a rest web service with java, passing the credentials of a domain user account.</p>
  
  <p>right now I'm doing it with classic asp</p>
  
  <pre><code>
  set xmlHttp = server.createObject( "msxml2.serverxmlhttp" )
  xmlHttp.open method, url, false, domain & "\" & user, password
  xmlHttp.send body
  out = xmlHttp.responseText
  set xmlHttp = nothing
  </code></pre>
  
  <p>and with asp.net</p>
  
  <pre><code>
  
  HttpWebRequest request = (HttpWebRequest) WebRequest.Create( url );
  
  request.Credentials = new NetworkCredential(user, password, domain);
  
  request.Method = WebRequestMethods.Http.Get
  
  HttpWebResponse response = (HttpWebResponse) request.GetResponse();
  
  StreamReader outStream = new StreamReader( response.GetResponseStream(), Encoding.UTF8) ;
  
  output = outStream.ReadToEnd();
  
  </code></pre>
  
  <p>how can I achieve this with java? Take into account that I'm not using the credentials of the currently logged user, I'm specifing the domain account (I have the password)</p>
  
  <p>please tell me it's as easy as with classic asp and asp.net....</p>