001: package org.apache.turbine.om.security;
002:
003: /*
004: * Copyright 2001-2005 The Apache Software Foundation.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License")
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.io.Serializable;
020:
021: import java.util.Hashtable;
022:
023: import javax.servlet.http.HttpSessionBindingListener;
024:
025: /**
026: * This interface represents functionality that all users of the
027: * Turbine system require.
028: *
029: * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
030: * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
031: * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
032: * @author <a href="mailto:cberry@gluecode.com">Craig D. Berry</a>
033: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
034: * @version $Id: User.java 264148 2005-08-29 14:21:04Z henning $
035: */
036: public interface User extends HttpSessionBindingListener, Serializable,
037: SecurityEntity {
038: /** The 'perm storage' key name for the first name. */
039: String FIRST_NAME = "FIRST_NAME";
040:
041: /** The 'perm storage' key name for the last name. */
042: String LAST_NAME = "LAST_NAME";
043:
044: /** The 'perm storage' key name for the last_login field. */
045: String LAST_LOGIN = "LAST_LOGIN";
046:
047: /** The 'perm storage' key name for the password field. */
048: String PASSWORD = "PASSWORD_VALUE";
049:
050: /** The 'perm storage' key name for the username field. */
051: String USERNAME = "LOGIN_NAME";
052:
053: /** The 'perm storage' key for the confirm_value field. */
054: String CONFIRM_VALUE = "CONFIRM_VALUE";
055:
056: /** The 'perm storage' key for the email field. */
057: String EMAIL = "EMAIL";
058:
059: /** This is the value that is stored in the database for confirmed users */
060: String CONFIRM_DATA = "CONFIRMED";
061:
062: /** The 'perm storage' key name for the access counter. */
063: String ACCESS_COUNTER = "_access_counter";
064:
065: /** The 'temp storage' key name for the session access counter */
066: String SESSION_ACCESS_COUNTER = "_session_access_counter";
067:
068: /** The 'temp storage' key name for the 'has logged in' flag */
069: String HAS_LOGGED_IN = "_has_logged_in";
070:
071: /** The session key for the User object. */
072: String SESSION_KEY = "turbine.user";
073:
074: /**
075: * Gets the access counter for a user from perm storage.
076: *
077: * @return The access counter for the user.
078: */
079: int getAccessCounter();
080:
081: /**
082: * Gets the access counter for a user during a session.
083: *
084: * @return The access counter for the user for the session.
085: */
086: int getAccessCounterForSession();
087:
088: /**
089: * Gets the last access date for this User. This is the last time
090: * that the user object was referenced.
091: *
092: * @return A Java Date with the last access date for the user.
093: */
094: java.util.Date getLastAccessDate();
095:
096: /**
097: * Gets the create date for this User. This is the time at which
098: * the user object was created.
099: *
100: * @return A Java Date with the date of creation for the user.
101: */
102: java.util.Date getCreateDate();
103:
104: /**
105: * Returns the user's last login date.
106: *
107: * @return A Java Date with the last login date for the user.
108: */
109: java.util.Date getLastLogin();
110:
111: /**
112: * Returns the user's password. This method should not be used by
113: * the application directly, because it's meaning depends upon
114: * the implementation of UserManager that manages this particular
115: * user object. Some implementations will use this attribute for
116: * storing a password encrypted in some way, other will not use
117: * it at all, when user entered password is presented to some external
118: * authority (like NT domain controller) to validate it.
119: * See also {@link org.apache.turbine.services.security.UserManager#authenticate(User,String)}.
120: *
121: * @return A String with the password for the user.
122: */
123: String getPassword();
124:
125: /**
126: * Get an object from permanent storage.
127: *
128: * @param name The object's name.
129: * @return An Object with the given name.
130: */
131: Object getPerm(String name);
132:
133: /**
134: * Get an object from permanent storage; return default if value
135: * is null.
136: *
137: * @param name The object's name.
138: * @param def A default value to return.
139: * @return An Object with the given name.
140: */
141: Object getPerm(String name, Object def);
142:
143: /**
144: * This should only be used in the case where we want to save the
145: * data to the database.
146: *
147: * @return A Hashtable.
148: */
149: Hashtable getPermStorage();
150:
151: /**
152: * This should only be used in the case where we want to save the
153: * data to the database.
154: *
155: * @return A Hashtable.
156: */
157: Hashtable getTempStorage();
158:
159: /**
160: * Get an object from temporary storage.
161: *
162: * @param name The object's name.
163: * @return An Object with the given name.
164: */
165: Object getTemp(String name);
166:
167: /**
168: * Get an object from temporary storage; return default if value
169: * is null.
170: *
171: * @param name The object's name.
172: * @param def A default value to return.
173: * @return An Object with the given name.
174: */
175: Object getTemp(String name, Object def);
176:
177: /**
178: * Returns the username for this user.
179: *
180: * @return A String with the username.
181: *
182: * @deprecated This is the same as getName(), so use this.
183: */
184: String getUserName();
185:
186: /**
187: * Returns the first name for this user.
188: *
189: * @return A String with the user's first name.
190: */
191:
192: String getFirstName();
193:
194: /**
195: * Returns the last name for this user.
196: *
197: * @return A String with the user's last name.
198: */
199: String getLastName();
200:
201: /**
202: * Returns the email address for this user.
203: *
204: * @return A String with the user's email address.
205: */
206: String getEmail();
207:
208: /**
209: * This sets whether or not someone has logged in. hasLoggedIn()
210: * returns this value.
211: *
212: * @param value Whether someone has logged in or not.
213: */
214: void setHasLoggedIn(Boolean value);
215:
216: /**
217: * The user is considered logged in if they have not timed out.
218: *
219: * @return True if the user has logged in.
220: */
221: boolean hasLoggedIn();
222:
223: /**
224: * Increments the permanent hit counter for the user.
225: */
226: void incrementAccessCounter();
227:
228: /**
229: * Increments the session hit counter for the user.
230: */
231: void incrementAccessCounterForSession();
232:
233: /**
234: * Remove an object from temporary storage and return the object.
235: *
236: * @param name The name of the object to remove.
237: * @return An Object.
238: */
239: Object removeTemp(String name);
240:
241: /**
242: * Sets the access counter for a user, saved in perm storage.
243: *
244: * @param cnt The new count.
245: */
246: void setAccessCounter(int cnt);
247:
248: /**
249: * Sets the session access counter for a user, saved in temp
250: * storage.
251: *
252: * @param cnt The new count.
253: */
254: void setAccessCounterForSession(int cnt);
255:
256: /**
257: * Sets the last access date for this User. This is the last time
258: * that the user object was referenced.
259: */
260: void setLastAccessDate();
261:
262: /**
263: * Set last login date/time.
264: *
265: * @param lastLogin The last login date.
266: */
267: void setLastLogin(java.util.Date lastLogin);
268:
269: /**
270: * Set password. Application should not use this method
271: * directly, see {@link #getPassword()}.
272: * See also {@link org.apache.turbine.services.security.UserManager#changePassword(User,String,String)}.
273: *
274: * @param password The new password.
275: */
276:
277: void setPassword(String password);
278:
279: /**
280: * Put an object into permanent storage.
281: *
282: * @param name The object's name.
283: * @param value The object.
284: */
285: void setPerm(String name, Object value);
286:
287: /**
288: * This should only be used in the case where we want to save the
289: * data to the database.
290: *
291: * @param storage A Hashtable.
292: */
293: void setPermStorage(Hashtable storage);
294:
295: /**
296: * This should only be used in the case where we want to save the
297: * data to the database.
298: *
299: * @param storage A Hashtable.
300: */
301: void setTempStorage(Hashtable storage);
302:
303: /**
304: * Put an object into temporary storage.
305: *
306: * @param name The object's name.
307: * @param value The object.
308: */
309: void setTemp(String name, Object value);
310:
311: /**
312: * Sets the username for this user.
313: *
314: * @param username The user's username.
315: *
316: * @deprecated This is the same as setName(), so use this.
317: */
318: void setUserName(String username);
319:
320: /**
321: * Sets the first name for this user.
322: *
323: * @param firstName User's first name.
324: */
325: void setFirstName(String firstName);
326:
327: /**
328: * Sets the last name for this user.
329: *
330: * @param lastName User's last name.
331: */
332: void setLastName(String lastName);
333:
334: /**
335: * Sets the creation date for this user.
336: *
337: * @param date Creation date
338: */
339: void setCreateDate(java.util.Date date);
340:
341: /**
342: * Sets the email address.
343: *
344: * @param address The email address.
345: */
346: void setEmail(String address);
347:
348: /**
349: * This method reports whether or not the user has been confirmed
350: * in the system by checking the TurbineUserPeer.CONFIRM_VALUE
351: * column to see if it is equal to CONFIRM_DATA.
352: *
353: * @return True if the user has been confirmed.
354: */
355: boolean isConfirmed();
356:
357: /**
358: * Sets the confirmation value.
359: *
360: * @param value The confirmation key value.
361: */
362: void setConfirmed(String value);
363:
364: /**
365: * Gets the confirmation value.
366: *
367: * @return The confirmed value
368: */
369: String getConfirmed();
370:
371: /**
372: * Updates the last login date in the database.
373: *
374: * @exception Exception A generic exception.
375: */
376: void updateLastLogin() throws Exception;
377: }
|