1 package org.apache.turbine.om.security;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.Serializable;
23
24 import java.util.Hashtable;
25
26 import javax.servlet.http.HttpSessionBindingListener;
27
28 /***
29 * This interface represents functionality that all users of the
30 * Turbine system require.
31 *
32 * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
33 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
34 * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
35 * @author <a href="mailto:cberry@gluecode.com">Craig D. Berry</a>
36 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
37 * @version $Id: User.java 534527 2007-05-02 16:10:59Z tv $
38 */
39 public interface User
40 extends HttpSessionBindingListener, Serializable, SecurityEntity
41 {
42 /*** The 'perm storage' key name for the first name. */
43 String FIRST_NAME = "FIRST_NAME";
44
45 /*** The 'perm storage' key name for the last name. */
46 String LAST_NAME = "LAST_NAME";
47
48 /*** The 'perm storage' key name for the last_login field. */
49 String LAST_LOGIN = "LAST_LOGIN";
50
51 /*** The 'perm storage' key name for the password field. */
52 String PASSWORD = "PASSWORD_VALUE";
53
54 /*** The 'perm storage' key name for the username field. */
55 String USERNAME = "LOGIN_NAME";
56
57 /*** The 'perm storage' key for the confirm_value field. */
58 String CONFIRM_VALUE = "CONFIRM_VALUE";
59
60 /*** The 'perm storage' key for the email field. */
61 String EMAIL = "EMAIL";
62
63 /*** This is the value that is stored in the database for confirmed users */
64 String CONFIRM_DATA = "CONFIRMED";
65
66 /*** The 'perm storage' key name for the access counter. */
67 String ACCESS_COUNTER = "_access_counter";
68
69 /*** The 'temp storage' key name for the session access counter */
70 String SESSION_ACCESS_COUNTER = "_session_access_counter";
71
72 /*** The 'temp storage' key name for the 'has logged in' flag */
73 String HAS_LOGGED_IN = "_has_logged_in";
74
75 /*** The session key for the User object. */
76 String SESSION_KEY = "turbine.user";
77
78 /***
79 * Gets the access counter for a user from perm storage.
80 *
81 * @return The access counter for the user.
82 */
83 int getAccessCounter();
84
85 /***
86 * Gets the access counter for a user during a session.
87 *
88 * @return The access counter for the user for the session.
89 */
90 int getAccessCounterForSession();
91
92 /***
93 * Gets the last access date for this User. This is the last time
94 * that the user object was referenced.
95 *
96 * @return A Java Date with the last access date for the user.
97 */
98 java.util.Date getLastAccessDate();
99
100 /***
101 * Gets the create date for this User. This is the time at which
102 * the user object was created.
103 *
104 * @return A Java Date with the date of creation for the user.
105 */
106 java.util.Date getCreateDate();
107
108 /***
109 * Returns the user's last login date.
110 *
111 * @return A Java Date with the last login date for the user.
112 */
113 java.util.Date getLastLogin();
114
115 /***
116 * Returns the user's password. This method should not be used by
117 * the application directly, because it's meaning depends upon
118 * the implementation of UserManager that manages this particular
119 * user object. Some implementations will use this attribute for
120 * storing a password encrypted in some way, other will not use
121 * it at all, when user entered password is presented to some external
122 * authority (like NT domain controller) to validate it.
123 * See also {@link org.apache.turbine.services.security.UserManager#authenticate(User,String)}.
124 *
125 * @return A String with the password for the user.
126 */
127 String getPassword();
128
129 /***
130 * Get an object from permanent storage.
131 *
132 * @param name The object's name.
133 * @return An Object with the given name.
134 */
135 Object getPerm(String name);
136
137 /***
138 * Get an object from permanent storage; return default if value
139 * is null.
140 *
141 * @param name The object's name.
142 * @param def A default value to return.
143 * @return An Object with the given name.
144 */
145 Object getPerm(String name, Object def);
146
147 /***
148 * This should only be used in the case where we want to save the
149 * data to the database.
150 *
151 * @return A Hashtable.
152 */
153 Hashtable getPermStorage();
154
155 /***
156 * This should only be used in the case where we want to save the
157 * data to the database.
158 *
159 * @return A Hashtable.
160 */
161 Hashtable getTempStorage();
162
163 /***
164 * Get an object from temporary storage.
165 *
166 * @param name The object's name.
167 * @return An Object with the given name.
168 */
169 Object getTemp(String name);
170
171 /***
172 * Get an object from temporary storage; return default if value
173 * is null.
174 *
175 * @param name The object's name.
176 * @param def A default value to return.
177 * @return An Object with the given name.
178 */
179 Object getTemp(String name, Object def);
180
181 /***
182 * Returns the username for this user.
183 *
184 * @return A String with the username.
185 *
186 * @deprecated This is the same as getName(), so use this.
187 */
188 String getUserName();
189
190 /***
191 * Returns the first name for this user.
192 *
193 * @return A String with the user's first name.
194 */
195
196 String getFirstName();
197
198 /***
199 * Returns the last name for this user.
200 *
201 * @return A String with the user's last name.
202 */
203 String getLastName();
204
205 /***
206 * Returns the email address for this user.
207 *
208 * @return A String with the user's email address.
209 */
210 String getEmail();
211
212 /***
213 * This sets whether or not someone has logged in. hasLoggedIn()
214 * returns this value.
215 *
216 * @param value Whether someone has logged in or not.
217 */
218 void setHasLoggedIn(Boolean value);
219
220 /***
221 * The user is considered logged in if they have not timed out.
222 *
223 * @return True if the user has logged in.
224 */
225 boolean hasLoggedIn();
226
227 /***
228 * Increments the permanent hit counter for the user.
229 */
230 void incrementAccessCounter();
231
232 /***
233 * Increments the session hit counter for the user.
234 */
235 void incrementAccessCounterForSession();
236
237 /***
238 * Remove an object from temporary storage and return the object.
239 *
240 * @param name The name of the object to remove.
241 * @return An Object.
242 */
243 Object removeTemp(String name);
244
245 /***
246 * Sets the access counter for a user, saved in perm storage.
247 *
248 * @param cnt The new count.
249 */
250 void setAccessCounter(int cnt);
251
252 /***
253 * Sets the session access counter for a user, saved in temp
254 * storage.
255 *
256 * @param cnt The new count.
257 */
258 void setAccessCounterForSession(int cnt);
259
260 /***
261 * Sets the last access date for this User. This is the last time
262 * that the user object was referenced.
263 */
264 void setLastAccessDate();
265
266 /***
267 * Set last login date/time.
268 *
269 * @param lastLogin The last login date.
270 */
271 void setLastLogin(java.util.Date lastLogin);
272
273 /***
274 * Set password. Application should not use this method
275 * directly, see {@link #getPassword()}.
276 * See also {@link org.apache.turbine.services.security.UserManager#changePassword(User,String,String)}.
277 *
278 * @param password The new password.
279 */
280
281 void setPassword(String password);
282
283 /***
284 * Put an object into permanent storage.
285 *
286 * @param name The object's name.
287 * @param value The object.
288 */
289 void setPerm(String name,
290 Object value);
291
292 /***
293 * This should only be used in the case where we want to save the
294 * data to the database.
295 *
296 * @param storage A Hashtable.
297 */
298 void setPermStorage(Hashtable storage);
299
300 /***
301 * This should only be used in the case where we want to save the
302 * data to the database.
303 *
304 * @param storage A Hashtable.
305 */
306 void setTempStorage(Hashtable storage);
307
308 /***
309 * Put an object into temporary storage.
310 *
311 * @param name The object's name.
312 * @param value The object.
313 */
314 void setTemp(String name, Object value);
315
316 /***
317 * Sets the username for this user.
318 *
319 * @param username The user's username.
320 *
321 * @deprecated This is the same as setName(), so use this.
322 */
323 void setUserName(String username);
324
325 /***
326 * Sets the first name for this user.
327 *
328 * @param firstName User's first name.
329 */
330 void setFirstName(String firstName);
331
332 /***
333 * Sets the last name for this user.
334 *
335 * @param lastName User's last name.
336 */
337 void setLastName(String lastName);
338
339 /***
340 * Sets the creation date for this user.
341 *
342 * @param date Creation date
343 */
344 void setCreateDate(java.util.Date date);
345
346 /***
347 * Sets the email address.
348 *
349 * @param address The email address.
350 */
351 void setEmail(String address);
352
353 /***
354 * This method reports whether or not the user has been confirmed
355 * in the system by checking the TurbineUserPeer.CONFIRM_VALUE
356 * column to see if it is equal to CONFIRM_DATA.
357 *
358 * @return True if the user has been confirmed.
359 */
360 boolean isConfirmed();
361
362 /***
363 * Sets the confirmation value.
364 *
365 * @param value The confirmation key value.
366 */
367 void setConfirmed(String value);
368
369 /***
370 * Gets the confirmation value.
371 *
372 * @return The confirmed value
373 */
374 String getConfirmed();
375
376 /***
377 * Updates the last login date in the database.
378 *
379 * @exception Exception A generic exception.
380 */
381 void updateLastLogin()
382 throws Exception;
383 }