Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Form-based authentication

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using JAAS with form based authentication in our application.When a user types in a user name and password I check it with the j_security_action. If the login fails , then I forward to an error_page.jsp.
I display a message saying invalid username and password. But it might be beacuse the database is down. Is there a way to find out that and display the appropriate message to the user ?
Thanks in advance for any suggestions.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If that is a problem with database , then all the users trying to login should get the error message.
Follow the below algorithm:

In the login module :

If there is a database exception , then store the exception in application with key as "CAUSE".

In case of any other exception you can store the exception in application context with the same key as "CAUSE".

In error_page.jsp

check for "CAUSE" in application scope.If present you can do

<%
Exception e = (Exception)application.getAttribute("CAUSE");
out.write(e.getMessage());
%>

Let me know if it helps,
 
roon ray
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.
How would I know there is a database exception as j_secutiy_check action does not differs betwwen database connection problem and wrong password problem.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget about j_secutiy_check , this would just delegate your authentication request to the login module as configured in the JAASReleam.

You are the one who will write the main authentication logic in the login module.So you can easily track the exceptions throws by the module.

If you have written the loginmodule then post code.
 
roon ray
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved the problem by using a taglib.
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic