View Javadoc

1   package org.musicontroller.security;
2   
3   
4   import java.util.Date;
5   import java.util.List;
6   import java.util.Set;
7   
8   import org.acegisecurity.userdetails.UserDetails;
9   
10  /**
11   * A User is a user of a certain program. A User can be assigned
12   * Role-objects, which contain Authorities to perform certain tasks.
13   * @author Arjan Verstoep
14   * @version $Id: IUser.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
15   */
16  public interface IUser extends UserDetails {
17  
18  	/**
19  	 * The unique identifier that can be used to distinguish different Users from eachother.
20  	 * @return The unique Id that is connected with this User, or -1 if the User has not been persisted yet.
21  	 */
22  	public long getId();
23  	/**
24  	 * Sets the identifier of the User.
25  	 * @param id an integer.
26  	 */
27  	public void setId(long id);
28  	
29  	/**
30  	 * @return The Date after which this User is no longer permitted to logon.
31  	 */
32  	public Date getExpiryDate();
33  	/**
34  	 * Sets the expirydate of this User. After this date, the User will no longer
35  	 * be able to logon.
36  	 * @param expiryDate
37  	 */
38  	public void setExpiryDate(Date expiryDate);
39  	
40  	/**
41  	 * @return The loginname of this User.
42  	 */
43  	public String getLoginname();
44  	/**
45  	 * Sets the loginname for this User.
46  	 * @param loginname The loginname. It is advisable to use only lowercase letters in the loginname.
47  	 */
48  	public void setLoginname(String loginname);
49  	
50  	/**
51  	 * @return The real name of this User.
52  	 */
53  	public String getName();
54  	/**
55  	 * Set the real name of this User.
56  	 * @param username The name.
57  	 */
58  	public void setName(String username);
59  	
60  	/**
61  	 * @return All Role-objects assigned to this User.
62  	 */
63  	public Set<Role> getRoles();
64  	
65  	/**
66  	 * Set the Roles which this User is assigned to. 
67  	 * @param roles The Roles.
68  	 */
69  	public void setRoles(Set<Role> roles);
70  	
71  	/**
72  	 * Convenience method to get the roles in List form.
73  	 * @return All Role-objects assigned to this User.
74  	 */
75  	public List<Role> getRolesList();
76  	
77  	/**
78  	 * Convenience method to set the roles in List form.
79  	 * @param roles The Roles.
80  	 */
81  	public void setRolesList(List<Role> roles);
82  	
83  	/**
84  	 * Adds a Role to the set of Roles of this User.
85  	 * @param role The Role to add
86  	 */
87  	public void addRole(Role role);
88  	
89      /**
90       * Sets the password for a User. This will encrypt
91       * the given password and fill the encrypted password with
92       * the encrypted version of the supplied password.
93       * @param unencryptedpass The unencryted password.
94       */	
95  	public void setUnencryptedPassword(String unencryptedpass);
96  	
97  	/**
98  	 * Gets the encrypted version of this Users password.
99  	 */
100 	public String getPassword();
101 	
102 	/**
103 	 * Sets the encrypted version of this Users password.
104 	 * @param encryptedPassword The encrypted password.
105 	 */
106 	public void setPassword(String encryptedPassword);
107 
108 	//TODO A User should have a property int getLoginCount()
109 	// int getFailedLoginCount()
110 	// Date getLastLogin()
111 	// After 3 failed logins --> call sleep() to prevent dictionary attacks, or block the account.
112 
113 }