%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.mindoro.domain.SecurityFacade |
|
|
1 | /* |
|
2 | * Created on Jun 6, 2005 |
|
3 | * |
|
4 | * The SecurityFacade provides a simplified and unified interface to the |
|
5 | * underlying Users/Roles/Permissions model. |
|
6 | */ |
|
7 | package net.sf.mindoro.domain; |
|
8 | ||
9 | import net.sf.mindoro.dao.UserDao; |
|
10 | import net.sf.mindoro.model.SystemUser; |
|
11 | ||
12 | /** |
|
13 | * The SecurityFacade provides a simplified and unified interface to the |
|
14 | * underlying Users/Roles/Permissions model. |
|
15 | * |
|
16 | * @author aisrael |
|
17 | */ |
|
18 | public class SecurityFacade { |
|
19 | ||
20 | private final UserDao userDao; |
|
21 | ||
22 | /** |
|
23 | * @param userDao |
|
24 | * UserDao |
|
25 | */ |
|
26 | 1 | public SecurityFacade(final UserDao userDao) { |
27 | 1 | this.userDao = userDao; |
28 | 1 | } |
29 | ||
30 | 1 | /** |
31 | 1 | * Attempt to authenticate the given SystemUser. |
32 | 1 | * |
33 | * @param user |
|
34 | * SystemUser |
|
35 | * @return a SystemUser object from the database if the given user's credentials |
|
36 | * are ok, null otherwise |
|
37 | */ |
|
38 | public final SystemUser authenticate(class="keyword">final SystemUser user) { |
|
39 | 2 | SystemUser result = null; |
40 | 4 | final SystemUser foundUser = userDao.findUserByLogin(user.getLogin()); |
41 | 4 | if (null != foundUser) { |
42 | 4 | if (foundUser.getLogin().equals(user.getLogin()) |
43 | 2 | && foundUser.getPasswordHash().equals(user.getPasswordHash())) { |
44 | 3 | result = foundUser; |
45 | } |
|
46 | 0 | } |
47 | 2 | return result; |
48 | 0 | } |
49 | 2 | |
50 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |