001: /**
002: * Copyright (C) 2001 Yasna.com. All rights reserved.
003: *
004: * ===================================================================
005: * The Apache Software License, Version 1.1
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions
009: * are met:
010: *
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The end-user documentation included with the redistribution,
020: * if any, must include the following acknowledgment:
021: * "This product includes software developed by
022: * Yasna.com (http://www.yasna.com)."
023: * Alternately, this acknowledgment may appear in the software itself,
024: * if and wherever such third-party acknowledgments normally appear.
025: *
026: * 4. The names "Yazd" and "Yasna.com" must not be used to
027: * endorse or promote products derived from this software without
028: * prior written permission. For written permission, please
029: * contact yazd@yasna.com.
030: *
031: * 5. Products derived from this software may not be called "Yazd",
032: * nor may "Yazd" appear in their name, without prior written
033: * permission of Yasna.com.
034: *
035: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038: * DISCLAIMED. IN NO EVENT SHALL YASNA.COM OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046: * SUCH DAMAGE.
047: * ====================================================================
048: *
049: * This software consists of voluntary contributions made by many
050: * individuals on behalf of Yasna.com. For more information
051: * on Yasna.com, please see <http://www.yasna.com>.
052: */
053:
054: /**
055: * Copyright (C) 2000 CoolServlets.com. All rights reserved.
056: *
057: * ===================================================================
058: * The Apache Software License, Version 1.1
059: *
060: * Redistribution and use in source and binary forms, with or without
061: * modification, are permitted provided that the following conditions
062: * are met:
063: *
064: * 1. Redistributions of source code must retain the above copyright
065: * notice, this list of conditions and the following disclaimer.
066: *
067: * 2. Redistributions in binary form must reproduce the above copyright
068: * notice, this list of conditions and the following disclaimer in
069: * the documentation and/or other materials provided with the
070: * distribution.
071: *
072: * 3. The end-user documentation included with the redistribution,
073: * if any, must include the following acknowledgment:
074: * "This product includes software developed by
075: * CoolServlets.com (http://www.coolservlets.com)."
076: * Alternately, this acknowledgment may appear in the software itself,
077: * if and wherever such third-party acknowledgments normally appear.
078: *
079: * 4. The names "Jive" and "CoolServlets.com" must not be used to
080: * endorse or promote products derived from this software without
081: * prior written permission. For written permission, please
082: * contact webmaster@coolservlets.com.
083: *
084: * 5. Products derived from this software may not be called "Jive",
085: * nor may "Jive" appear in their name, without prior written
086: * permission of CoolServlets.com.
087: *
088: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
089: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
090: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
091: * DISCLAIMED. IN NO EVENT SHALL COOLSERVLETS.COM OR
092: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
093: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
094: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
095: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
096: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
097: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
098: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
099: * SUCH DAMAGE.
100: * ====================================================================
101: *
102: * This software consists of voluntary contributions made by many
103: * individuals on behalf of CoolServlets.com. For more information
104: * on CoolServlets.com, please see <http://www.coolservlets.com>.
105: */package com.Yasna.forum;
106:
107: import java.util.*;
108:
109: /**
110: * The User interface provides information about and services for users
111: * of the forum system. Users can be identified by a unique id or username.
112: * Users can also be organized into Groups for easier management of
113: * permissions at the forum level.
114: * <p>
115: * The name and email field will normally be required fields when creating
116: * user accounts for most implementations of forums. However, some users may
117: * wish to keep that information private. Therefore, there are two flags to
118: * set if the name and email fields should be made visible to other users. If
119: * the flags are set to deny access, getName() and getEmail() will throw
120: * UnauthorizedExceptions to users that don't have ADMIN permissions.
121: * <p>
122: * Security for User objects is provide by UserProxy protection proxy objects.
123: *
124: * @see Group
125: */
126: public interface User {
127:
128: /**
129: * Returns the user's id. All ids must be unique in the system.
130: *
131: * @return the user's id.
132: */
133: public int getID();
134:
135: /**
136: * Returns true if the User object is an anonymous user object.
137: *
138: * @return true if the user is anonymous.
139: */
140: public boolean isAnonymous();
141:
142: /**
143: * Returns the user's username. All usernames must be unique in the system.
144: *
145: * @return the username of the user.
146: */
147: public String getUsername();
148:
149: /**
150: * Returns the user's name. The user's name does not have to be to be
151: * unique in the system. Some users may opt to not let others see their
152: * name for privacy reasons. In that case, the user can set nameVisible to
153: * false. In that case, a call to this method will return null.
154: *
155: * @return the name of the user.
156: */
157: public String getName();
158:
159: /**
160: * Sets the user's name. The user's name does not have to be to be
161: * unique in the system.
162: *
163: * @param name new name for the user.
164: * @throws UnauthorizedException if does not have ADMIN permissions.
165: */
166: public void setName(String name) throws UnauthorizedException;
167:
168: /**
169: * Returns true if the user has chosen to make her name visible to other
170: * users. If the name is not visible, calling getName() will throw an
171: * UnauthorizedException.
172: *
173: * @return true if the name is visible to other users.
174: */
175: public boolean isNameVisible();
176:
177: /**
178: * Sets whether a user's name is visible to other users. If the field
179: * is set to not be visible, calling getName() will throw an
180: * UnauthorizedException.
181: *
182: * @param visible boolean value to determin if the name should be visible.
183: * @throws UnauthorizedException if does not have ADMIN permissions.
184: */
185: public void setNameVisible(boolean visible)
186: throws UnauthorizedException;
187:
188: /**
189: * Sets the users's password. The password should be passed in as
190: * plain text. The way the password is stored is implementation dependent.
191: * However, it is recommended to at least hash passwords with an
192: * algorithm such as MD5.
193: *
194: * @param password new password for the user.
195: * @throws UnauthorizedException if does not have ADMIN permissions.
196: */
197: public void setPassword(String password)
198: throws UnauthorizedException;
199:
200: /**
201: * Returns the user's password in hashed form. This method is only intended
202: * for system administration functions and can be ignored by skin writers.
203: *
204: * @return the hashed password.
205: * @throws UnauthorizedException if does not have ADMIN permissions.
206: */
207: public String getPasswordHash() throws UnauthorizedException;
208:
209: /**
210: * Sets the user's password in hashed form. This method is only intended
211: * for system administration functions and can be ignored by skin writers.
212: *
213: * @param passwordHash the hashedPassword for the user.
214: * @throws UnauthorizedException if does not have ADMIN permissions.
215: */
216: public void setPasswordHash(String passwordHash)
217: throws UnauthorizedException;
218:
219: /**
220: * Reset's a user's password. This is useful if a user forgets their
221: * password since many implementations will not be able retrieve a
222: * hashed password. The normal side effect of calling this method is
223: * that the new password is emailed to the user using the email address
224: * listed in the account. However, this method could be abused by another
225: * user if they were able to continually reset another users's password.
226: * <p>
227: * A recommendation for implementation of a password resetting system:
228: * provide a form where users can request a password reset because they've
229: * forgotten their password. Making this request sends an email to the
230: * email account listed for the user. That email should include a web
231: * address with a random string for security. If the user visits that
232: * address within 24 hours, the password is reset with a random string
233: * and emailed to the user. If the web page is never visited, the password
234: * is not reset. This method provides good security and prevents abuse
235: * of the password resetting system. This functionality would probably
236: * be incorporated into a forum skin.
237: */
238: //NOTE: This feature will be delayed until after Yazd 1.0
239: //public void resetPassword();
240: /**
241: * Returns the user's email address. Email should be considered to be
242: * a required field of a user account since it is critical to many
243: * user operations performing. If the user sets emailVisible to false,
244: * this method will always return null.
245: *
246: * @return the email address of the user.
247: */
248: public String getEmail();
249:
250: /**
251: * Returns the user's last login date. This date is updated in the DbAuthorizationFactory
252: * after the user successfully is validated.
253: *
254: * @return the last date that user successfully logged in
255: */
256: public Calendar getLastLogin();
257:
258: /**
259: * Returns the date that the user posted his last message.
260: *
261: * @return the last date that user posted his last message
262: */
263: public Calendar getLastPost();
264:
265: /**
266: * Returns the user's preferred locale. This would drive how the Yazd forum would display the buttons
267: * and in which language.
268: * @return
269: */
270: public Locale getUserLocale();
271:
272: /**
273: * This would set the user's perferred locale.
274: * @param locale
275: * @throws UnauthorizedException
276: */
277: public void setUserLocale(Locale locale)
278: throws UnauthorizedException;
279:
280: /**
281: * Returns the user's Time Zone. This would drive how the Yazd forum would display the dates
282: * and in which language. If there is no time zone set by the user, it returns
283: * the default time zone.
284: * @return TimeZone
285: */
286:
287: public TimeZone getUserTimeZone();
288:
289: /**
290: * This would set the user's perferred Time Zone.
291: * @param timezoneid
292: * @throws UnauthorizedException
293: */
294: public void setUserTimeZone(String timezoneid)
295: throws UnauthorizedException;
296:
297: /**
298: * Sets the user's email address. Email should be considered to be
299: * a required field of a user account since it is critical to many
300: * user operations performing.
301: *
302: * @param email new email address for the user.
303: * @throws UnauthorizedException if does not have ADMIN permissions.
304: */
305: public void setEmail(String email) throws UnauthorizedException;
306:
307: /**
308: * Shows if user wants to subscribe to the threads he posts messages in.
309: *
310: * @return true if user wants to receive mail on reply.
311: */
312: public boolean getThreadSubscribe();
313:
314: /**
315: * Boolean value to determin if user wants to
316: * subscribe to the threads that he posts messages in.
317: *
318: * @param emailReply boolean value to determin if user wants to
319: * receive email when a reply on his/her message occur.
320: * @throws UnauthorizedException if does not have ADMIN permissions.
321: */
322: public void setThreadSubscribe(boolean emailReply)
323: throws UnauthorizedException;
324:
325: /**
326: * Returns true if the user has chosen to make her email visible to other
327: * users. If the email field is not visible, calling getEmail() will throw
328: * an UnauthorizedException.
329: *
330: * @return true if the name is visible to other users.
331: */
332: public boolean isEmailVisible();
333:
334: /**
335: * Sets whether a user's email is visible to other users. If the field
336: * is set to not be visible, calling getEmail() will throw an
337: * UnauthorizedException.
338: *
339: * @param visible boolean value to determin if the name should be visible.
340: * @throws UnauthorizedException if does not have ADMIN permissions.
341: */
342: public void setEmailVisible(boolean visible)
343: throws UnauthorizedException;
344:
345: /**
346: * Returns an extended property of the user. Each user can have an
347: * arbitrary number of extended properties. This lets particular skins
348: * or filters provide enhanced functionality that is not part of the base
349: * interface.
350: *
351: * @param name the name of the property to get.
352: * @return the value of the property
353: */
354: public String getProperty(String name);
355:
356: /**
357: * Returns an Enumeration of all the names of the extended user properties.
358: *
359: * @return an Enumeration of the property names.
360: */
361: public Enumeration propertyNames();
362:
363: /**
364: * Sets an extended property of the user. Each user can have an
365: * arbitrary number of extended properties. This lets particular skins
366: * or filters provide enhanced functionality that is not part of the base
367: * interface.
368: *
369: * @param name the name of the property to set.
370: * @param value the new value for the property.
371: */
372: public void setProperty(String name, String value);
373:
374: /**
375: * Returns the permissions for the user that correspond to the
376: * passed-in Authorization.
377: *
378: * @param authorization the auth token to look up permissions with.
379: */
380: public abstract ForumPermissions getPermissions(
381: Authorization authorization);
382:
383: /**
384: * Returns true if the handle on the object has the permission specified.
385: * A list of possible permissions can be found in the ForumPermissions
386: * class. Certain methods of this class are restricted to certain
387: * permissions as specified in the method comments.
388: *
389: * @see ForumPermissions
390: */
391: public boolean hasPermission(int type);
392: }
|