[jcifs] jcifs NTLM authentication in an Applet.

Michael B Allen mba2000 at ioplex.com
Thu Oct 23 08:50:50 EST 2003

> I am having problems with my Java Applet attempting to
> authenticate using http with an MS Web server. The
> Applet returns a 401 authorization failed. When I use
> the same code in a Java application everything works
> fine.  Here is the code in question:
>             jcifs.Config.registerSmbURLHandler();
> I noticed in the debugger, the Java application was
> checking for the protocol handlers when an
> OpenConnection() occurred.  The applet seemed to skip
> this check and always used the Java default protocol
> handler.

The SMB protocol handler needs to be loaded by the System class loader or
a class loader with similar requisite permissions. An applet is loaded in
a very restricted class loader that will not permit code downloaded from
the server to register a handler. You would need to determine which
permissions specifically are necessary to register the handler and then
create a policy file and sign the applet, etc, etc. I don't recall the
details but it might be possible. Or perhaps you can install the jar in on
the client where the Web Browser will load it using a suitably
less-restricted class loader but I'm not certain that's even possible with
a client like IE for example.


A program should be written to  model the concepts of the task it
performs rather than the physical world or a process because this
maximizes the  potential for it  to be applied  to tasks that are
conceptually similar and, more  important, to tasks that have not
yet been conceived.

More information about the jcifs mailing list