[jcifs] JCIFS NTLM Authentication for HTTP Connections

Michael B Allen mba2000 at ioplex.com
Wed Dec 8 00:02:38 GMT 2004

damien.postlethwaite at ntlworld.com said:
> Hi,
> I have successfully managed to use JCIFS to connect to a remote machine
> and retrieve the content of a webpage via
> 'jcifs.Config.registerSmbURLHandler();' in the main method of a stand
> alone java application as described here:
> 	http://jcifs.samba.org/src/docs/httpclient.html
> However, the same method does not seem to work when I call it from within
> a class to provide content to a java portlet that is running from a BEA
> weblogic web server.

This undoubted has to do with how the URL handler get's installed or used.

The below code shows how the SMB URL handler get's installed:

    public static void registerSmbURLHandler() {
        String pkgs;

        pkgs = System.getProperty( "java.protocol.handler.pkgs" );
        if( pkgs == null ) {
            System.setProperty( "java.protocol.handler.pkgs", "jcifs" );
        } else if( pkgs.indexOf( "jcifs" ) == -1 ) {
            pkgs += "|jcifs";
            System.setProperty( "java.protocol.handler.pkgs", pkgs );

There are a couple points of failure with this.

1) The caller doesn't have permission to set java.protocol.handler.pkgs.
Try to get the System property 'java.protocol.handler.pkgs' and see if
'jcifs' is in the list and look for Permissions exceptions in the logs.
2) The container is rudely overriding the java.protocol.handler.pkgs
property. Try to get the System property 'java.protocol.handler.pkgs' and
see if 'jcifs' is in the list.
3) The handler is actually a wrapper for the default http protocol
provider. Maybe weblogic is installing it's own implementation that isn't
compatible with ours (e.g. when we call it it doesn't do what needs to
happen (e.g. keep-alives) to get NTLM HTTP authentication to work). Get a
packet trace and see if it's actually sending the WWW-Authenticate: NTLM
<base64encodeddata> message.


More information about the jcifs mailing list