KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > security > entity > User


1 package org.apache.fulcrum.security.entity;
2
3 /* ====================================================================
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 2001 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution,
22  * if any, must include the following acknowledgment:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowledgment may appear in the software itself,
26  * if and wherever such third-party acknowledgments normally appear.
27  *
28  * 4. The names "Apache" and "Apache Software Foundation" and
29  * "Apache Turbine" must not be used to endorse or promote products
30  * derived from this software without prior written permission. For
31  * written permission, please contact apache@apache.org.
32  *
33  * 5. Products derived from this software may not be called "Apache",
34  * "Apache Turbine", nor may "Apache" appear in their name, without
35  * prior written permission of the Apache Software Foundation.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals on behalf of the Apache Software Foundation. For more
53  * information on the Apache Software Foundation, please see
54  * <http://www.apache.org/>.
55  */

56
57 import java.util.Hashtable JavaDoc;
58 import java.io.Serializable JavaDoc;
59
60 import org.apache.fulcrum.security.session.SessionBindingListener;
61
62 /**
63  * This interface represents functionality that all users of the
64  * Turbine system require.
65  *
66  * @author <a HREF="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
67  * @author <a HREF="mailto:jmcnally@collab.net">John D. McNally</a>
68  * @author <a HREF="mailto:jon@collab.net">Jon S. Stevens</a>
69  * @author <a HREF="mailto:cberry@gluecode.com">Craig D. Berry</a>
70  * @version $Id: User.java,v 1.1 2004/11/12 10:25:51 epugh Exp $
71  */

