User Authentication

hi all,

i am working on servlets and i would like to set up authentication for the pages ppl view.

i have used the following code to display that the page that people are viewing needs authentication

response.setStatus(res.SC_UNAUTHORIZED);

response.setHeader("WWW-Authenticate","NTLM");

it pops up a authentication window but when i give domain\user name and password it does not proceed.

how should we use the authentication stuff?

i need to work on sessions so i would like to authenticate the user before i use their name in session info.

please let me know what i should do.

[634 byte] By [sgshankara] at [2007-11-27 8:53:39]
# 1
Most web application servers provide authentication mechanisms that can be configure in the web.xml file. Check the documentation for your server. http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html
tolmanka at 2007-7-12 21:11:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
hi is this the only way to do authentication.... like setting up the relm and then using it?
sgshankara at 2007-7-12 21:11:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

As far as I know, this is the only way with Tomcat, you could try running Tomcat with Apache and use NTLM authentication with Apache. Tomcat by itself doesn't support domain authentication.

I've seen some code somewhere where the app reads the values from Windows, i.e. it uses the values of the user logged into the Windows system ( NTLM ). But the problems with that are that

1. It doesn't actually involve a login, it automatically uses the values

2. You'll have to put the code on every single page and handle the restriction etc on your own since it's part of your JSP/servlet code and is not handled by the container.

nogoodatcodinga at 2007-7-12 21:11:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

ok..

i am using the system to show me a pop up and get get the user info why is that not authenticating against the domain? shouldnt the browser automatically try to authenticate?

i am unaware of whats the process behind this authentication procedure.. can any one tell me what will happen once i get the popup and i give domain\username followed by password and click ok?

will it go back to application server?

sgshankara at 2007-7-12 21:11:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I really don't know how the authentication that you're using works.The domain authentication is under the control of the server; once the user types in the details, the server will authenticate that data against the realm that you've specified, JDBC, Memory, JNDI or whatever.
nogoodatcodinga at 2007-7-12 21:11:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Here's what a little Google'*** turned up: http://www.jguru.com/faq/view.jsp?EID=1045412 http://www.jguru.com/faq/viewquestion.jsp?EID=393110
nogoodatcodinga at 2007-7-12 21:11:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...