[jcifs] Tomcat NTLM authentication with JCIFS

Michael B. Allen miallen at eskimo.com
Wed May 22 17:36:08 EST 2002

Jason has submitted the NTLM authentication code he spoke of previously. I
have not examined it very closely but I have prepared two archives;
jcifs-ntlm-auth-0.6.4.{tgz,zip} available in the normal download
area. Perhaps Tomcat users can try it out and calaborate with him before
I figure out how exactly to include the code.

Thanks Jason,


On Wed, 22 May 2002 11:04:20 +1000
"Pugsley, Jason" <Jason.Pugsley at team.telstra.com> wrote:


I wrote to the mailing list several weeks ago detailing a project I was
working on to get seamless user authentication to a java web server with the
Internet Explorer NTLM "protocol". I've had some time recently to work on
the code, and I'd like to submit it for your examination.

The changes to existing JCIFS .java files from release 0.6.3:


  Changed the constructor to be public.


  Added new instance variables to hold pre-encrypted passwords.
  Added a new constructor to take pre-encrypted passwords.


  Added a new getSmbSession() that takes pre-encrypted passwords.
  Commented out session caching. Caching doesn't work for my purposes but
removing it might break other things. Please check this one for me!!


  Added code to writeParameterWordsWireFormat() to check if we're using
pre-encrypted passwords and use those instead of encrypting the clear-text

I also added a new file/class SmbNTLM.java for the web server NTLM based

If you have the time, maybe you could test this in your environment. If you
pass the changes I've made to JCIFS, then I'd hope to get others to test in
their environments too.

    [This does look very interesting Jason. I will look at this closely
    but for now I think I should just upload it "as is" because I know
    there are others that are interested in this sort of thing - mba]

Test environment setup procedures:

I've been working with the latest available release of Tomcat. It would be
best if you could use it in your test environment. If not let me know what
version you have and I'll see if I can customise my code. Here's the

After you've installed Tomcat, follow these instructions:

Edit $CATALINA_HOME/conf/tomcat-users.xml
Add your NT login ID with a blank password and appropriate roles.
Keep in mind tomcat usernames are case sensitive, but NTLM is not,
so be sure to add all usernames in uppercase to work properly.

<user username="JPUGSLEY" password="" roles="tomcat,role1"/>

Copy the supplied  jcifs-0.6.3.jar to

Overwrite the existing  catalina.jar  in $CATALINA_HOME/server/lib
with the supplied one.

Testing is done with the standard JSP example security test page.
As shipped, it is set up to use form based authentication. You need
to change it to NTLM based authentication.

Edit $CATALINA_HOME/webapps/examples/WEB-INF/web.xml
Replace these lines from the file

    <!-- Default login configuration uses form-based authentication -->
      <realm-name>Example Form-Based Authentication Area</realm-name>

with these lines

    <!-- Default login configuration uses NTLM-based authentication -->
      <realm-name>Example NTLM-Based Authentication Area</realm-name>

Edit $CATALINA_HOME/bin/catalina.sh
Add configuration entries as necessary. At least specify your jcifs
properties file.


Here is a suggested list of entries for your jcifs.prp file, edit for your

; wins and domain are necessary
; client hostname is optional, but recommended
; Set this to suit your environment or use default. (LMHOSTS,WINS,BCAST,DNS)
; For debugging

Now start the tomcat server.

If you have logging turned on in jcifs.prp, try tailing
$CATALINA_HOME/logs/catalina.out  and

Then point your browser to

If your computer is part of a domain, then you should get access straight

If your computer is part of a workgroup, then you might get a password
dialog. Depending on your version of IE and Windows, you'll get either 2
or 3 text boxes for your credentials.
If 2, then User Name will be DOMAIN\USERNAME
If 3, then you will have a separate box for each of User Name and Domain.

    [This sounds nice. I think I have a use for this at work myself. - mba]

I'm still in the process of learning the internals of Tomcat and JCIFS so I
apologise if my code is a bit sloppy. I hope we can work on the JCIFS
components. Once the SmbNTLM class is frozen, I can start pushing the
jakarta-tomcat people to include my NTLM changes. There's no guarantee this
will every happen though - the developers there seem to have little interest
in this idea. Maybe I'll look at some other java web servers - like Jetty
for example.

    [I don't think the existing code can go in "as is" but I haven't
    looked at it too closely yet. I would rather it not be specific to
    Tomcat. Someone should be able to use Resin or just CGI. In theory
    it should be possible to abstract that possibly handling HTTP
    request/responses directly and without interfereing with the core
    code too much. - mba]

Let me know what you think and how you get on.

Kind Regards,

Jason Pugsley.

More information about the jcifs mailing list