This blog is mainly about Java...

Thursday, August 28, 2008

Enabled commenting on my blogs

I decided to enable commenting on my blogs.
I dont know why I havent done this earlier, but anyways, never to late. So if you have something to say or a question, please comment the blog and I will answer ASAP.

2 comments:

Prati said...

Hi

I can now save password in database following your blog.I am using hash ="md5" annotation also. @UserPassword(hash ="md5")
public String getPassword() {
return password;
}
But now how can i login from UserLoginPage using plain text password.

Please Help

Shervin Asgari said...

Pretty simple actually.

You dont use the password in your query. You just get the user with username, then you check the password.

Something like:

user = (ProcessUser) entityManager.createQuery("from User where username = :username ").setParameter("username", username) .getSingleResult();

Then you check if the password matches here if(!user.getPassword().equals(PasswordSupport.generatePasswordHash(password, username)) return false;

Labels