• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to use SQL database for J2EE web logins

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to be able to authenticate users based on a username and password in a SQL server database. Presently, I have setup users by using the realmtool from the J2EE server. I would rather use the database entries. Could you please tell me how to do this? Can it be done from the deployment tool?
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Security tab,choose Form Based authentication, instead of Basic authentication.
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by surasak lee:
In Security tab,choose Form Based authentication, instead of Basic authentication.


I have not used the j2ee server ( reference implementation).
I had a question though. So it does allow me to specify the database as the repository against which it needs to authenticate with Form based authentication?
I mean can i switch between LDAP, Database and flat file as possible repositories for form based authentication?
 
P.Jamieson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I set this for FORM-BASED authentication, what else do I need to do in order to authenticate to a SQL database? I need to authenticate to this database as I will be adding / deleting users (dynamic).
[ November 20, 2003: Message edited by: P.Jamieson ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at this article on form-based security in J2EE web applications. Basically, you need three things:
- a pair of HTML/JSP pages (login.jsp, login-error.jsp)
- a restricted part of the web application (so that the container will force the user to login)
- a security realm configured to use the database (vendor-specific)
 
P.Jamieson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I have looked at this previously. The example that they use is for Tomcat users. I am using the J2EE web server (hence container). Looking at your points, could you please explain further how I can map a realm name to my database? Also do I have to edit any other files like they explain for Tomcat (i.e. server.xml)? I have already setup tables for users, user_roles and roles in my database.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I can say is read the J2EE tutorial. This page looked like the closest match for what you want to do. I haven't used the reference implementation in ages (and probably didn't specify any realms) so I'm really not able to help with specifics on that particular server.
 
P.Jamieson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. I have gone through the tutorial and it only the basics. The only part that I need is to know how to create my own realm that is configured to use a database.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case, go through your particular application server's documentation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic