KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jguard > ext > authentication > manager > AuthenticationManager


1 /*
2 jGuard is a security framework based on top of jaas (java authentication and authorization security).
3 it is written for web applications, to resolve simply, access control problems.
4 version $Name$
5 http://sourceforge.net/projects/jguard/
6
7 Copyright (C) 2004 Charles GAY
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23
24 jGuard project home page:
25 http://sourceforge.net/projects/jguard/
26
27 */

28 package net.sf.jguard.ext.authentication.manager;
29
30
31
32 import java.security.Principal JavaDoc;
33 import java.util.Collection JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.util.Set JavaDoc;
36
37 import javax.security.auth.Subject JavaDoc;
38
39 import net.sf.jguard.core.authentication.credentials.JGuardCredential;
40 import net.sf.jguard.ext.authentication.AuthenticationException;
41 import net.sf.jguard.ext.registration.RegistrationException;
42 import net.sf.jguard.ext.registration.SubjectTemplate;
43
44 /**
45  *
46  * this interface provide the ability to operate on the system which stores user profiles.
47  * it can be a database, or an ldap server, or anything else....
48  * it concerns <strong>administrators</strong> guys.
49  * there is one AuthenticationManager per webapp.
50  * @author <a HREF="mailto:diabolo512@users.sourceforge.net">Charles Gay</a>
51  * @author <a HREF="mailto:tandilero@users.sourceforge.net">Maximiliano Batelli</a>
52  *
53  */

