Hello everbody, what are the best possible ways for user authentication in java??Say, I've a user interface done in swing.Before the user try to do some operation, I would like to check for his credentials(password is encrypted).Never done with java before, had experience with PHP using flat files as well as databases.I dont want to use any database here. pls point me to a nice tutorial,useful links or if somebody had a sample code, I would like to go through too. Thanks for all your time
Originally posted by kimi lynn: Hello everbody, what are the best possible ways for user authentication in java??
The user authentication/authorization services Java makes available are in the Enterprise Edition, probably an order of magnitude more complex than you want to get into.
I dont want to use any database here.
Every time I've rolled my own auth I've used a database. It should be pretty easy to use a flat file. Store a user name, hashed password and some flags on a line as a record. Scan through the file using the user name as the record 'index'. If you want to get really fancy (or if performance is an issue, you have a couple hundred users), you could store the user records in order by user name and use java.io.RandomAcccessFile to do a binary search of the records. That would give you database-like speed without the database-like overhead. Of course you'd have to write a maintaince application to add/update/insert/delete records.
You could start with The Java Tutorial I/O Classes. As for links to building your own auth functionality, doesn't look like it on google. Hence the problem with rolling your own: nobody's done it before.