View Javadoc

1   /***
2   Copyright (C) 2005 The Java Community
3   
4   This program is free software; you can redistribute it and/or modify  it under
5   the terms of the GNU General Public License as published by  the Free Software
6   Foundation; either version 2 of the License, or  (at your option) any later
7   version.
8   
9   This program is distributed in the hope that it will be useful,  but WITHOUT
10  ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License  along with
14  this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15  Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17  
18  package org.bejug.javacareers.jobs.dao.adapters;
19  
20  import net.sf.acegisecurity.UserDetails;
21  import net.sf.acegisecurity.providers.dao.AuthenticationDao;
22  import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
23  
24  import org.bejug.javacareers.jobs.dao.UserDao;
25  import org.bejug.javacareers.jobs.model.User;
26  import org.springframework.dao.DataAccessException;
27  
28  /***
29   * The Acegi authentication dao implementation.
30   *
31   * @author kva (last modified by $Author: schauwvliege $)
32   * @version $Revision: 1.2 $ - $Date: 2005/09/13 08:11:17 $
33   */
34  public class AcegiAuthenticationDaoImpl implements AuthenticationDao {
35  
36  	/***
37  	 * The domain level <code>userDao</code> to be adapted to fit acegi.
38  	 */
39  	private UserDao userDao;
40  	
41  	/***
42  	 * load the user by username.
43  	 * @return userDetails
44  	 * @param name username String
45  	 * @throws UsernameNotFoundException if username is not found
46  	 * @throws DataAccessException if so;ething goes wrong on the database
47       * @see net.sf.acegisecurity.providers.dao.AuthenticationDao#loadUserByUsername(java.lang.String)
48  	 */
49  	public UserDetails loadUserByUsername (String name)
50  			throws UsernameNotFoundException, DataAccessException {
51  		User user = userDao.getUserByUserName(name);
52  		if (null == user) {
53              throw new UsernameNotFoundException(name);
54          }
55  		
56  		UserDetails details = new UserDetailsImpl(user);	
57  		return details;
58  	}
59  
60  	/***
61  	 * @param userDao The userDao to set.
62  	 */
63  	public void setUserDao(UserDao userDao) {
64  		this.userDao = userDao;
65  	}
66  }
67  
68  /***
69   * $Log: AcegiAuthenticationDaoImpl.java,v $
70   * Revision 1.2  2005/09/13 08:11:17  schauwvliege
71   * organize imports
72   *
73   * Revision 1.1  2005/08/26 07:58:30  ge0ffrey
74   * split up the sources in service, serviceimpl and webclient
75   *
76   * Revision 1.3  2005/08/09 12:59:55  bavo_jcs
77   * Optimized imports
78   *
79   * Revision 1.2  2005/06/09 08:18:43  bejug_cc
80   * Fix initial import
81   *
82   * Revision 1.3  2005/05/17 11:59:56  ssc
83   * Refactored User and Publisher class to User Class added cvAdded Boolean, added Address to user, Fixed test to work with this setup
84   *
85   * Revision 1.2  2005/05/12 08:23:55  ssc
86   * Checkstyle errors
87   *
88   * Revision 1.1  2005/05/11 17:04:30  sja
89   * Renamed class and corrected CVS tag.
90   *
91   * Revision 1.5  2005/05/11 11:29:32  ssc
92   * Checstyle errors
93   *
94   * Revision 1.4  2005/05/11 08:09:20  ssc
95   * fixed AcegiAuthenticationTest
96   *
97   * Revision 1.3  2005/05/09 14:54:45  ssc
98   * checkstyle
99   *
100  * Revision 1.2  2005/05/04 14:58:54  kva
101  * checkstyle fix
102  *
103  * Revision 1.1  2005/05/03 15:22:03  kva
104  * adapter for our user DAO to integrate with acegi
105  *
106  */