KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > security > InfoGlueBasicAuthorizationModule


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.security;
25
26 import java.io.Serializable JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Properties JavaDoc;
32
33 import org.apache.log4j.Logger;
34 import org.exolab.castor.jdo.Database;
35 import org.infoglue.cms.controllers.kernel.impl.simple.BaseController;
36 import org.infoglue.cms.controllers.kernel.impl.simple.CastorDatabaseService;
37 import org.infoglue.cms.controllers.kernel.impl.simple.GroupController;
38 import org.infoglue.cms.controllers.kernel.impl.simple.RoleController;
39 import org.infoglue.cms.controllers.kernel.impl.simple.SystemUserController;
40 import org.infoglue.cms.entities.kernel.BaseEntityVO;
41 import org.infoglue.cms.entities.management.Group;
42 import org.infoglue.cms.entities.management.GroupVO;
43 import org.infoglue.cms.entities.management.Role;
44 import org.infoglue.cms.entities.management.RoleVO;
45 import org.infoglue.cms.entities.management.SystemUser;
46 import org.infoglue.cms.entities.management.SystemUserVO;
47 import org.infoglue.cms.exception.SystemException;
48 import org.infoglue.cms.util.CmsPropertyHandler;
49
50 /**
51  * @author Mattias Bogeblad
52  *
53  * This authentication module authenticates an user against the ordinary infoglue database.
54  */

