java - JCIFS NTLM Authentication for HTTP Connections on GlassFish (or any servlet container) -


I have created a Java class that connects to an IIS website which requires NTLM authentication. Java class uses the JCIFS library and is based on the following example:

  Config.registerSmbURLHandler (); Config.setProperty ("jcifs.smb.client.domain", domain); Config.setProperty ("jcifs.smb.client.username", user); Config.setProperty ("jcifs.smb.client.password", password); Url url = new url (location); Buffer Reader Reader = New buffed reader (new input train reader (url.openstream ()); String line; While ((line = reader.readline ()) = null {} System.out.println (line); }  

example works fine when executed from the command prompt, but as soon as I tried to use the same code in a servlet container (especially GlassFish) therefore I A IOException

I have tried to run a pinch jar for system classpath (% GLASSFISH% / lib). , But it does not matter.

Suggestions are highly appreciated. It seems that I was trying to do that is supported already in Java 5/6 and so I had to leave Jesiaifs API and instead be able to do something like:

  public static string Millerspons (last connection settings settings, string request) throws IOException {string url = Setingskgetuarel () + "/" + request; Authenticator.setDefault (new certifier () {@Override public Paswardadikarn getPasswordAuthentication () {System.out.println (getRequestingScheme) + "certification") Keep // user remember names to NT domain New Paswardathikeshn (settings.getDomain () + "\\" + settings.getUsername (), settings.getPassword (). ToCharArray ());}}); URL urlRequest = new URL (url); HttpURLConnection conn = (HttpURLConnection) urlRequest.openConnection (); Conn.setDoOutput (right); Conn.setDoInput (true); Conn.setRequestMethod ("GET"); StringBilder Response = New StringBuilder (); InputStream stream = conn.getInputStream (); BufferedReader = new BufferedReader (new InputStreamReader (stream)); String str = ""; While ((str = in.readLine ()) = null) {response.append (str); } In.close (); Return response. String (); }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -