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