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

extend form based authentication

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have implemented a form based authentication. however, i would like an "extension". In my database i have a column "last_login". whenever, a user succesfully loggs in to the web app a message is show e.g.: welcome mr ... you last logged in on 23/01/2008 14:34:40.

my first question is when shall i store the login date/time in the database and how?
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Viv,
I suppose that you are already using one of the JAAS login module (probably the database login module) configured on <server_conf>/conf/login-config.xml.

So, for example, I have this one on my configuration file:


I think that simply you should have a look how it is implemented the DatabaseServerLoginModule. After that you can extends or decorate it (it depends on its implementation).

Regards,
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"a.gazzarini"

Please check your private message for a message from JavaRanch.
 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the username stored somewhere in the session after i get authenticated?

i would like to write the following when the user logs in:

welcome user_123, you last logged in on 23/11/2008.

thanks in advance.
[ November 23, 2008: Message edited by: Viv Singh ]
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, you can use the request.getRemoteUser() where of course "request" is an instance of HttpServletRequest. As Javadoc says :

"Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER"

Hope it helps
 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your help.

i also need to get the role which is fetched from the database when the authentication is done. how can i get that?

i checked the api and there is only one method request.isUserInRole("1") that returns a boolean. is there any other way to actually get the role of the user that is "logged" in.

thanks in advance.
 
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic