Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Authentication and re-Authentication for authorization on Tomcat 4.1.24  RSS feed

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my server.xml, I have a JNDI realm which works for authenticating every user against Microsoft Active Directory.

The user requests a URL which I have set up as an alias in my web.xml for a servlet which authenticates the user against the active directory and then does a dispatcher.forward(request,response) to what is essentially an opening page for the user. (A menu of links to specific programs.)

I am trying to implement further authorization for certain programs for administrators.

If a person tries to open (I�m only testing 1 page at the moment) the protected page, before doing the dispatcher.forward(request,response), I rewrite the http header to be basic authentication in an effort to trick Tomcat into re-authenticating for this page.

response.setStatus(response.SC_UNAUTHORIZED); // Ie 401

I have set up a context fragment similar to tomcat_home/webapps/application.xml trying to set up the additional basic authentication.

It wants to use the user database, and in fact, it does pop up the basic login window after the user has cleared the jndi authentication. However, after 3 attempts to login, it neither gives me a �bad password� message, nor a �successful� message, instead after the 3 attempts, it just allows the already authenticated user access whether or not they have been assigned the appropriate role in the tomcat-users.xml.

Any ideas why it doesn�t seem to be actually using the tomcat-users.xml?
It�s a miracle that it�s this close to working. I�m feeling my way through this, I�m not very experienced at Tomcat or Java or Jndi, I only touch on them occasionally. So, please answer in full, rich answers.

Thanks so much
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!