kunalraj — 2009-02-03T03:35:30-05:00 — #1
I am developing jsp/servlet web application.
I have coded for login and it is successful.
But Now i want to do code for particular user is going to log in.
But his id/password is wrong then he is retrying.
upto 3 times he will try for login.
after that, that particular user can not login for some time.
means for specific time his account will locked.
How can i do this CAN ANY ONE GUIDE ME?
If any one have any example than let me know.
mikemckinney — 2009-02-03T04:23:56-05:00 — #2
My product has a prov_user (Provisioning - User) table that contains a record for each user allowed on the system. Among other items, the record contains the user's login ID, encrypted password, user state (Enabled, Disabled, and Suspended), user state change time stamp, and an invalid password count. Normally, the user state is Enabled. I have a web page which allows an administrator to Disable or Enable users. A value of Suspended means the user is temporarily prevented from logging in.
When the user logs in successfully, the code sets the invalid password count to zero. When the user provides an incorrect password, the code increments the invalid password count. After three consecutive failures, the code sets the user state to Suspended and sets the state change time stamp to the current time. Should the user provide the correct password while the state is Suspended, the code checks how long the user has been suspended. If the user has been suspended for at least 5 minutes (you may want to use another time interval), the code sets the state to Enabled, sets the state change time stamp, sets the invalid password count to zero, and logs in the user. Otherwise, the code tells the user that their account is temporarily suspended and to try again later.
Hope this helps....
sg707 — 2009-02-03T09:55:17-05:00 — #3
mike's solution sounds good. Definitely, have a admin page to enable the user.
hooknc — 2009-02-03T10:51:00-05:00 — #4
I would recommend using a user_login table that records each and every login. Which user, from where (ip address), what time and if the user was successful or not.
I would then use a query to figure out if the user is a allowed to login or not based on that query.
That way you don't have to worry about updating state on a table all the time.
manwithshades — 2009-02-11T12:52:20-05:00 — #5
If you don't want to have to record the thing in the database, just put the user name into a session scope (or perhaps a static map). This might be easier than putting it in the database.
kunalraj — 2009-02-12T01:37:00-05:00 — #6
Ok i have done it through session.
sg707 — 2009-02-13T09:38:55-05:00 — #7
Just FYI, there maybe a security requirements which may not work with Session. For example, let say there's a hack who's trying access user "abc". He can easily retrieve new session and keeps on trying. So, just consider this fact when it's for a real project.
brandone — 2009-02-13T16:44:56-05:00 — #8
Agreed. You'll have more control if you store "user access attempts" in DB.
kunalraj — 2009-02-18T23:25:16-05:00 — #9
Ok so i would do that through database.
Thanks friends for guide me.