[jcifs] RE: NTML Authentication in servlet

Doan, Thi-My-Chi thi-my-chi.doan at hp.com
Wed Dec 22 16:22:09 GMT 2004


Hi,

I also tried the code below but it still not work

             Config.registerSmbURLHandler();
            System.out.println(System.getProperty(
"java.protocol.handler.pkgs"));
            Config.setProperty("jcifs.http.domainController",
"americas.cpqcorp.net");
            //Config.setProperty("jcifs.smb.client.domain",
"americas.cpqcorp.net"); **** this did not work too

            Config.setProperty("jcifs.smb.client.username", _username );
            Config.setProperty("jcifs.smb.client.password", _password);

System.out.println("_username = " +  _username  + "  _password=" +
_password);

        try {
            Config.setProperty("jcifs.netbios.hostname",
                    Config.getProperty("jcifs.netbios.hostname",
                            InetAddress.getLocalHost().getHostName()));
        } catch (Exception ex) { }

            // Send the request to the server.
            URL u = new URL(url + LOGIN + "?j_username=" + _username +
            				"&j_password=" + "ssssss" );
            HttpURLConnection connection = (HttpURLConnection) 
            		u.openConnection();
            if (connection.getResponseCode() == 403) {
            	return false;
            }
            

However it worked with http://DOMAIN%5cuser:password@host/dir/file.html 
It seems that the property settings (Config.setProperty...) are not sent
to server application 

Thanks and regards
My Chi



>  -----Original Message-----
> From: 	Doan, Thi-My-Chi  
> Sent:	Wednesday, December 22, 2004 2:01 PM
> To:	'jcifs at lists.samba.org'
> Subject:	NTML Authentication in servlet
> 
> Hi,
> 
> I have problem to access servlets running on the BEA server 8.1 from a
> standalone java application. I configured the web.xml as followed:
> 
> <filter>
>     <filter-name>NtlmHttpFilter</filter-name>
>     <filter-class>jcifs.http.NtlmHttpFilter</filter-class>
> <init-param>
>         <param-name>jcifs.http.domainController</param-name>
>         <param-value>americas.cpqcorp.net</param-value>
>     </init-param>
>     <init-param>
>         <param-name>jcifs.netbios.wins</param-name>
>  
> <param-value>16.57.7.253,16.25.7.254,16.57.7.246,16.25.7.247</param-va
> lue>
>     </init-param>
>     <init-param>
>         <param-name>jcifs.http.loadBalance</param-name>
>         <param-value>true</param-value>
>     </init-param>
>     <init-param>
>         <param-name>jcifs.util.loglevel</param-name>   
>         <param-value>3</param-value>
>     </init-param>
> </filter>    
> <filter-mapping>
>     <filter-name>NtlmHttpFilter</filter-name>
>     <url-pattern>/*</url-pattern>
> </filter-mapping>
> 
> 1) I successfully accessed the jsp page from IE and the NTML
> authentication seems to work fine. The according HTTP log looks like:
> 
> 15.197.234.154 - - [22/Dec/2004:13:26:58 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJN23Sby0wnPdT1vShnN0STdtyHQ8JpS14
> yLpTG09wH2nytfc0mm!722604844!1186760201 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:26:58 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJN23Sby0wnPdT1vShnN0STdtyHQ8JpS14
> yLpTG09wH2nytfc0mm!722604844!1186760201 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:27:02 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJN23Sby0wnPdT1vShnN0STdtyHQ8JpS14
> yLpTG09wH2nytfc0mm!722604844!1186760201 HTTP/1.1" 200 4459
> 15.197.234.154 - - [22/Dec/2004:13:27:08 +0100] "GET
> /hpsb_webtools/webtools.css HTTP/1.1" 304 0
> 15.197.234.154 - - [22/Dec/2004:13:27:08 +0100] "GET
> /hpsb_webtools/portal/navigation/header.js HTTP/1.1" 304 0
> 
> 
> 2) However I'm not able to get access to the servlet running on the
> same server application as 1). The code for that part:
> 			  URL u = new URL(url + LOGIN + "?j_username=" +
> _username +
>             				"&j_password=" + _password);
>             HttpURLConnection connection = (HttpURLConnection) 
>             		u.openConnection();
>             if (connection.getResponseCode() == 403) {
>             	return false;
>             }
> 
> I found the following logs:
> 
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpKQG3pBGjg2hx07v5ycLGXJFQNbGFDsB
> dTFdjtnJLfmxx74gbT!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpKrKTCJwfDt2WGcppJ0vfTWxLRJchJ56
> hbGnGn810rcCd2h3Gv!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpKhyFn8xsdpyXD0tVLk61QThm1jcxJBx
> x7nyyjBvNr4Hc3rWb8!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpK12C0Y2TQzRkWwxvyY1h9k62Tp4QVsk
> GhC4t6T0k1yDxTX1Sb!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpK41RDvs8sJyDGJhvPnRYb1NQmhGGwts
> 30RwNvSFs55RFSzpnL!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpKcnh7Jb8qsLll1pLsSzlkp3g2SQXTjh
> Cby2h1rWv22rx4GQTV!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpK4lCTHm37kr4CJgkYY1SYk6Vcc2Wnv2
> bZrhwSvMQvycXSbJqM!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpKv3XYJH2hgh1738fMhdlnpT3yPdvLFB
> rqCCq1jcbT2KhTT3Ld!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpKtbn0d8ymn3xSThVZxxFyBcLvJ1pBv3
> y3hJY5dhxpgqJpbJB0!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools
> HTTP/1.1" 302 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET /hpsb_webtools/
> HTTP/1.1" 302 477
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/Login.jsp;jsessionid=BJpK1hVgmz1LzlB8TjL1Z7P2yvMGqWxLG2
> z1FNDHVr2vLGTn9kpb!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/j_security_check?j_username=awuttke&j_password=platfor,
> 239 HTTP/1.1" 302 457
> 15.197.234.154 - - [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools;jsessionid=BJpKwxTKThFGw10W1ysdynVycvlWN15KGDD8Y22FGGS0
> DLpDLtvr!-620133764!-1654432485 HTTP/1.1" 302 0
> 15.197.234.154 - awuttke [22/Dec/2004:13:32:10 +0100] "GET
> /hpsb_webtools/;jsessionid=BJpKwxTKThFGw10W1ysdynVycvlWN15KGDD8Y22FGGS
> 0DLpDLtvr!-620133764!-1654432485 HTTP/1.1" 401 0
> 15.197.234.154 - awuttke [22/Dec/2004:13:32:11 +0100] "POST
> /hpsb_webtools/EMT HTTP/1.1" 401 0
> 
> What is wrong with my code? 
> 
> Thanks and regards
> My Chi
> 
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the jcifs mailing list