KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > client > interfaces > UserHandler


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.ejb.client.interfaces;
20
21 import java.util.HashMap JavaDoc;
22 import javax.ejb.EJBLocalObject JavaDoc;
23
24 import cowsultants.itracker.ejb.client.exceptions.*;
25 import cowsultants.itracker.ejb.client.models.*;
26
27 public interface UserHandler extends EJBLocalObject JavaDoc {
28     public static final String JavaDoc JNDI_NAME = "ejb/UserHandler";
29
30     public UserModel getUser(Integer JavaDoc userId);
31     public UserModel getUserByLogin(String JavaDoc login);
32     public String JavaDoc getUserPasswordByLogin(String JavaDoc login);
33     public UserModel[] getAllUsers();
34     public int getNumberUsers();
35     public UserModel[] getActiveUsers();
36     public UserModel[] getSuperUsers();
37     public UserPreferencesModel getUserPreferencesByUserId(Integer JavaDoc userId);
38
39     public UserModel[] getPossibleOwners(IssueModel issue, Integer JavaDoc projectId, Integer JavaDoc userId);
40
41     public UserModel createUser(UserModel model) throws UserException;
42     public UserModel updateUser(UserModel model) throws UserException;
43     public String JavaDoc generateUserPassword(UserModel model) throws PasswordException;
44     public boolean deleteUser(UserModel model);
45
46     public UserPreferencesModel updateUserPreferences(UserPreferencesModel model) throws UserException;
47
48     public boolean setUserStatus(Integer JavaDoc userId, int status);
49     public boolean clearOwnedProjects(Integer JavaDoc userId);
50
51     /**
52       * This method will call local EJBs to find users with a specific permission.
53       * This method is used by the deafult authenticator to manage permissions locally.
54       * If a pluggable authenticator is implemented that stores permissions in an
55       * external system, calling this method may not have up to date information.
56       * @param permission the permission to search for
57       * @return an array of UserModels containing the users with the permission
58       */

59     public UserModel[] getUsersWithPermissionLocal(PermissionModel permission);
60     /**
61       * This method will call local EJBs to find all permissions for a user.
62       * This method is used by the deafult authenticator to manage permissions locally.
63       * If a pluggable authenticator is implemented that stores permissions in an
64       * external system, calling this method may not have up to date information.
65       * @param user the user to find the permissions for
66       * @return an array of PermissionModels containing the user's permissions
67       */

68     public PermissionModel[] getUserPermissionsLocal(UserModel user);
69
70     /**
71       * Adds an additional set of permissions to a user in the database. This does not remove any existing
72       * permissions. Any duplication permissions will be ignored. Before updating the permissions, this
73       * method will call the pluggable authenticator to have the permission set augmented. This augmented
74       * set of permissions will then be used for the actual update.
75       * @param userId the userId, not login, of the user to add the permissions to
76       * @param newPermissions an array of PermissionModels that represent the new permissions to add to the user
77       * @return true if the operation was successful
78       */

79     public boolean addUserPermissions(Integer JavaDoc userId, PermissionModel[] newPermissions);
80     /**
81       * Resets all of the permissions for a user in the database. The new permissions for the user are contained in a
82       * HashMap object. The keys of this map MUST be in the format Perm<permission type>Prod<productId>. For example to add the
83       * VIEW_ALL permission to project 3, the key would be Perm7Prod3. The value of the key would be a PermissionModel
84       * object. Before updating the permissions, this method will call the pluggable authenticator to have the permission
85       * set augmented. This augmented set of permissions will then be used for the actual update.
86       * @param userId the userId, not login, of the user to add the permissions to
87       * @param newPermissions a HashMap containing keys and PermissionModel values as described in the method description.
88       * @return true if the operation was successful
89       * @see UserUtilities
90       */

91     public boolean setUserPermissions(Integer JavaDoc userId, PermissionModel[] newPermissions);
92
93     /**
94       * Returns an array of PermissionModel objects for the requested userId.
95       * @param userId the userId, not the login, to find the permissions of
96       * @returns an array of PermissionModels
97       */

98     public PermissionModel[] getPermissionsByUserId(Integer JavaDoc userId);
99     /**
100       * Returns a HashMap of all permissions a user has. The HashMap uses the projectId as the key values, and then
101       * contains a HashSet as the value of the key containing Integer objects of the permissions a user has. A special
102       * key of the Integer -1 may also be in the HashMap. This key is used to represet if the user is a super user, and in
103       * which case the user has all permissions be default. The value of this key would be a Boolen object with the value true
104       * if the user was a super user. This HashMap is usually not used directly, but in conjunction with the hasPermission
105       * methods in UserUtilities to determine if a user ahs a particualr permission.
106       * @param model a UserModel representing the user that the permissions should be obtained for
107       * @param reqSource the source of the request
108       * @return a HashMap of permissions as described in the method description
109       * @see UserUtilities#hasPermission
110       */

111     public HashMap JavaDoc getUserPermissions(UserModel model, int reqSource);
112     /**
113       * This method will return a list of users with a specific permission, either explicitly, or
114       * by their role as a super user. This list is obtained calling a method in the pluggable
115       * authenticator, so the actual source of the data may not
116       * be the local datastore.
117       * @param projectId the project to find the permission for
118       * @param permission the permission to check for
119       * @return an array of UserModels that represent the users that have the permission
120       */

121     public UserModel[] getUsersWithProjectPermission(Integer JavaDoc projectId, int permission);
122     /**
123       * This method will return a list of users with a specific permission, either explicitly, or
124       * by their role as a super user. This list is obtained calling a method in the pluggable
125       * authenticator, so the actual source of the data may not
126       * be the local datastore.
127       * @param projectId the project to find the permission for
128       * @param permission the permission to check for
129       * @param activeOnly only include users who are currently active
130       * @return an array of UserModels that represent the users that have the permission
131       */

132     public UserModel[] getUsersWithProjectPermission(Integer JavaDoc projectId, int permission, boolean activeOnly);
133     /**
134       * This method will return a list of users with the supplied permission, either explicitly, or
135       * by their role as a super user. This list is obtained calling a method in the pluggable
136       * authenticator, so the actual source of the data may not be the local datastore.
137       * @param projectId the project to find the permission for
138       * @param permissions the permissions that are checked against
139       * @param requireAll true if all the permissions in the array are required, false if only one is required
140       * @param activeOnly only include users who are currently active
141       * @return an array of UserModels that represent the users that have the permission
142       */

143     public UserModel[] getUsersWithProjectPermission(Integer JavaDoc projectId, int[] permissions, boolean requireAll, boolean activeOnly);
144     /**
145       * This method will return a list of users with any of the supplied permission, either explicitly, or
146       * by their role as a super user. This list is obtained calling a method in the pluggable
147       * authenticator, so the actual source of the data may not
148       * be the local datastore.
149       * @param projectId the project to find the permission for
150       * @param permissions the permissions that are checked against
151       * @return an array of UserModels that represent the users that have the permission
152       */

153     public UserModel[] getUsersWithAnyProjectPermission(Integer JavaDoc projectId, int[] permissions);
154     /**
155       * This method will return a list of users with any of the supplied permission, either explicitly, or
156       * by their role as a super user. This list is obtained calling a method in the pluggable
157       * authenticator, so the actual source of the data may not
158       * be the local datastore.
159       * @param projectId the project to find the permission for
160       * @param permissions the permissions that are checked against
161       * @param activeOnly only include users who are currently active
162       * @return an array of UserModels that represent the users that have the permission
163       */

164     public UserModel[] getUsersWithAnyProjectPermission(Integer JavaDoc projectId, int[] permissions, boolean activeOnly);
165
166     /**
167       * This method checks the login of a user, and returns the user if authentication was successful.
168       * @param login the login the user/client provided
169       * @param authentication the user's authentication information, if known
170       * @param authType the type of authentication information being provided
171       * @param reqSource the source from which the request was made (eg web, api)
172       * @return a UserModel if the login is successful
173       * @throws AuthenticatorException an exception if the login is unsuccessful, or an error occurs
174       */

175     public UserModel checkLogin(String JavaDoc login, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
176
177     /**
178       * This method checks to see if the given user is allowed to self register.
179       * @param user a UserModel object that contains the data the user submitted
180       * @param authentication the user's authentication information, if known
181       * @param authType the type of authentication information being provided
182       * @param reqSource the source from which the request was made (eg web, api)
183       * @return true if the user is allowed to register
184       * @throws AuthenticatorException an exception if an error occurs
185       */

186     public boolean allowRegistration(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
187
188     /**
189       * This method checks to see if a new user profile can be created within ITracker
190       * @param user a UserModel object that contains the data for the new user. If null,
191                then the request is being made for an unknown future user. For example,
192                the system may request this with an null user if it needs to know if the system
193                should even present the option to create a new user
194       * @param authentication the user's authentication information, if known
195       * @param authType the type of authentication information being provided
196       * @param reqSource the source from which the request was made (eg web, api)
197       * @return a boolean indicating whether new user profile can be created through ITracker
198       * @throws AuthenticatorException an exception if an error occurs
199       */

200     public boolean allowProfileCreation(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
201
202     /**
203       * This method checks to see if the given user's core user profile information
204       * can be updated locally.
205       * @param user a UserModel object that contains the data the user submitted
206       * @param authentication the user's authentication information, if known
207       * @param authType the type of authentication information being provided
208       * @param reqSource the source from which the request was made (eg web, api)
209       * @return a boolean whether the user's core profile information can be updated
210       * @throws AuthenticatorException an exception if an error occurs
211       */

212     public boolean allowProfileUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
213
214     /**
215       * This method checks to see if the given user's password can be updated locally.
216       * @param user a UserModel object that contains the data the user submitted
217       * @param authentication the user's authentication information, if known
218       * @param authType the type of authentication information being provided
219       * @param reqSource the source from which the request was made (eg web, api)
220       * @return a boolean whether the user's core profile information can be updated
221       * @throws AuthenticatorException an exception if an error occurs
222       */

223     public boolean allowPasswordUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
224
225     /**
226       * This method checks to see if the given user's permission information
227       * can be updated locally.
228       * @param user a UserModel object that contains the data the user submitted
229       * @param authentication the user's authentication information, if known
230       * @param authType the type of authentication information being provided
231       * @param reqSource the source from which the request was made (eg web, api)
232       * @return a boolean whether the user's core profile information can be updated
233       * @throws AuthenticatorException an exception if an error occurs
234       */

235     public boolean allowPermissionUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
236
237     /**
238       * This method checks to see if the given user's preference information
239       * can be updated locally.
240       * @param user a UserModel object that contains the data the user submitted
241       * @param authentication the user's authentication information, if known
242       * @param authType the type of authentication information being provided
243       * @param reqSource the source from which the request was made (eg web, api)
244       * @return a boolean whether the user's core profile information can be updated
245       * @throws AuthenticatorException an exception if an error occurs
246       */

247     public boolean allowPreferenceUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
248
249     public void sendNotification(String JavaDoc login, String JavaDoc email, String JavaDoc baseURL);
250 }
Popular Tags