I'm a total newbie to J2EE programming, and in fact to client/server programmin in general, so please be gentle :)
I'm trying to figure out an effective way to do authentication for my application. It uses only servlets and JSPs, since the whole EJB thing is a bit more than i need right now, but i wouldn't mind knowing how things work there, too.
At the moment, i'm storing password hashes in the database in a userlogin table, and just storing either a null userid in the HttpSession object that passes around the pages or a set userID if someone is logged in. Something tells me, though, that this is not the way i should be doing it.
I'm using JBoss to host this, if it makes a difference. Can someone point me at the right book/site that can teach me the right practices to use to solve this?
Thanks.
Discussions
Web tier: servlets, JSP, Web frameworks: Best practices for authentication of simple web apps
-
Best practices for authentication of simple web apps (5 messages)
- Posted by: Chris Rose
- Posted on: April 29 2004 17:38 EDT
Threaded Messages (5)
- Best practices for authentication of simple web apps by Bidyut Pattanayak on April 29 2004 19:56 EDT
- Best practices for authentication of simple web apps by Chris Rose on April 29 2004 21:27 EDT
-
Best practices for authentication of simple web apps by Senthil Chinnaiyan on April 30 2004 08:52 EDT
-
Best practices for authentication of simple web apps by Chris Rose on April 30 2004 12:09 EDT
- Container Managed Security by joseph yi on May 03 2004 05:24 EDT
-
Best practices for authentication of simple web apps by Chris Rose on April 30 2004 12:09 EDT
-
Best practices for authentication of simple web apps by Senthil Chinnaiyan on April 30 2004 08:52 EDT
- Best practices for authentication of simple web apps by Chris Rose on April 29 2004 21:27 EDT
-
Best practices for authentication of simple web apps[ Go to top ]
- Posted by: Bidyut Pattanayak
- Posted on: April 29 2004 19:56 EDT
- in response to Chris Rose
The best way for you would be to use MVC pattern where the job of the controller would be to do authentication. You can read documentation on Struts on how to do it. Also think of adapting Struts or any other MVC frameworks for your JSP application. It would be scalable in long run with less maintance. Struts default controller has the facility to override and provide your own way of authentication. -
Best practices for authentication of simple web apps[ Go to top ]
- Posted by: Chris Rose
- Posted on: April 29 2004 21:27 EDT
- in response to Bidyut Pattanayak
I'm trying to learn the J2EE thing from first-ish principles, which means i'm choosing not to use Struts as yet, until i understand things well enough to do without them. Then i'll add them in.
What other options are there? -
Best practices for authentication of simple web apps[ Go to top ]
- Posted by: Senthil Chinnaiyan
- Posted on: April 30 2004 08:52 EDT
- in response to Chris Rose
I'm trying to learn the J2EE thing from first-ish principles, which means i'm choosing not to use Struts as yet, until i understand things well enough to do without them. Then i'll add them in.What other options are there?
I would suggest you to start with Servlets & JSPs with helper classes and Data Access Objects(Apply MVC pattern), then learn Struts, you will find how easy struts is to use for MVC pattern.
Sun is the best place to learn J2ee.
Tutorial: http://java.sun.com/j2ee/tutorial/1_3-fcs/
AudioCasts: http://java.sun.com/developer/onlineTraining/webcasts/
Thanks,
Senthil. -
Best practices for authentication of simple web apps[ Go to top ]
- Posted by: Chris Rose
- Posted on: April 30 2004 12:09 EDT
- in response to Senthil Chinnaiyan
The thing is, i'm not looking for general application design answers, although those are great too, since there seem to be a lot of ways one can do design of J2EE apps. The MVC pattern is the one i'm looking at, but that's beside the point.
What i want to know is how i can handle authentication in such a way that i can add new users via a web interface and authenticate them for access to resources on the site. Do i use JAAS? And if so, how? Or do i write my own hack auth system and just do checks to the HttpSession that is passed throughout the session?
And how do i set cookies, and use them for 'remember me' logins?
Basically, I plan to pick up a book or two on the subject, but i'd like to know now which one i should look at, and/or what web resources are ideal for answering this particular kind of design questions.
Be sure i'll be reading that tutorial, by the way -- i'm not trying to suggest that it was a bad idea, just that i'm looking for very specific information at the moment.
Thanks again for all the help. -
Container Managed Security[ Go to top ]
- Posted by: joseph yi
- Posted on: May 03 2004 17:24 EDT
- in response to Chris Rose
Have you investigated your application server's container managed security mechanisms? Within web.xml, you can define what URL patterns are protected, what login scheme to use, and who has permission to access the resource, but the 'implementation' of how the container managed security works is dependent on your particular app server. Based on the login, you can call HttpServletRequest's getRemoteUser() to get the 'uer login name' without really having to deal with sessions directly.