KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > User


1 /*
2  * NEMESIS-FORUM.
3  * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  *
7  * Copyright (C) 2001 Yasna.com. All rights reserved.
8  *
9  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10  *
11  * NEMESIS-FORUM. is free software; you can redistribute it and/or
12  * modify it under the terms of the Apache Software License, Version 1.1,
13  * or (at your option) any later version.
14  *
15  * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16  * application are parts of NEMESIS-FORUM and are distributed under
17  * same terms of licence.
18  *
19  *
20  * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21  * and software developed by CoolServlets.com (http://www.coolservlets.com).
22  * and software developed by Yasna.com (http://www.yasna.com).
23  *
24  */

25 package org.nemesis.forum;
26
27 import java.util.Enumeration JavaDoc;
28
29 import org.nemesis.forum.exception.UnauthorizedException;
30
31 /**
32  * The User interface provides information about and services for users
33  * of the forum system. Users can be identified by a unique id or username.
34  * Users can also be organized into Groups for easier management of
35  * permissions at the forum level.
36  * <p>
37  * The name and email field will normally be required fields when creating
38  * user accounts for most implementations of forums. However, some users may
39  * wish to keep that information private. Therefore, there are two flags to
40  * set if the name and email fields should be made visible to other users. If
41  * the flags are set to deny access, getName() and getEmail() will throw
42  * UnauthorizedExceptions to users that don't have ADMIN permissions.
43  * <p>
44  * Security for User objects is provide by UserProxy protection proxy objects.
45  *
46  * @see Group
47  */

