aspose file tools*
The moose likes JSP and the fly likes How to restrict two user with same username and password Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to restrict two user with same username and password" Watch "How to restrict two user with same username and password" New topic
Author

How to restrict two user with same username and password

Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
Could any body tell me how can i restrict user from logging in to the server from two machines using same username and password at the same time.
Thanks
Idly Vada
Ranch Hand

Joined: Sep 02, 2003
Posts: 135
Originally posted by Kondal reddy:
Could any body tell me how can i restrict user from logging in to the server from two machines using same username and password at the same time.
Thanks

Just maintain user name and number of sessions in a table, if the username is already associated with a session, disallow other sessions.
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
Try this
Write a UserId class implementing HttpSessionBindingListener.
Add a flag column in the user_detail table. When the user login always check the flag.
Allow login only when the flag is "NO". Then set the flag to "YES" and allow login.
Create UserId object add it to the session
valueUnbound method of the UserId class reset the flag (from "YES" to "NO") in the user_detail table.
Sainudheen
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

What if your webserver crashes? User logged in at the time of the crash will never be able to log in.
Originally posted by Sainudheen Mydeen:
Try this
Write a UserId class implementing HttpSessionBindingListener.
Add a flag column in the user_detail table. When the user login always check the flag.
Allow login only when the flag is "NO". Then set the flag to "YES" and allow login.
Create UserId object add it to the session
valueUnbound method of the UserId class reset the flag (from "YES" to "NO") in the user_detail table.
Sainudheen


Groovy
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
To avoid locking people out forever, clear the table at server startup and make it so nobody is logged on. We have something very similar in a current system. If you have only one instance of your server - no load balanced machines or such things - you might as well manage all of this in memory.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

you might as well manage all of this in memory.

This is a good one.
 
 
subject: How to restrict two user with same username and password