55
56 public class InfoGlueBasicAuthorizationModule extends BaseController implements AuthorizationModule, Serializable JavaDoc
57 {
58     private final static Logger logger = Logger.getLogger(InfoGlueBasicAuthorizationModule.class.getName());
59
60     private Properties JavaDoc extraProperties = null;
61     private transient Database transactionObject = null;
62     
63     /**
64      * Gets is the implementing class can update as well as read
65      */

66     
67     public boolean getSupportUpdate()
68     {
69         return true;
70     }
71
72     /**
73      * Gets is the implementing class can delete as well as read
74      */

75     
76     public boolean getSupportDelete()
77     {
78         return true;
79     }
80     
81     /**
82      * Gets is the implementing class can create as well as read
83      */

84     
85     public boolean getSupportCreate()
86     {
87         return true;
88     }
89
90     /**
91      * Gets an authorized InfoGluePrincipal. If the user has logged in with the root-account
92      * we immediately return - otherwise we populate it.
93      */

94     
95     public InfoGluePrincipal getAuthorizedInfoGluePrincipal(String JavaDoc userName) throws Exception JavaDoc
96     {
97         if(userName == null || userName.equals(""))
98         {
99             logger.warn("userName was null or empty - fix your templates:" + userName);
100             return null;
101         }
102         
103         InfoGluePrincipal infogluePrincipal = null;
104         
105         String JavaDoc administratorUserName = CmsPropertyHandler.getAdministratorUserName();
106         String JavaDoc administratorEmail = CmsPropertyHandler.getAdministratorEmail();
107         
108         final boolean isAdministrator = (userName != null && userName.equalsIgnoreCase(administratorUserName)) ? true : false;
109         if(isAdministrator)
110         {
111             infogluePrincipal = new InfoGluePrincipal(userName, "System", "Administrator", administratorEmail, new ArrayList JavaDoc(), new ArrayList JavaDoc(), isAdministrator, this);
112         }
113         else
114         {
115             List JavaDoc roles = new ArrayList JavaDoc();
116             List JavaDoc groups = new ArrayList JavaDoc();
117             
118             if(transactionObject == null)
119             {
120                 Database db = CastorDatabaseService.getDatabase();
121     
122                 try
123                 {
124                     beginTransaction(db);
125                     
126                     SystemUser systemUser = SystemUserController.getController().getReadOnlySystemUserWithName(userName, db);
127                     if(systemUser != null)
128                     {
129                         Iterator JavaDoc roleListIterator = systemUser.getRoles().iterator();
130                         while(roleListIterator.hasNext())
131                         {
132                             Role role = (Role)roleListIterator.next();
133                             InfoGlueRole infoGlueRole = new InfoGlueRole(role.getRoleName(), role.getDescription(), this);
134                             roles.add(infoGlueRole);
135                         }
136         
137                         Iterator JavaDoc groupListIterator = systemUser.getGroups().iterator();
138                         while(groupListIterator.hasNext())
139                         {
140                             Group group = (Group)groupListIterator.next();
141                             InfoGlueGroup infoGlueGroup = new InfoGlueGroup(group.getGroupName(), group.getDescription(), this);
142                             groups.add(infoGlueGroup);
143                         }
144         
145                         infogluePrincipal = new InfoGluePrincipal(userName, systemUser.getFirstName(), systemUser.getLastName(), systemUser.getEmail(), roles, groups, isAdministrator, this);
146                     }
147                     else
148                     {
149                         logger.warn("Could not find user with userName '" + userName + "' - fix your template logic.");
150                         infogluePrincipal = null;
151                     }
152                     
153                     commitTransaction(db);
154                 }
155                 catch (Exception JavaDoc e)
156                 {
157                     logger.info("An error occurred trying to get SystemUser for " + userName + ":" + e);
158                     rollbackTransaction(db);
159                     throw new SystemException(e.getMessage());
160                 }
161             }
162             else
163             {
164                 SystemUser systemUser = SystemUserController.getController().getReadOnlySystemUserWithName(userName, transactionObject);
165                 
166                 if(systemUser != null)
167                 {
168                     Iterator JavaDoc roleListIterator = systemUser.getRoles().iterator();
169                     while(roleListIterator.hasNext())
170                     {
171                         Role role = (Role)roleListIterator.next();
172                         InfoGlueRole infoGlueRole = new InfoGlueRole(role.getRoleName(), role.getDescription(), this);
173                         roles.add(infoGlueRole);
174                     }
175     
176                     Iterator JavaDoc groupListIterator = systemUser.getGroups().iterator();
177                     while(groupListIterator.hasNext())
178                     {
179                         Group group = (Group)groupListIterator.next();
180                         InfoGlueGroup infoGlueGroup = new InfoGlueGroup(group.getGroupName(), group.getDescription(), this);
181                         groups.add(infoGlueGroup);
182                     }
183     
184                     infogluePrincipal = new InfoGluePrincipal(userName, systemUser.getFirstName(), systemUser.getLastName(), systemUser.getEmail(), roles, groups, isAdministrator, this);
185                 }
186                 else
187                 {
188                     logger.warn("Could not find user with userName '" + userName + "' - fix your template logic.");
189                     infogluePrincipal = null;
190                 }
191             }
192         }
193         
194         return infogluePrincipal;
195     }
196
197     /**
198      * Gets an authorized InfoGlueRole.
199      */

200     
201     public InfoGlueRole getAuthorizedInfoGlueRole(String JavaDoc roleName) throws Exception JavaDoc
202     {
203         InfoGlueRole infoglueRole = null;
204
205         RoleVO roleVO = null;
206         
207         if(transactionObject == null)
208         {
209             roleVO = RoleController.getController().getRoleVOWithId(roleName);
210         }
211         else
212         {
213             roleVO = RoleController.getController().getRoleWithName(roleName, transactionObject).getValueObject();
214         }
215         
216         infoglueRole = new InfoGlueRole(roleVO.getRoleName(), roleVO.getDescription(), this);
217                 
218         return infoglueRole;
219     }
220
221     /**
222      * Gets an authorized InfoGlueGroup.
223      */

224     
225     public InfoGlueGroup getAuthorizedInfoGlueGroup(String JavaDoc groupName) throws Exception JavaDoc
226     {
227         InfoGlueGroup infoglueGroup = null;
228         
229         GroupVO groupVO = null;
230         if(transactionObject == null)
231         {
232             groupVO = GroupController.getController().getGroupVOWithId(groupName);
233         }
234         else
235         {
236             groupVO = GroupController.getController().getGroupWithName(groupName, transactionObject).getValueObject();
237         }
238
239         infoglueGroup = new InfoGlueGroup(groupVO.getGroupName(), groupVO.getDescription(), this);
240                 
241         return infoglueGroup;
242     }
243
244     
245     /**
246      * This method gets a users roles
247      */

248     
249     public List JavaDoc authorizeUser(String JavaDoc userName) throws Exception JavaDoc
250     {
251         List JavaDoc roles = new ArrayList JavaDoc();
252         List JavaDoc groups = new ArrayList JavaDoc();
253         
254         String JavaDoc administratorUserName = CmsPropertyHandler.getAdministratorUserName();
255         
256         boolean isAdministrator = userName.equalsIgnoreCase(administratorUserName) ? true : false;
257         if(isAdministrator)
258             return roles;
259         
260         if(transactionObject == null)
261         {
262             List JavaDoc roleVOList = RoleController.getController().getRoleVOList(userName);
263             Iterator JavaDoc roleVOListIterator = roleVOList.iterator();
264             while(roleVOListIterator.hasNext())
265             {
266                 RoleVO roleVO = (RoleVO)roleVOListIterator.next();
267                 InfoGlueRole infoGlueRole = new InfoGlueRole(roleVO.getRoleName(), roleVO.getDescription(), this);
268                 roles.add(infoGlueRole);
269             }
270     
271             List JavaDoc groupVOList = GroupController.getController().getGroupVOList(userName);
272             Iterator JavaDoc groupVOListIterator = groupVOList.iterator();
273             while(groupVOListIterator.hasNext())
274             {
275                 GroupVO groupVO = (GroupVO)groupVOListIterator.next();
276                 InfoGlueGroup infoGlueGroup = new InfoGlueGroup(groupVO.getGroupName(), groupVO.getDescription(), this);
277                 groups.add(infoGlueGroup);
278             }
279         }
280         else
281         {
282             Collection JavaDoc roleList = RoleController.getController().getRoleList(userName, transactionObject);
283             Iterator JavaDoc roleListIterator = roleList.iterator();
284             while(roleListIterator.hasNext())
285             {
286                 Role role = (Role)roleListIterator.next();
287                 InfoGlueRole infoGlueRole = new InfoGlueRole(role.getRoleName(), role.getDescription(), this);
288                 roles.add(infoGlueRole);
289             }
290     
291             Collection JavaDoc groupList = GroupController.getController().getGroupList(userName, transactionObject);
292             Iterator JavaDoc groupListIterator = groupList.iterator();
293             while(groupListIterator.hasNext())
294             {
295                 Group group = (Group)groupListIterator.next();
296                 InfoGlueGroup infoGlueGroup = new InfoGlueGroup(group.getGroupName(), group.getDescription(), this);
297                 groups.add(infoGlueGroup);
298             }
299         }
300         
301         return groups;
302     }
303
304     /**
305      * This method gets a list of roles
306      */

307     
308     public List JavaDoc getRoles() throws Exception JavaDoc
309     {
310         List JavaDoc roles = new ArrayList JavaDoc();
311         
312         if(transactionObject == null)
313         {
314             List JavaDoc roleVOList = RoleController.getController().getRoleVOList();
315             Iterator JavaDoc roleVOListIterator = roleVOList.iterator();
316             while(roleVOListIterator.hasNext())
317             {
318                 RoleVO roleVO = (RoleVO)roleVOListIterator.next();
319                 InfoGlueRole infoGlueRole = new InfoGlueRole(roleVO.getRoleName(), roleVO.getDescription(), this);
320                 roles.add(infoGlueRole);
321             }
322         }
323         else
324         {
325             List JavaDoc roleVOList = RoleController.getController().getRoleVOList(this.transactionObject);
326             Iterator JavaDoc roleVOListIterator = roleVOList.iterator();
327             while(roleVOListIterator.hasNext())
328             {
329                 RoleVO roleVO = (RoleVO)roleVOListIterator.next();
330                 InfoGlueRole infoGlueRole = new InfoGlueRole(roleVO.getRoleName(), roleVO.getDescription(), this);
331                 roles.add(infoGlueRole);
332             }
333         }
334         
335         return roles;
336     }
337
338     public List JavaDoc getGroups() throws Exception JavaDoc
339     {
340         List JavaDoc groups = new ArrayList JavaDoc();
341         
342         if(transactionObject == null)
343         {
344             List JavaDoc groupVOList = GroupController.getController().getGroupVOList();
345             Iterator JavaDoc groupVOListIterator = groupVOList.iterator();
346             while(groupVOListIterator.hasNext())
347             {
348                 GroupVO groupVO = (GroupVO)groupVOListIterator.next();
349                 InfoGlueGroup infoGlueGroup = new InfoGlueGroup(groupVO.getGroupName(), groupVO.getDescription(), this);
350                 groups.add(infoGlueGroup);
351             }
352         }
353         else
354         {
355             List JavaDoc groupVOList = GroupController.getController().getGroupVOList(this.transactionObject);
356             Iterator JavaDoc groupVOListIterator = groupVOList.iterator();
357             while(groupVOListIterator.hasNext())
358             {
359                 GroupVO groupVO = (GroupVO)groupVOListIterator.next();
360                 InfoGlueGroup infoGlueGroup = new InfoGlueGroup(groupVO.getGroupName(), groupVO.getDescription(), this);
361                 groups.add(infoGlueGroup);
362             }
363         }
364         
365         return groups;
366     }
367
368     
369     /**
370      * This method gets a list of users
371      */

372     
373     public List JavaDoc getUsers() throws Exception JavaDoc
374     {
375         List JavaDoc users = new ArrayList JavaDoc();
376         
377         if(transactionObject == null)
378         {
379             List JavaDoc systemUserVOList = SystemUserController.getController().getSystemUserVOList();
380             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
381             while(systemUserVOListIterator.hasNext())
382             {
383                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
384     
385                 List JavaDoc roles = new ArrayList JavaDoc();
386                 Collection JavaDoc roleVOList = RoleController.getController().getRoleVOList(systemUserVO.getUserName());
387                 Iterator JavaDoc roleVOListIterator = roleVOList.iterator();
388                 while(roleVOListIterator.hasNext())
389                 {
390                     RoleVO roleVO = (RoleVO)roleVOListIterator.next();
391                     InfoGlueRole infoGlueRole = new InfoGlueRole(roleVO.getRoleName(), roleVO.getDescription(), this);
392                     roles.add(infoGlueRole);
393                 }
394                 
395                 List JavaDoc groups = new ArrayList JavaDoc();
396                 Collection JavaDoc groupVOList = GroupController.getController().getGroupVOList(systemUserVO.getUserName());
397                 Iterator JavaDoc groupVOListIterator = groupVOList.iterator();
398                 while(groupVOListIterator.hasNext())
399                 {
400                     GroupVO groupVO = (GroupVO)groupVOListIterator.next();
401                     InfoGlueGroup infoGlueGroup = new InfoGlueGroup(groupVO.getGroupName(), groupVO.getDescription(), this);
402                     roles.add(infoGlueGroup);
403                 }
404                 
405                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), roles, groups, false, this);
406                 
407                 users.add(infoGluePrincipal);
408             }
409         }
410         else
411         {
412             List JavaDoc systemUserVOList = SystemUserController.getController().getSystemUserVOList(transactionObject);
413             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
414             while(systemUserVOListIterator.hasNext())
415             {
416                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
417
418                 List JavaDoc roles = new ArrayList JavaDoc();
419                 Collection JavaDoc roleList = RoleController.getController().getRoleList(systemUserVO.getUserName(), transactionObject);
420                 Iterator JavaDoc roleListIterator = roleList.iterator();
421                 while(roleListIterator.hasNext())
422                 {
423                     Role role = (Role)roleListIterator.next();
424                     InfoGlueRole infoGlueRole = new InfoGlueRole(role.getRoleName(), role.getDescription(), this);
425                     roles.add(infoGlueRole);
426                 }
427                 
428                 List JavaDoc groups = new ArrayList JavaDoc();
429                 Collection JavaDoc groupList = GroupController.getController().getGroupList(systemUserVO.getUserName(), transactionObject);
430                 Iterator JavaDoc groupListIterator = groupList.iterator();
431                 while(groupListIterator.hasNext())
432                 {
433                     Group group = (Group)groupListIterator.next();
434                     InfoGlueGroup infoGlueGroup = new InfoGlueGroup(group.getGroupName(), group.getDescription(), this);
435                     roles.add(infoGlueGroup);
436                 }
437                 
438                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), roles, groups, false, this);
439                 
440                 users.add(infoGluePrincipal);
441             }
442         }
443         
444         return users;
445     }
446
447     public List JavaDoc getFilteredUsers(String JavaDoc firstName, String JavaDoc lastName, String JavaDoc userName, String JavaDoc email, String JavaDoc[] roleIds) throws Exception JavaDoc
448     {
449         List JavaDoc users = new ArrayList JavaDoc();
450         
451         if(transactionObject == null)
452         {
453             List JavaDoc systemUserVOList = SystemUserController.getController().getFilteredSystemUserVOList(firstName, lastName, userName, email, roleIds);
454             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
455             while(systemUserVOListIterator.hasNext())
456             {
457                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
458                 
459                 List JavaDoc roles = new ArrayList JavaDoc();
460                 Collection JavaDoc roleVOList = RoleController.getController().getRoleVOList(systemUserVO.getUserName());
461                 Iterator JavaDoc roleVOListIterator = roleVOList.iterator();
462                 while(roleVOListIterator.hasNext())
463                 {
464                     RoleVO roleVO = (RoleVO)roleVOListIterator.next();
465                     InfoGlueRole infoGlueRole = new InfoGlueRole(roleVO.getRoleName(), roleVO.getDescription(), this);
466                     roles.add(infoGlueRole);
467                 }
468                 
469                 List JavaDoc groups = new ArrayList JavaDoc();
470                 Collection JavaDoc groupVOList = GroupController.getController().getGroupVOList(systemUserVO.getUserName());
471                 Iterator JavaDoc groupVOListIterator = groupVOList.iterator();
472                 while(groupVOListIterator.hasNext())
473                 {
474                     GroupVO groupVO = (GroupVO)groupVOListIterator.next();
475                     InfoGlueGroup infoGlueGroup = new InfoGlueGroup(groupVO.getGroupName(), groupVO.getDescription(), this);
476                     groups.add(infoGlueGroup);
477                 }
478                 
479                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), roles, groups, false, this);
480                 users.add(infoGluePrincipal);
481             }
482         }
483         else
484         {
485             List JavaDoc systemUserList = SystemUserController.getController().getFilteredSystemUserList(firstName, lastName, userName, email, roleIds, transactionObject);
486             Iterator JavaDoc systemUserListIterator = systemUserList.iterator();
487             while(systemUserListIterator.hasNext())
488             {
489                 SystemUser systemUser = (SystemUser)systemUserListIterator.next();
490                 
491                 List JavaDoc roles = new ArrayList JavaDoc();
492                 Collection JavaDoc roleList = RoleController.getController().getRoleList(systemUser.getUserName(), transactionObject);
493                 Iterator JavaDoc roleListIterator = roleList.iterator();
494                 while(roleListIterator.hasNext())
495                 {
496                     Role role = (Role)roleListIterator.next();
497                     InfoGlueRole infoGlueRole = new InfoGlueRole(role.getRoleName(), role.getDescription(), this);
498                     roles.add(infoGlueRole);
499                 }
500                 
501                 List JavaDoc groups = new ArrayList JavaDoc();
502                 Collection JavaDoc groupList = GroupController.getController().getGroupList(systemUser.getUserName(), transactionObject);
503                 Iterator JavaDoc groupListIterator = groupList.iterator();
504                 while(groupListIterator.hasNext())
505                 {
506                     Group group = (Group)groupListIterator.next();
507                     InfoGlueGroup infoGlueGroup = new InfoGlueGroup(group.getGroupName(), group.getDescription(), this);
508                     groups.add(infoGlueGroup);
509                 }
510                 
511                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUser.getUserName(), systemUser.getFirstName(), systemUser.getLastName(), systemUser.getEmail(), roles, groups, false, this);
512                 users.add(infoGluePrincipal);
513             }
514         }
515         
516         return users;
517     }
518     
519     public List JavaDoc getUsers(String JavaDoc roleName) throws Exception JavaDoc
520     {
521         return getRoleUsers(roleName);
522     }
523
524     public List JavaDoc getRoleUsers(String JavaDoc roleName) throws Exception JavaDoc
525     {
526         logger.info("roleName:" + roleName);
527         List JavaDoc users = new ArrayList JavaDoc();
528         
529         if(transactionObject == null)
530         {
531             List JavaDoc systemUserVOList = RoleController.getController().getRoleSystemUserVOList(roleName);
532             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
533             while(systemUserVOListIterator.hasNext())
534             {
535                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
536                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), new ArrayList JavaDoc(), new ArrayList JavaDoc(), false, this);
537                 users.add(infoGluePrincipal);
538             }
539         }
540         else
541         {
542             List JavaDoc systemUserVOList = RoleController.getController().getRoleSystemUserVOList(roleName, transactionObject);
543             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
544             while(systemUserVOListIterator.hasNext())
545             {
546                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
547                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), new ArrayList JavaDoc(), new ArrayList JavaDoc(), false, this);
548                 users.add(infoGluePrincipal);
549             }
550         }
551         
552         return users;
553     }
554
555     public List JavaDoc getGroupUsers(String JavaDoc groupName) throws Exception JavaDoc
556     {
557         logger.info("groupName:" + groupName);
558         List JavaDoc users = new ArrayList JavaDoc();
559         
560         if(transactionObject == null)
561         {
562             List JavaDoc systemUserVOList = GroupController.getController().getGroupSystemUserVOList(groupName);
563             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
564             while(systemUserVOListIterator.hasNext())
565             {
566                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
567                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), new ArrayList JavaDoc(), new ArrayList JavaDoc(), false, this);
568                 users.add(infoGluePrincipal);
569             }
570         }
571         else
572         {
573             List JavaDoc systemUserVOList = GroupController.getController().getGroupSystemUserVOList(groupName, transactionObject);
574             Iterator JavaDoc systemUserVOListIterator = systemUserVOList.iterator();
575             while(systemUserVOListIterator.hasNext())
576             {
577                 SystemUserVO systemUserVO = (SystemUserVO)systemUserVOListIterator.next();
578                 InfoGluePrincipal infoGluePrincipal = new InfoGluePrincipal(systemUserVO.getUserName(), systemUserVO.getFirstName(), systemUserVO.getLastName(), systemUserVO.getEmail(), new ArrayList JavaDoc(), new ArrayList JavaDoc(), false, this);
579                 users.add(infoGluePrincipal);
580             }
581         }
582
583         return users;
584     }
585
586     public void createInfoGluePrincipal(SystemUserVO systemUserVO) throws Exception JavaDoc
587     {
588         if(transactionObject == null)
589         {
590             SystemUserController.getController().create(systemUserVO);
591         }
592         else
593         {
594             SystemUserController.getController().create(systemUserVO, transactionObject);
595         }
596     }
597
598     public void updateInfoGluePrincipal(SystemUserVO systemUserVO, String JavaDoc[] roleNames, String JavaDoc[] groupNames) throws Exception JavaDoc
599     {
600         if(transactionObject == null)
601         {
602             SystemUserController.getController().update(systemUserVO, roleNames, groupNames);
603         }
604         else
605         {
606             SystemUserController.getController().update(systemUserVO, roleNames, groupNames, transactionObject);
607         }
608     }
609
610     /**
611      * This method is used to send out a newpassword to an existing users.
612      */

