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.GrantedAuthority;
21  import net.sf.acegisecurity.GrantedAuthorityImpl;
22  import net.sf.acegisecurity.UserDetails;
23  
24  import org.bejug.javacareers.jobs.model.User;
25  
26  /***
27   *
28   * @author kva (last modified by $Author: shally $)
29   * @version $Revision: 1.3 $ - $Date: 2005/12/20 15:36:46 $
30   */
31  public class UserDetailsImpl implements UserDetails {
32      /***
33       * user the user
34       */
35  	private User user;
36  	
37  	/***
38  	 * @param user the domain level user
39  	 */
40  	public UserDetailsImpl(User user) {
41  		this.user = user;
42  	}
43  
44  	/*** 
45  	 * @see net.sf.acegisecurity.UserDetails#isAccountNonExpired()
46  	 * @return true or false
47  	 */
48  	public boolean isAccountNonExpired() {
49  		return true;
50  	}
51  
52  	/***
53  	 * @see net.sf.acegisecurity.UserDetails#isAccountNonLocked()
54  	 * @return true if Account is NonLocked
55  	 */
56  	
57  	public boolean isAccountNonLocked() {
58  		return true;
59  	}
60  
61  	/***
62  	 * @see net.sf.acegisecurity.UserDetails#getAuthorities()
63  	 * @return array GrantedAuthorities
64  	 */
65  	public GrantedAuthority[] getAuthorities() {
66  		GrantedAuthority[] auth = new GrantedAuthorityImpl[] {
67  				new GrantedAuthorityImpl(user.getRole())
68  		};
69  		return auth;
70  	}
71  
72  	/***
73  	 * @see net.sf.acegisecurity.UserDetails#isCredentialsNonExpired()
74  	 * @return true if Credentials is NonExpired
75  	 */
76  	public boolean isCredentialsNonExpired() {
77  		return true;
78  	}
79  
80  	/***
81  	 * @see net.sf.acegisecurity.UserDetails#isEnabled()
82  	 * @return true if enabled
83  	 */
84  	public boolean isEnabled() {
85  		return true;
86  	}
87  
88  	/***
89  	 * @see net.sf.acegisecurity.UserDetails#getPassword()
90  	 * @return password
91  	 */
92  	public String getPassword() {
93  		return user.getPassword();
94  	}
95  
96  	/***
97  	 * @see net.sf.acegisecurity.UserDetails#getUsername()
98  	 * @return username
99  	 */
100 	public String getUsername() {
101 		return user.getUserName();
102 	}
103 }
104 /***
105  * $Log: UserDetailsImpl.java,v $
106  * Revision 1.3  2005/12/20 15:36:46  shally
107  * CheckStyle and PMD changes.
108  *
109  * Revision 1.2  2005/09/13 08:11:17  schauwvliege
110  * organize imports
111  *
112  * Revision 1.1  2005/08/26 07:58:30  ge0ffrey
113  * split up the sources in service, serviceimpl and webclient
114  *
115  * Revision 1.3  2005/08/09 12:59:55  bavo_jcs
116  * Optimized imports
117  *
118  * Revision 1.2  2005/06/09 08:18:43  bejug_cc
119  * Fix initial import
120  *
121  * Revision 1.5  2005/05/17 11:59:56  ssc
122  * Refactored User and Publisher class to User Class added cvAdded Boolean, added Address to user, Fixed test to work with this setup
123  *
124  * Revision 1.4  2005/05/12 08:23:55  ssc
125  * Checkstyle errors
126  *
127  * Revision 1.3  2005/05/11 17:05:47  sja
128  * Corrected CVS tag.
129  *
130  * Revision 1.2  2005/05/09 14:54:45  ssc
131  * checkstyle
132  *
133  * Revision 1.1  2005/05/03 15:22:03  kva
134  * adapter for our user DAO to integrate with acegi
135  *
136  */