54 public interface AuthenticationManager {
55
56      /**
57       * define the template against the user will
58       * be checked during the registration process.
59       * @param template
60      * @throws AuthenticationException
61       */

62      public void persistSubjectTemplate(SubjectTemplate template) throws AuthenticationException;
63
64
65      /**
66       * add user in the list to the persistance storage, in conformance to the default
67       * SubjectTemplate.
68       * @param user
69       * @throws AuthenticationException
70       */

71      public Subject JavaDoc createUser(SubjectTemplate user) throws RegistrationException ;
72
73
74      /**
75       * add user in the list to the persistance storage, in conformance to the default
76       * SubjectTemplate.
77       * @param user user candidate
78       * @param template we register user against this specific template
79       * @return user created
80       * @throws AuthenticationException
81       */

82      public Subject JavaDoc createUser(SubjectTemplate user, SubjectTemplate template) throws RegistrationException ;
83
84      /**
85       * add user in the list to the persistance storage, in conformance to the default
86       * SubjectTemplate.
87       * @param user user to create
88       * @throws AuthenticationException
89       */

90      public void createUser(Subject JavaDoc user) throws AuthenticationException ;
91
92      /**
93       * add role from this application to user.
94       * @param user
95       * @param roleName
96       * @throws AuthenticationException
97       */

98      public void addPrincipalToUser(Subject JavaDoc user, String JavaDoc roleName)throws AuthenticationException;
99      
100      
101      /**
102       * add a role from <strong>any</strong> application <strong>without</strong> check
103       * to user.
104       * @param user
105       * @param roleName
106       * @param applicationName
107       * @throws AuthenticationException
108       */

109      public void addPrincipalToUser(Subject JavaDoc user, String JavaDoc roleName,String JavaDoc applicationName) throws AuthenticationException;
110
111     /**
112      * add principals in the list to the persistance storage.
113      * create a Principal in the backend, <strong>only</strong> if it is not already present.
114      * @param role
115      * @throws AuthenticationException
116      */

117     public void createPrincipal(Principal JavaDoc role) throws AuthenticationException ;
118
119     /**
120      * retrieve role from the webapp.
121      * @param name
122      * @return roleInterface
123      * @throws AuthenticationException
124      */

125     public Principal JavaDoc getLocalPrincipal(String JavaDoc name)throws AuthenticationException;
126
127
128     /**
129      * get the principals defined in the repository for all the applications.
130      * @return role's list.
131      * @throws AuthenticationException
132      */

133     public Set JavaDoc getAllPrincipalsSet() throws AuthenticationException;
134
135     /**
136      * get the principals defined in the repository <strong>only</strong> for this application.
137      * @return role's list.
138      *
139      */

140     public Set JavaDoc getLocalPrincipals();
141
142     /**
143      * retrieve users which are in conformance with all these credentials.
144      * @param credentials
145      * @return users
146      * @throws AuthenticationException
147      */

148     public Set JavaDoc findUsers(Collection JavaDoc credentials)throws AuthenticationException;
149
150     /**
151      * checks if a user with the same username already exists.
152      * @param user
153      * @return result. true if a user with the same name exists, false otherwise.
154      * @throws AuthenticationException
155      */

156     public boolean userAlreadyExists(Subject JavaDoc user) throws AuthenticationException;
157
158
159     /**
160      * initialize AuthenticationManager.
161      * @param map
162      */

163     public void init(Map JavaDoc map);
164
165
166     /**
167      * role wether or not exists in the webapp.
168      * @param role to check
169      * @return result
170      * @throws AuthenticationException
171      */

172     public boolean hasPrincipal(Principal JavaDoc role)throws AuthenticationException;
173
174     /**
175      * role wether or not exists in the webapp.
176      * @param role to check
177      * @return result
178      * @throws AuthenticationException
179      */

180     public boolean hasPrincipal(String JavaDoc role)throws AuthenticationException;
181
182     /**
183      * update user's informations.
184      * @param identityCred
185      * @param user
186      * @throws AuthenticationException
187      */

188     public void updateUser(JGuardCredential identityCred,Subject JavaDoc user)throws AuthenticationException;
189
190     /**
191      * remove user.
192      * @param user
193      * @throws AuthenticationException
194      */

195     public void deleteUser(Subject JavaDoc user)throws AuthenticationException;
196
197     /**
198      * return the default <strong>unmodifiable</strong> SubjectTemplate.
199      * @return default SubjectTemplate
200      * @throws AuthenticationException
201      */

202     public SubjectTemplate getDefaultSubjectTemplate() throws AuthenticationException;
203
204     /**
205      * return the SubjectTemplate.
206      * @param name
207      * @return SubjectTemplate
208      * @throws AuthenticationException
209      */

210     public SubjectTemplate getSubjectTemplate(String JavaDoc name) throws AuthenticationException;
211
212     public Set JavaDoc getUsers() throws AuthenticationException;
213
214     public boolean isEmpty();
215
216     /**
217      * change principal's name.
218      * @param oldPrincipalName
219      * @param principal
220      * @throws AuthenticationException
221      */

222     public void updatePrincipal(String JavaDoc oldPrincipalName, Principal JavaDoc principal) throws AuthenticationException;
223
224
225     /**
226      * delete this principal and its references in users.
227      * @param principal
228      * @return false i delete fails, true if it succeed
229      * @throws AuthenticationException
230      */

231     public boolean deletePrincipal(Principal JavaDoc principal)throws AuthenticationException ;
232
233
234     /**
235      * Clone a Principal with a random name
236      * @param roleName Principal name to clone
237      * @return cloned Principal with a different name: roleName + Random integer betweeen 0 and 99999
238      * @throws AuthenticationException
239      */

240     public Principal JavaDoc clonePrincipal(String JavaDoc roleName) throws AuthenticationException;
241
242     /**
243      * Clone a Principal. If Principal is instance of RolePrincipal makes a call to the clone method leting the clone task to RolePrincipal
244      * @param roleName Principal name to clone
245      * @param cloneName Principal cloned name
246      * @return cloned Principal with the given cloneName
247      * @throws AuthenticationException
248      */

249     public Principal JavaDoc clonePrincipal(String JavaDoc roleName, String JavaDoc cloneName) throws AuthenticationException;
250     /**
251      * change 'active' property on the specified role for a user.
252      * this change cannot be done on 'guest' user, or if it remains only one 'active=true' role.
253      * @param subject
254      * @param roleName
255      * @param applicationName
256      * @param active
257      * @throws AuthenticationException
258      */

259     public void setActiveOnRolePrincipal(Subject JavaDoc subject,String JavaDoc roleName,String JavaDoc applicationName,boolean active) throws AuthenticationException;
260     
261     public Subject JavaDoc findUser(String JavaDoc login);
262     
263     public void updateRoleDefinition(Subject JavaDoc subject, String JavaDoc role,String JavaDoc applicationName,String JavaDoc definition) throws AuthenticationException;
264     
265     
266     public void importAuthenticationManager(AuthenticationManager authManager);
267     
268 }
269
Popular Tags