72 public interface User
73     extends SessionBindingListener, Serializable JavaDoc, SecurityEntity
74 {
75     /** The 'perm storage' key name for the first name. */
76     public static final String JavaDoc FIRST_NAME = "FIRST_NAME";
77
78     /** The 'perm storage' key name for the last name. */
79     public static final String JavaDoc LAST_NAME = "LAST_NAME";
80
81     /** The 'perm storage' key name for the last_login field. */
82     public static final String JavaDoc LAST_LOGIN = "LAST_LOGIN";
83
84     /** The 'perm storage' key name for the password field. */
85     public static final String JavaDoc PASSWORD = "PASSWORD_VALUE";
86
87     /** The 'perm storage' key name for the username field. */
88     public static final String JavaDoc USERNAME = "LOGIN_NAME";
89
90     /** The 'perm storage' key for the confirm_value field. */
91     public static final String JavaDoc CONFIRM_VALUE = "CONFIRM_VALUE";
92
93     /** The 'perm storage' key for the email field. */
94     public static final String JavaDoc EMAIL = "EMAIL";
95
96     /** This is the value that is stored in the database for confirmed users */
97     public static final String JavaDoc CONFIRM_DATA = "CONFIRMED";
98
99     /** The 'perm storage' key name for the access counter. */
100     public static final String JavaDoc ACCESS_COUNTER = "_access_counter";
101
102     /** The 'temp storage' key name for the session access counter */
103     public static final String JavaDoc SESSION_ACCESS_COUNTER = "_session_access_counter";
104
105     /** The 'temp storage' key name for the 'has logged in' flag */
106     public static final String JavaDoc HAS_LOGGED_IN = "_has_logged_in";
107
108     /** The session key for the User object. */
109     public static final String JavaDoc SESSION_KEY = "turbine.user";
110
111     /**
112      * Gets the access counter for a user from perm storage.
113      *
114      * @return The access counter for the user.
115      */

116     int getAccessCounter();
117
118     /**
119      * Gets the access counter for a user during a session.
120      *
121      * @return The access counter for the user for the session.
122      */

123     int getAccessCounterForSession();
124
125     /**
126      * Gets the last access date for this User. This is the last time
127      * that the user object was referenced.
128      *
129      * @return A Java Date with the last access date for the user.
130      */

131     java.util.Date JavaDoc getLastAccessDate();
132
133     /**
134      * Gets the create date for this User. This is the time at which
135      * the user object was created.
136      *
137      * @return A Java Date with the date of creation for the user.
138      */

139     java.util.Date JavaDoc getCreateDate();
140
141     /**
142      * Returns the user's last login date.
143      *
144      * @return A Java Date with the last login date for the user.
145      */

146     java.util.Date JavaDoc getLastLogin();
147
148     /**
149      * Returns the user's password. This method should not be used by
150      * the application directly, because it's meaning depends upon
151      * the implementation of UserManager that manages this particular
152      * user object. Some implementations will use this attribute for
153      * storing a password encrypted in some way, other will not use
154      * it at all, when user entered password is presented to some external
155      * authority (like NT domain controller) to validate it.
156      * See also {@link org.apache.fulcrum.security.UserManager#authenticate(User,String)}.
157      *
158      * @return A String with the password for the user.
159      */

160     String JavaDoc getPassword();
161
162     /**
163      * Get an object from permanent storage.
164      *
165      * @param name The object's name.
166      * @return An Object with the given name.
167      */

168     Object JavaDoc getPerm(String JavaDoc name);
169
170     /**
171      * Get an object from permanent storage; return default if value
172      * is null.
173      *
174      * @param name The object's name.
175      * @param def A default value to return.
176      * @return An Object with the given name.
177      */

178     Object JavaDoc getPerm(String JavaDoc name, Object JavaDoc def);
179
180     /**
181      * This should only be used in the case where we want to save the
182      * data to the database.
183      *
184      * @return A Hashtable.
185      */

186     Hashtable JavaDoc getPermStorage();
187
188     /**
189      * This should only be used in the case where we want to save the
190      * data to the database.
191      *
192      * @return A Hashtable.
193      */

194     Hashtable JavaDoc getTempStorage();
195
196     /**
197      * Get an object from temporary storage.
198      *
199      * @param name The object's name.
200      * @return An Object with the given name.
201      */

202     Object JavaDoc getTemp(String JavaDoc name);
203
204     /**
205      * Get an object from temporary storage; return default if value
206      * is null.
207      *
208      * @param name The object's name.
209      * @param def A default value to return.
210      * @return An Object with the given name.
211      */

212     Object JavaDoc getTemp(String JavaDoc name, Object JavaDoc def);
213
214     /**
215      * Returns the username for this user.
216      *
217      * @return A String with the username.
218      */

219     String JavaDoc getUserName();
220
221     /**
222      * Returns the first name for this user.
223      *
224      * @return A String with the user's first name.
225      */

226
227     String JavaDoc getFirstName();
228
229     /**
230      * Returns the last name for this user.
231      *
232      * @return A String with the user's last name.
233      */

234     String JavaDoc getLastName();
235
236     /**
237      * Returns the email address for this user.
238      *
239      * @return A String with the user's email address.
240      */

241     String JavaDoc getEmail();
242
243     /**
244      * This sets whether or not someone has logged in. hasLoggedIn()
245      * returns this value.
246      *
247      * @param value Whether someone has logged in or not.
248      */

249     void setHasLoggedIn(Boolean JavaDoc value);
250
251     /**
252      * The user is considered logged in if they have not timed out.
253      *
254      * @return True if the user has logged in.
255      */

256     boolean hasLoggedIn();
257
258     /**
259      * Increments the permanent hit counter for the user.
260      */

261     void incrementAccessCounter();
262
263     /**
264      * Increments the session hit counter for the user.
265      */

266     void incrementAccessCounterForSession();
267
268     /**
269      * Remove an object from temporary storage and return the object.
270      *
271      * @param name The name of the object to remove.
272      * @return An Object.
273      */

274     Object JavaDoc removeTemp(String JavaDoc name);
275
276     /**
277      * Sets the access counter for a user, saved in perm storage.
278      *
279      * @param cnt The new count.
280      */

281     void setAccessCounter(int cnt);
282
283     /**
284      * Sets the session access counter for a user, saved in temp
285      * storage.
286      *
287      * @param cnt The new count.
288      */

289     void setAccessCounterForSession(int cnt);
290
291     /**
292      * Sets the last access date for this User. This is the last time
293      * that the user object was referenced.
294      */

295     void setLastAccessDate();
296
297     /**
298      * Set last login date/time.
299      *
300      * @param lastLogin The last login date.
301      */

302     void setLastLogin(java.util.Date JavaDoc lastLogin);
303
304     /**
305      * Set password. Application should not use this method
306      * directly, see {@link #getPassword()}.
307      * See also {@link org.apache.fulcrum.security.UserManager#changePassword(User,String,String)}.
308      *
309      * @param password The new password.
310      */

311
312     void setPassword(String JavaDoc password);
313
314     /**
315      * Put an object into permanent storage.
316      *
317      * @param name The object's name.
318      * @param value The object.
319      */

320     void setPerm(String JavaDoc name,
321                  Object JavaDoc value);
322
323     /**
324      * This should only be used in the case where we want to save the
325      * data to the database.
326      *
327      * @param storage A Hashtable.
328      */

329     void setPermStorage(Hashtable JavaDoc storage);
330
331     /**
332      * This should only be used in the case where we want to save the
333      * data to the database.
334      *
335      * @param storage A Hashtable.
336      */

337     void setTempStorage(Hashtable JavaDoc storage);
338
339     /**
340      * Put an object into temporary storage.
341      *
342      * @param name The object's name.
343      * @param value The object.
344      */

345     void setTemp(String JavaDoc name, Object JavaDoc value);
346
347     /**
348      * Sets the username for this user.
349      *
350      * @param username The user's username.
351      */

352     void setUserName(String JavaDoc username);
353
354     /**
355      * Sets the first name for this user.
356      *
357      * @param firstName User's first name.
358      */

359     void setFirstName(String JavaDoc firstName);
360
361     /**
362      * Sets the last name for this user.
363      *
364      * @param lastName User's last name.
365      */

366     void setLastName(String JavaDoc lastName);
367
368     /**
369      * Sets the creation date for this user.
370      *
371      * @param date Creation date
372      */

373     void setCreateDate(java.util.Date JavaDoc date);
374
375     /**
376      * Sets the email address.
377      *
378      * @param address The email address.
379      */

380     void setEmail(String JavaDoc address);
381
382     /**
383      * This method reports whether or not the user has been confirmed
384      * in the system by checking the TurbineUserPeer.CONFIRM_VALUE
385      * column to see if it is equal to CONFIRM_DATA.
386      *
387      * @return True if the user has been confirmed.
388      */

389     boolean isConfirmed();
390
391     /**
392      * Sets the confirmation value.
393      *
394      * @param value The confirmation key value.
395      */

396     void setConfirmed(String JavaDoc value);
397
398     /**
399      * Gets the confirmation value.
400      *
401      * @return The confirmed value
402      */

403     String JavaDoc getConfirmed();
404
405     /**
406      * Updates the last login date in the database.
407      *
408      * @exception Exception A generic exception.
409      */

410     void updateLastLogin()
411         throws Exception JavaDoc;
412 }
413
Popular Tags