613
614     public void updateInfoGluePrincipalPassword(String JavaDoc userName) throws Exception JavaDoc
615     {
616         if(transactionObject == null)
617         {
618             SystemUserController.getController().updatePassword(userName);
619         }
620         else
621         {
622             SystemUserController.getController().updatePassword(userName, transactionObject);
623         }
624     }
625     
626     /**
627      * This method is used to let a user update his password by giving his/her old one first.
628      */

629
630     public void updateInfoGluePrincipalPassword(String JavaDoc userName, String JavaDoc oldPassword, String JavaDoc newPassword) throws Exception JavaDoc
631     {
632         if(transactionObject == null)
633         {
634             SystemUserController.getController().updatePassword(userName, oldPassword, newPassword);
635         }
636         else
637         {
638             SystemUserController.getController().updatePassword(userName, oldPassword, newPassword, transactionObject);
639         }
640     }
641     
642     public void deleteInfoGluePrincipal(String JavaDoc userName) throws Exception JavaDoc
643     {
644         if(transactionObject == null)
645         {
646             SystemUserController.getController().delete(userName);
647         }
648         else
649         {
650             SystemUserController.getController().delete(userName, transactionObject);
651         }
652     }
653
654     public void createInfoGlueRole(RoleVO roleVO) throws Exception JavaDoc
655     {
656         if(transactionObject == null)
657         {
658             RoleController.getController().create(roleVO);
659         }
660         else
661         {
662             RoleController.getController().create(roleVO, transactionObject);
663         }
664     }
665
666     public void updateInfoGlueRole(RoleVO roleVO, String JavaDoc[] userNames) throws Exception JavaDoc
667     {
668         if(transactionObject == null)
669         {
670             RoleController.getController().update(roleVO, userNames);
671         }
672         else
673         {
674             RoleController.getController().update(roleVO, userNames, transactionObject);
675         }
676     }
677
678     public void deleteInfoGlueRole(String JavaDoc roleName) throws Exception JavaDoc
679     {
680         if(transactionObject == null)
681         {
682             RoleController.getController().delete(roleName);
683         }
684         else
685         {
686             RoleController.getController().delete(roleName, transactionObject);
687         }
688     }
689
690     public void createInfoGlueGroup(GroupVO groupVO) throws Exception JavaDoc
691     {
692         if(transactionObject == null)
693         {
694             GroupController.getController().create(groupVO);
695         }
696         else
697         {
698             GroupController.getController().create(groupVO, transactionObject);
699         }
700     }
701
702     public void updateInfoGlueGroup(GroupVO groupVO, String JavaDoc[] userNames) throws Exception JavaDoc
703     {
704         if(transactionObject == null)
705         {
706             GroupController.getController().update(groupVO, userNames);
707         }
708         else
709         {
710             GroupController.getController().update(groupVO, userNames, transactionObject);
711         }
712     }
713
714     public void deleteInfoGlueGroup(String JavaDoc groupName) throws Exception JavaDoc
715     {
716         if(transactionObject == null)
717         {
718             GroupController.getController().delete(groupName);
719         }
720         else
721         {
722             GroupController.getController().delete(groupName, transactionObject);
723         }
724     }
725
726     public Properties JavaDoc getExtraProperties()
727     {
728         return extraProperties;
729     }
730
731     public void setExtraProperties(Properties JavaDoc extraProperties)
732     {
733         this.extraProperties = extraProperties;
734     }
735     
736     public Object JavaDoc getTransactionObject()
737     {
738         return this.transactionObject;
739     }
740
741     public void setTransactionObject(Object JavaDoc transactionObject)
742     {
743         this.transactionObject = (Database)transactionObject;
744     }
745
746     public BaseEntityVO getNewVO()
747     {
748         return null;
749     }
750
751 }
752
Popular Tags