48 public interface User {
49
50     /**
51      * Returns the user's id. All ids must be unique in the system.
52      *
53      * @return the user's id.
54      */

55     public int getID();
56
57     /**
58      * Returns true if the User object is an anonymous user object.
59      *
60      * @return true if the user is anonymous.
61      */

62     public boolean isAnonymous();
63
64     /**
65      * Returns the user's username. All usernames must be unique in the system.
66      *
67      * @return the username of the user.
68      */

69     public String JavaDoc getUsername();
70
71     /**
72      * Returns the user's name. The user's name does not have to be to be
73      * unique in the system. Some users may opt to not let others see their
74      * name for privacy reasons. In that case, the user can set nameVisible to
75      * false. In that case, a call to this method will return null.
76      *
77      * @return the name of the user.
78      */

79     public String JavaDoc getName();
80
81     /**
82      * Sets the user's name. The user's name does not have to be to be
83      * unique in the system.
84      *
85      * @param name new name for the user.
86      * @throws UnauthorizedException if does not have ADMIN permissions.
87      */

88     public void setName(String JavaDoc name) throws UnauthorizedException;
89
90     /**
91      * Returns true if the user has chosen to make her name visible to other
92      * users. If the name is not visible, calling getName() will throw an
93      * UnauthorizedException.
94      *
95      * @return true if the name is visible to other users.
96      */

97     public boolean isNameVisible();
98
99     /**
100      * Sets whether a user's name is visible to other users. If the field
101      * is set to not be visible, calling getName() will throw an
102      * UnauthorizedException.
103      *
104      * @param visible boolean value to determin if the name should be visible.
105      * @throws UnauthorizedException if does not have ADMIN permissions.
106      */

107     public void setNameVisible(boolean visible) throws UnauthorizedException;
108
109     /**
110      * Sets the users's password. The password should be passed in as
111      * plain text. The way the password is stored is implementation dependent.
112      * However, it is recommended to at least hash passwords with an
113      * algorithm such as MD5.
114      *
115      * @param password new password for the user.
116      * @throws UnauthorizedException if does not have ADMIN permissions.
117      */

118     public void setPassword(String JavaDoc password) throws UnauthorizedException;
119
120     /**
121      * Returns the user's password in hashed form. This method is only intended
122      * for system administration functions and can be ignored by skin writers.
123      *
124      * @return the hashed password.
125      * @throws UnauthorizedException if does not have ADMIN permissions.
126      */

127     public String JavaDoc getPasswordHash() throws UnauthorizedException;
128
129     /**
130      * Sets the user's password in hashed form. This method is only intended
131      * for system administration functions and can be ignored by skin writers.
132      *
133      * @param hashedPassword the hashedPassword for the user.
134      * @throws UnauthorizedException if does not have ADMIN permissions.
135      */

136     public void setPasswordHash(String JavaDoc passwordHash) throws UnauthorizedException;
137
138     /**
139      * Reset's a user's password. This is useful if a user forgets their
140      * password since many implementations will not be able retrieve a
141      * hashed password. The normal side effect of calling this method is
142      * that the new password is emailed to the user using the email address
143      * listed in the account. However, this method could be abused by another
144      * user if they were able to continually reset another users's password.
145      * <p>
146      * A recommendation for implementation of a password resetting system:
147      * provide a form where users can request a password reset because they've
148      * forgotten their password. Making this request sends an email to the
149      * email account listed for the user. That email should include a web
150      * address with a random string for security. If the user visits that
151      * address within 24 hours, the password is reset with a random string
152      * and emailed to the user. If the web page is never visited, the password
153      * is not reset. This method provides good security and prevents abuse
154      * of the password resetting system. This functionality would probably
155      * be incorporated into a forum skin.
156      */

157     
158     //public void resetPassword();
159
// :TODO:resetPassword
160

161     /**
162      * Returns the user's email address. Email should be considered to be
163      * a required field of a user account since it is critical to many
164      * user operations performing. If the user sets emailVisible to false,
165      * this method will always return null.
166      *
167      * @return the email address of the user.
168      */

169     public String JavaDoc getEmail();
170
171     /**
172      * Sets the user's email address. Email should be considered to be
173      * a required field of a user account since it is critical to many
174      * user operations performing.
175      *
176      * @param email new email address for the user.
177      * @throws UnauthorizedException if does not have ADMIN permissions.
178      */

179     public void setEmail(String JavaDoc email) throws UnauthorizedException;
180
181     /**
182      * Returns true if the user has chosen to make her email visible to other
183      * users. If the email field is not visible, calling getEmail() will throw
184      * an UnauthorizedException.
185      *
186      * @return true if the name is visible to other users.
187      */

188     public boolean isEmailVisible();
189
190     /**
191      * Sets whether a user's email is visible to other users. If the field
192      * is set to not be visible, calling getEmail() will throw an
193      * UnauthorizedException.
194      *
195      * @param visible boolean value to determin if the name should be visible.
196      * @throws UnauthorizedException if does not have ADMIN permissions.
197      */

198     public void setEmailVisible(boolean visible) throws UnauthorizedException;
199
200     /**
201      * Returns an extended property of the user. Each user can have an
202      * arbitrary number of extended properties. This lets particular skins
203      * or filters provide enhanced functionality that is not part of the base
204      * interface.
205      *
206      * @param name the name of the property to get.
207      * @return the value of the property
208      */

209     public String JavaDoc getProperty(String JavaDoc name);
210
211     /**
212      * Returns an Enumeration of all the names of the extended user properties.
213      *
214      * @return an Enumeration of the property names.
215      */

216     public Enumeration JavaDoc propertyNames();
217
218     /**
219      * Sets an extended property of the user. Each user can have an
220      * arbitrary number of extended properties. This lets particular skins
221      * or filters provide enhanced functionality that is not part of the base
222      * interface.
223      *
224      * @param name the name of the property to set.
225      * @param value the new value for the property.
226      */

227     public void setProperty(String JavaDoc name, String JavaDoc value);
228
229     /**
230      * Returns the permissions for the user that correspond to the
231      * passed-in Authorization.
232      *
233      * @param authorization the auth token to look up permissions with.
234      */

235     public abstract ForumPermissions getPermissions(Authorization authorization);
236
237     /**
238      * Returns true if the handle on the object has the permission specified.
239      * A list of possible permissions can be found in the ForumPermissions
240      * class. Certain methods of this class are restricted to certain
241      * permissions as specified in the method comments.
242      *
243      * @see ForumPermissions
244      */

245     public boolean hasPermission(int type);
246
247     //*****AJOUT
248
/**
249      * Returns true if the User is group administrator .
250      *
251      * @return true if the User is an administrator of the group.
252      */

253     public boolean isAdministratorInGroup(Group group);
254
255     /**
256      * Returns true if if the User is a member of the group.
257      *
258      * @return true if the User is a member of the group.
259      */

260     public boolean isMemberInGroup(Group group);
261
262     /**
263      * Returns the number of group where the user is administrator.
264      *
265      * @return the number of group where the user is administrator.
266      */

267     public int getGroupAdministratorCount();
268
269     /**
270      * Returns the number of group where the user is member.
271      *
272      * @return the number of group where the user is member.
273      */

274     public int getGroupCount();
275
276 }
277
Popular Tags