1 /**
2 *
3 */
4 package ar.com.jiji.kaya.dao.hib;
5
6 import java.util.List;
7
8 import ar.com.jiji.kaya.dao.UserDao;
9 import ar.com.jiji.kaya.model.User;
10
11 /**
12 * @author lparra
13 *
14 */
15 public class UserDaoImpl extends HibernateCRUDPageableDaoImpl<User> implements
16 UserDao {
17
18 public UserDaoImpl() {
19 super(User.class);
20 }
21
22 public boolean authenticate(String username, String password) {
23 return findByCredentials(username, password) != null;
24 }
25
26 @SuppressWarnings("unchecked")
27 public User findByCredentials(String username, String password) {
28 User usr = new User(username);
29 usr.setPassword(password, true);
30 usr.setEnabled(true);
31
32
33
34
35 List<User> result = getHibernateTemplate().findByExample(usr, 0, 2);
36 if (result.size() == 1)
37 return result.get(0);
38 return null;
39 }
40
41 }