[jcifs] NTLM V2 authentication is failing with JCIFS (sample java program which uses JCIFS to contact the Proxy server with NTLMV2 authentication)

Nagaraja Joshi joshinagaraja at rediffmail.com
Thu Nov 6 12:35:37 GMT 2008


Hi,

We are using a sample java program which uses JCIFS library to communicate
using NTLMV2 authentication to a proxy server.

Also we are using the proxy server credentails to communicate through our
sample program (i.e IAS proxy which uses NTLMV2 Authentication)

However we are facing this issue when we execute the sample program :

Exception in thread "main" java.lang.NullPointerException
	at
jcifs.smb.NtlmPasswordAuthentication.getNTLMv2Response(NtlmPasswordAuthentication.java:246)
	at jcifs.ntlmssp.Type3Message.getNTLMv2Response(Type3Message.java:584)
	at jcifs.ntlmssp.Type3Message.<init>(Type3Message.java:229)
	at
jcifs.http.NtlmHttpURLConnection.attemptNegotiation(NtlmHttpURLConnection.java:566)
	at
jcifs.http.NtlmHttpURLConnection.doHandshake(NtlmHttpURLConnection.java:452)
	at
jcifs.http.NtlmHttpURLConnection.handshake(NtlmHttpURLConnection.java:103)
	at
jcifs.http.NtlmHttpURLConnection.getInputStream(NtlmHttpURLConnection.java:240)
	at java.net.URL.openStream(Unknown Source)
	at JCIFS.main(JCIFS.java:60)

The above problem is caused due to  targetInfo value passed to the public
static byte[] getNTLMv2Response( ) method of the 
NtlmPasswordAuthentication.java file becoming null.

The following line is causing the issue :

byte[] temp = new byte[28 + targetInfo.length];  //here targetInfo is
becoming null.

Heres the Sample Program which we used to execute the same :



import java.io.*;

import java.net.*;

import jcifs.*;

public class JCIFS {

    public static void main(String[] args) throws Exception {
    	
        // Normally set this outside application.
        // Note that as a side effect due to the way handlers are located,
        // you can also achieve this by simply doing:
           Config.registerSmbURLHandler();
        // which we already do to register the smb handler.
       // String pkgs = System.getProperty("java.protocol.handler.pkgs");
       // pkgs = (pkgs != null) ? "http|" + pkgs : "http";
        //System.setProperty("java.protocol.handler.pkgs", pkgs);
          
           String proxy = "64.104.136.241";                 //IAS proxy or
any proxy which is used to configure NTLMV2 authentication
           String port = "8080";                                   //IAS
proxy or any proxy port 
           System.setProperty("http.proxyHost",proxy);
           System.setProperty("http.proxyPort",port);
           

        //

      /*  if (args == null || args.length < 4) {
            System.out.println("NtlmHttpClient <url> <domain> <user>
<password>");
            System.exit(1);
        }*/
      // String location = "http://www.cisco.com/";
       String location = "http://www.cisco.com/";
        String domain = "cisco";
        String user = "nagaraja";
        String password = "nagaraja";

        // can also specify these in the URL, i.e.
        //     http://DOMAIN%5cuser:password@host/dir/file.html
        // which will override these properties
       Config.setProperty("jcifs.smb.client.domain", domain);
        Config.setProperty("jcifs.smb.client.username", user);
       Config.setProperty("jcifs.smb.client.password", password);
        Config.setProperty("jcifs.smb.lmCompatibility ", "3");
        Config.setProperty("jcifs.http.domainController","cisco");
      //  Config.setProperty("jcifs.smb.client.useUnicode ", "false");

       /* try {
        	Config.setProperty("jcifs.netbios.hostname","64.103.135.182");

            System.out.println("host
name"+Config.getProperty("jcifs.netbios.hostname",InetAddress.getLocalHost().getHostName()));
        } catch (Exception ex) { }
        //URL url = new URL(location);*/
        
        URL url = new URL("http://www.cisco.com/");

        BufferedReader reader = new BufferedReader(
                new InputStreamReader(url.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
        }
    }

}











It will be great if some body can help us on this.




-- 
View this message in context: http://www.nabble.com/NTLM-V2-authentication-is-failing-with-JCIFS-%28sample-java-program-which-uses-JCIFS-to-contact-the-Proxy-server-with-NTLMV2-authentication%29-tp20360187p20360187.html
Sent from the Samba - jcifs mailing list archive at Nabble.com.



More information about the jcifs mailing list