authentication - authenticate with ntlm (or kerberos) using java UrlConnection -


I need to consume a relaxing web service with Java, passing the domain user's account credentials.

I just used classic ASP

  set xmlHttp = server.createObject ("msxml2.serverxmlhttp") xmlHttp.open method, url, false, domain and "\" and user I'm doing this with the password xmlHttp.send body = xmlHttp.responseText set xmlHttp = nothing  

and with ASP.NET

  HttpWebRequest request = (HttpWebRequest) WebRequest.Create (URL); request. Credential = new network credentials (user, password, domain); Request.Method = WebRequestMethods.Http.Get HttpWebResponse response = (HttpWebResponse) request.GetResponse (); Streamer Outstream = New Streamerder (Response Gaterespanstream (), Encoding .UTF8); Output = Outstream Readout ();  

How can I get it with Java? Note that I am not currently using the user's credentials, I am specifying the domain account (I have a password)

Please tell me how much with the classic ASP and ASP it's easy. Net ....

Take a look at the SpnegoHttpURLConnection class in the SPNEGO HTTP Servlet Filter project. There are some examples of this project too.

There is a lot in this project that you are doing in your example.

Look at this example from javadoc ...

  public static zero main (final string [] args) throws exception {final string creds = "dfelix: myp @ s5 "; Last String Token = Base64. encode (creds.getBytes ()); URL url = new URL ("http: // medusa: 8080 / index.jsp"); HttpURLConnection conn = (HttpURLConnection) url.openConnection (); Conn.setRequestProperty (Constants.AUTHZ_HEADER, Constants.BASIC_HEADER + "" + Tokens); Conn.connect (); System.out.println ("response code:" + conn.getResponseCode ()); }  

Comments

Popular posts from this blog

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -