KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > authentication > PluggableAuthenticator


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.authentication;
20
21 import java.rmi.*;
22 import java.rmi.server.*;
23 import java.util.*;
24 import javax.ejb.*;
25
26 import cowsultants.itracker.ejb.client.exceptions.*;
27 import cowsultants.itracker.ejb.client.interfaces.*;
28 import cowsultants.itracker.ejb.client.models.*;
29 import cowsultants.itracker.ejb.client.util.*;
30
31 /**
32   * This interface should be implemented to provide a new authentication module for
33   * ITracker. It provides service to check if a user can be authenticated
34   * during a login, and also whether a user self registration is allowed. A new
35   * instance of this object is created for each check.
36   * @see AuthenticationConstants
37   */

38 public interface PluggableAuthenticator {
39
40     /**
41       * This method should be implemented to determine if a user login is successful. The method
42       * should return a valid UserModel object.
43       * @param login the login the user/client provided
44       * @param authentication the user's authentication information, if known
45       * @param authType the type of authentication information being provided
46       * @param reqSource the source of the request (eg web, api)
47       * @return a UserModel if the login is successful
48       * @throws AuthenticatorException an exception if the login is unsuccessful, or an error occurs
49       */

50     public UserModel checkLogin(String JavaDoc login, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
51
52     /**
53       * This method should return all the permissions a user has in the authentication system. This
54       * list may then be augmented based on other attributes of the user, or project level options.
55       * @param user a UserModel object that contains the user to retrieve permissions for
56       * @param reqSource the source of the request (eg web, api)
57       * @return an array of PermissionModels
58       * @throws AuthenticatorException an error occurs
59       */

60     public PermissionModel[] getUserPermissions(UserModel user, int reqSource) throws AuthenticatorException;
61
62     /**
63       * This method should return an array of users that have certian permissions in the
64       * authentication system. This list must always include all super users, even if they
65       * do not explicitly have the required permission.
66       * @param permissions an array of PermissionModels that define which permissions in which
67                projects are required.
68       * @param requireAll true is the user must possess any of the permissions, false if only one is required
69       * @param activeOnly true if only users listed as active should be returned
70       * @param reqSource the source of the request (eg web, api)
71       * @return an array of UserModels
72       * @throws AuthenticatorException an error occurs
73       */

74     public UserModel[] getUsersWithProjectPermission(PermissionModel[] permissions, boolean requireAll, boolean activeOnly, int reqSource) throws AuthenticatorException;
75
76     /**
77       * This method should be implemented to determine if a user is authorized to self register.
78       * @param user a UserModel object that contains the data the user submitted
79       * @param authentication the user's authentication information, if known
80       * @param authType the type of authentication information being provided
81       * @param reqSource the source of the request (eg web, api)
82       * @return a boolean whether the user should be allowed to register
83       * @throws AuthenticatorException an exception if an error occurs
84       */

85     public boolean allowRegistration(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
86
87     /**
88       * This method should be implemented to determine if a new user profile should be allowed
89       * to be created. This applies to both self registration and also new users created by
90       * a super user on the system. If this method would always return false, then some other
91       * mechanism must be provided for new users to be created in the system.
92       * @param user a UserModel object that contains the data for the new user. If null,
93                then the request is being made for an unknown future user. For example,
94                the system may request this with an null user if it needs to know if the system
95                should even present the option to create a new user
96       * @param authentication the user's authentication information, if known
97       * @param authType the type of authentication information being provided
98       * @param reqSource the source of the request (eg web, api)
99       * @return a boolean whether new profile creation is allowed
100       * @throws AuthenticatorException an exception if an error occurs
101       */

102     public boolean allowProfileCreation(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
103
104     /**
105       * This method should be implemented to determine if the particular user is allowed to perform
106       * profile updates on the system. This method is used in conjunction with allowPasswordUpdates,
107       * allowPreferenceUpdates, and allowPermissionUpdates to determine what parts of the user's
108       * information is allowed to be updated through ITracker.
109       * @param user a UserModel object that contains the data the user submitted
110       * @param authentication the user's authentication information, if known
111       * @param authType the type of authentication information being provided
112       * @param reqSource the source of the request (eg web, api)
113       * @return a boolean whether the user's core profile information can be updated
114       * @throws AuthenticatorException an exception if an error occurs
115       * @see PluggableAuthentication#allowPasswordUpdates
116       * @see PluggableAuthentication#allowPermissionUpdates
117       * @see PluggableAuthentication#allowPreferenceUpdates
118       */

119     public boolean allowProfileUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
120
121     /**
122       * This method should be implemented to determine if the particular user is allowed to perform
123       * password updates on the system. This method is used in conjunction with allowProfileUpdates,
124       * allowPermissionUpdates, and allowPreferenceUpdates to determine what parts of the user's
125       * information is allowed to be updated through ITracker.
126       * @param user a UserModel object that contains the current user data
127       * @param authentication the user's authentication information, if known
128       * @param authType the type of authentication information being provided
129       * @param reqSource the source of the request (eg web, api)
130       * @return a boolean whether the user's core profile information can be updated
131       * @throws AuthenticatorException an exception if an error occurs
132       * @see PluggableAuthentication#allowProfileUpdates
133       * @see PluggableAuthentication#allowPermissionUpdates
134       * @see PluggableAuthentication#allowPreferenceUpdates
135       */

136     public boolean allowPasswordUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
137
138     /**
139       * This method should be implemented to determine if the particular user is allowed to perform
140       * permissions updates on the system. This method is used in conjunction with allowProfileUpdates,
141       * allowPasswordUpdates, and allowPreferenceUpdates to determine what parts of the user's
142       * information is allowed to be updated through ITracker. If the user model is null, then the
143       * request is being made for multiple users, for example on the edit project page, and is being applied
144       * on a generic basis, that is are permission updates allowed at all on the system.
145       * @param user a UserModel object that contains the current user data, or null if multiple users
146       * @param authentication the user's authentication information, if known
147       * @param authType the type of authentication information being provided
148       * @param reqSource the source of the request (eg web, api)
149       * @return a boolean whether the user's core profile information can be updated
150       * @throws AuthenticatorException an exception if an error occurs
151       * @see PluggableAuthentication#allowProfileUpdates
152       * @see PluggableAuthentication#allowPasswordUpdates
153       * @see PluggableAuthentication#allowPreferenceUpdates
154       */

155     public boolean allowPermissionUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
156
157     /**
158       * This method should be implemented to determine if the particular user is allowed to perform
159       * preferences updates on the system. This method is used in conjunction with allowProfileUpdates,
160       * allowPasswordUpdates, and allowPermissionUpdate to determine what parts of the user's
161       * information is allowed to be updated through ITracker.
162       * @param user a UserModel object that contains the current user data
163       * @param authentication the user's authentication information, if known
164       * @param authType the type of authentication information being provided
165       * @param reqSource the source of the request (eg web, api)
166       * @return a boolean whether the user's core profile information can be updated
167       * @throws AuthenticatorException an exception if an error occurs
168       * @see PluggableAuthentication#allowProfileUpdates
169       * @see PluggableAuthentication#allowPasswordUpdates
170       * @see PluggableAuthentication#allowPermissionUpdates
171       */

172     public boolean allowPreferenceUpdates(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
173
174     /**
175       * This method should be implemented to perform any updates that are necessary in the authentication
176       * system to support a new user. Any updates needed to the data supplied should be made in the supplied
177       * UserModel. The system will then update the information in the ITracker datastore. Only changes to the
178       * core profile information and password are made here. Any permission information for the new user
179       * whould be done through an updateProfile call.
180       * @param user a UserModel object that contains the newly created profile
181       * @param authentication the user's authentication information, if known
182       * @param authType the type of authentication information being provided
183       * @param reqSource the source of the request (eg web, api)
184       * @return true if changes were made
185       * @throws AuthenticatorException an error occurs
186       * @see PluggableAuthenticator#updateProfile
187       */

188     public boolean createProfile(UserModel user, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
189
190     /**
191       * This method should be implemented to perform any updates that are necessary in the authentication
192       * system to support the updated user information. This action will be called any time there are any
193       * updates to a user including core profile information, password information, permission information
194       * or preference changes. Any changes should be made directly to user model supplied to the method.
195       * @param user a UserModel object that contains the updated profile
196       * @param updateType the type of information that is being updated
197       * @param authentication the user's authentication information, if known
198       * @param authType the type of authentication information being provided
199       * @param reqSource the source of the request (eg web, api)
200       * @return true if changes were made
201       * @throws AuthenticatorException an exception if the login is unsuccessful, or an error occurs
202       */

203     public boolean updateProfile(UserModel user, int updateType, Object JavaDoc authentication, int authType, int reqSource) throws AuthenticatorException;
204
205     /**
206       * This method should be implemented to setup any needed components. It is called
207       * Every time a new check is performed but could be used to store static information
208       * that is not changed.
209       * @param values A HashMap that contains some default information. The current calls
210       * pass a UserHandler bean as userHandler, and an SystemConfiguration
211       * bean as systemConfiguration
212       */

213     public void initialize(HashMap value);
214 }
Popular Tags