KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > user > User


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.repository.user;
17
18 import java.util.Date JavaDoc;
19
20 import org.outerx.daisy.x10.UserDocument;
21 import org.outerx.daisy.x10.PublicUserInfoDocument;
22 import org.outerj.daisy.repository.RepositoryException;
23
24 /**
25  * A repository user.
26  */

27 public interface User {
28     /**
29      * Sets this User's default role.
30      *
31      * <p>If the user is not yet associated with this role
32      * (via {@link #addToRole(Role)}), then this will be
33      * done implicitely.
34      *
35      * <p>You can specify null to unset the default role.
36      *
37      * <p>A default role is optional, if a user does not have
38      * a default role, then the authentication code will itself
39      * decide which role(s) to take as default.
40      */

41     void setDefaultRole(Role role) throws UserManagementException;
42
43     /**
44      * Gets the default role for this user, can return null
45      * if there is no default role assigned.
46      */

47     Role getDefaultRole();
48     
49     /**
50      * Adds the User to the specified Role role. If the user is added
51      * to the same role twice, nothing happens (no exception is thrown).
52      * In that case, the user will only belong to that role once.
53      *
54      * @param role the Role to add the user to
55      */

56     void addToRole(Role role);
57     
58     /**
59      * Remove the User from the specified Role role.
60      *
61      * @param role the Role to remove the user from
62      */

63     void removeFromRole(Role role);
64     
65     /**
66      * Returns the Roles to which the user belongs
67      */

68     Roles getAllRoles();
69
70     /**
71      * Returns the ids of the roles to which the user belongs.
72      */

73     long[] getAllRoleIds();
74
75     /**
76      * Sets the password for this user.
77      *
78      * <p>For security reasons, <b>getPassword</b>
79      * is <b>not</b> provided.
80      */

81     void setPassword(String JavaDoc password);
82
83     /**
84      * Sets this User's e-mail.
85      *
86      * @param emailAddress allowed to be null
87      */

88     void setEmail(String JavaDoc emailAddress);
89
90     /**
91      * Gets the email address of this user, or null if not assigned.
92      */

93     String JavaDoc getEmail();
94
95     /**
96      * Returns the user login.
97      */

98     String JavaDoc getLogin();
99     
100     /**
101      * Sets the user login string.
102      */

103     void setLogin(String JavaDoc loginName);
104
105     /**
106      * Returns the user id.
107      */

108     long getId();
109     
110     /**
111      * Sets the first name of the user (can be null).
112      */

113     void setFirstName(String JavaDoc firstName);
114
115     /**
116      * Sets the last name of the user (can be null).
117      */

118     void setLastName(String JavaDoc lastName);
119
120     /**
121      * Gets the first name of the user, could be null.
122      */

123     String JavaDoc getFirstName();
124
125     /**
126      * Gets the last name of the user, could be null.
127      */

128     String JavaDoc getLastName();
129
130     /**
131      * Returns either the concatenation of firstName and lastName,
132      * if at least one of those has a value, or otherwise the login.
133      */

134     String JavaDoc getDisplayName();
135
136     /**
137      * Persist this User to a data store.
138      */

139     void save() throws RepositoryException;
140     
141     Date JavaDoc getLastModified();
142
143     /**
144      * Gets the user id of the last modifier.
145      */

146     long getLastModifier();
147     
148     //Implement later:
149
//Profile getProfile();
150

151     /**
152      * Gets the XML representation of this object.
153      */

154     UserDocument getXml();
155
156     /**
157      * <b>Clears all roles</b> for this user and <b>sets the default role</b> to <b>null</b>.
158      */

159     void clearRoles();
160
161     /**
162      * Returns true if the user belongs to the specified role.
163      */

164     boolean hasRole(long roleId);
165
166     /**
167      * Returns true if the user to who this user object corresponds
168      * can update this object. This allows the user to change its
169      * login, email, password, etc. but not the roles he/she has.
170      */

171     boolean isUpdateableByUser();
172
173     /**
174      * @see #isUpdateableByUser()
175      */

176     void setUpdateableByUser(boolean updateableByUser);
177
178     boolean isConfirmed();
179
180     void setConfirmed(boolean confirmed);
181
182     String JavaDoc getConfirmKey();
183
184     void setConfirmKey(String JavaDoc confirmKey);
185
186     String JavaDoc getAuthenticationScheme();
187
188     void setAuthenticationScheme(String JavaDoc schemeName);
189
190     long getUpdateCount();
191
192     PublicUserInfoDocument getPublicUserInfo();
193
194 }
195
Popular Tags