KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > security > TurbineSecurity


1 package org.apache.fulcrum.security;
2
3 /* ====================================================================
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 2001 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution,
22  * if any, must include the following acknowledgment:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowledgment may appear in the software itself,
26  * if and wherever such third-party acknowledgments normally appear.
27  *
28  * 4. The names "Apache" and "Apache Software Foundation" and
29  * "Apache Turbine" must not be used to endorse or promote products
30  * derived from this software without prior written permission. For
31  * written permission, please contact apache@apache.org.
32  *
33  * 5. Products derived from this software may not be called "Apache",
34  * "Apache Turbine", nor may "Apache" appear in their name, without
35  * prior written permission of the Apache Software Foundation.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals on behalf of the Apache Software Foundation. For more
53  * information on the Apache Software Foundation, please see
54  * <http://www.apache.org/>.
55  */

56
57 import org.apache.fulcrum.TurbineServices;
58
59 import org.apache.fulcrum.security.entity.Group;
60 import org.apache.fulcrum.security.entity.Permission;
61 import org.apache.fulcrum.security.entity.Role;
62 import org.apache.fulcrum.security.entity.User;
63
64 import org.apache.fulcrum.security.util.AccessControlList;
65 import org.apache.fulcrum.security.util.GroupSet;
66 import org.apache.fulcrum.security.util.RoleSet;
67 import org.apache.fulcrum.security.util.PermissionSet;
68 import org.apache.fulcrum.security.util.DataBackendException;
69 import org.apache.fulcrum.security.util.UnknownEntityException;
70 import org.apache.fulcrum.security.util.EntityExistsException;
71 import org.apache.fulcrum.security.util.PasswordMismatchException;
72 import org.apache.fulcrum.security.util.TurbineSecurityException;
73
74 import org.apache.torque.util.Criteria;
75
76 /**
77  * This is a Facade class for SecurityService.
78  *
79  * This class provides static methods that call related methods of the
80  * implementation of SecurityService used by the System, according to
81  * the settings in TurbineResources.
82  * <br>
83  *
84  * <a name="global">
85  * <p> Certain Roles that the Users may have in the system may are not related
86  * to any specific resource nor entity. They are assigned within a special group
87  * named 'global' that can be referenced in the code as
88  * {@link org.apache.fulcrum.security.entity.Group#GLOBAL_GROUP_NAME}.
89  *
90  * @author <a HREF="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
91  * @version $Id: TurbineSecurity.java,v 1.1 2004/11/12 10:26:14 epugh Exp $
92  */

93 public abstract class TurbineSecurity
94 {
95     /**
96      * Retrieves an implementation of SecurityService, base on the settings in
97      * TurbineResources.
98      *
99      * @return an implementation of SecurityService.
100      */

101     public static SecurityService getService()
102     {
103         return (SecurityService) TurbineServices.getInstance().
104             getService(SecurityService.SERVICE_NAME);
105     }
106
107     /*-----------------------------------------------------------------------
108       Management of User objects
109       -----------------------------------------------------------------------*/

110
111     /**
112      * This method provides client-side encryption of passwords.
113      *
114      * This is an utility method that is used by other classes to maintain
115      * a consistent approach to encrypting password. The behavior of the
116      * method can be configured in service's properties.
117      *
118      * @param password the password to process
119      * @return processed password
120      */

121     public static String JavaDoc encryptPassword(String JavaDoc password)
122     {
123         return getService().encryptPassword(password);
124     }
125
126     /**
127      * Return a Class object representing the system's chosen implementation of
128      * of User interface.
129      *
130      * @return systems's chosen implementation of User interface.
131      * @throws UnknownEntityException if the implementation of User interface
132      * could not be determined, or does not exist.
133      */

134     public static Class JavaDoc getUserClass()
135         throws UnknownEntityException
136     {
137         return getService().getUserClass();
138     }
139
140     /**
141      * Construct a blank User object.
142      *
143      * This method calls getUserClass, and then creates a new object using
144      * the default constructor.
145      *
146      * @return an object implementing User interface.
147      * @throws UnknownEntityException if the object could not be instantiated.
148      */

149     public static User getUserInstance()
150         throws UnknownEntityException
151     {
152         return getService().getUserInstance();
153     }
154
155     /**
156      * Check whether a specified user's account exists.
157      *
158      * The login name is used for looking up the account.
159      *
160      * @param user The user to be checked.
161      * @return true if the specified account exists
162      * @throws DataBackendException if there was an error accessing the data backend.
163      */

164     public static boolean accountExists(User user)
165         throws DataBackendException
166     {
167         return getService().accountExists(user);
168     }
169
170     /**
171      * Check whether a specified user's account exists.
172      *
173      * The login name is used for looking up the account.
174      *
175      * @param userName The name of the user to be checked.
176      *
177      * @return true if the specified account exists
178      *
179      * @throws DataBackendException if there was an error accessing the data backend.
180      */

181     public static boolean accountExists(String JavaDoc userName)
182         throws DataBackendException
183     {
184         return getService().accountExists(userName);
185     }
186
187     /**
188      * Authenticates an user, and constructs an User object to represent him/her.
189      *
190      * @param username The user name.
191      * @param password The user password.
192      * @return An authenticated Turbine User.
193      * @throws DataBackendException if there was an error accessing the data backend.
194      * @throws UnknownEntityException if user account is not present.
195      * @throws PasswordMismatchException if the supplied password was incorrect.
196      */

197     public static User getAuthenticatedUser(String JavaDoc username, String JavaDoc password)
198         throws DataBackendException, UnknownEntityException, PasswordMismatchException
199     {
200         return getService().getAuthenticatedUser(username, password);
201     }
202
203     /**
204      * Constructs an User object to represent a registered user of the application.
205      *
206      * @param username The user name.
207      * @return A Turbine User.
208      * @throws DataBackendException if there was an error accessing the data backend.
209      * @throws UnknownEntityException if user account is not present.
210      */

211     public static User getUser(String JavaDoc username)
212         throws DataBackendException, UnknownEntityException
213     {
214         return getService().getUser(username);
215     }
216
217     /**
218      * Retrieve a set of users that meet the specified criteria.
219      *
220      * As the keys for the criteria, you should use the constants that
221      * are defined in {@link User} interface, plus the names
222      * of the custom attributes you added to your user representation
223      * in the data storage. Use verbatim names of the attributes -
224      * without table name prefix in case of DB implementation.
225      *
226      * @param criteria The criteria of selection.
227      * @return a List of users meeting the criteria.
228      * @throws DataBackendException if there is a problem accessing the
229      * storage.
230      */

231     public static User[] getUsers(Criteria criteria)
232         throws DataBackendException
233     {
234         return getService().getUsers(criteria);
235     }
236
237     /**
238      * Constructs an User object to represent an anonymous user of the application.
239      *
240      * @return An anonymous Turbine User.
241      * @throws UnknownEntityException if the anonymous User object couldn't be
242      * constructed.
243      */

244     public static User getAnonymousUser()
245         throws UnknownEntityException
246     {
247         return getService().getAnonymousUser();
248     }
249
250     /**
251      * Saves User's data in the permanent storage. The user account is required
252      * to exist in the storage.
253      *
254      * @param user The User object to save.
255      *
256      * @exception UnknownEntityException if the user's account does not
257      * exist in the database.
258      * @exception DataBackendException if there is a problem accessing the
259      * storage.
260      */

261     public static void saveUser(User user)
262         throws UnknownEntityException, DataBackendException
263     {
264         getService().saveUser(user);
265     }
266
267     /**
268      * Change the password for an User.
269      *
270      * @param user an User to change password for.
271      * @param oldPassword the current password supplied by the user.
272      * @param newPassword the current password requested by the user.
273      * @exception PasswordMismatchException if the supplied password was
274      * incorrect.
275      * @exception UnknownEntityException if the user's record does not
276      * exist in the database.
277      * @exception DataBackendException if there is a problem accessing the
278      * storage.
279      */

280     public static void changePassword(User user, String JavaDoc oldPassword, String JavaDoc newPassword)
281         throws PasswordMismatchException, UnknownEntityException,
282                DataBackendException
283     {
284         getService().changePassword(user, oldPassword, newPassword);
285     }
286
287     /**
288      * Forcibly sets new password for an User.
289      *
290      * This is supposed by the administrator to change the forgotten or
291      * compromised passwords. Certain implementatations of this feature
292      * would require administrative level access to the authenticating
293      * server / program.
294      *
295      * @param user an User to change password for.
296      * @param password the new password.
297      * @exception UnknownEntityException if the user's record does not
298      * exist in the database.
299      * @exception DataBackendException if there is a problem accessing the
300      * storage.
301      */

302     public static void forcePassword(User user, String JavaDoc password)
303         throws UnknownEntityException, DataBackendException
304     {
305         getService().forcePassword(user, password);
306     }
307
308     /*-----------------------------------------------------------------------
309       Creation of AccessControlLists
310       -----------------------------------------------------------------------*/

311
312     /**
313      * Constructs an AccessControlList for a specific user.
314      *
315      * @param user the user for whom the AccessControlList are to be retrieved
316      *
317      * @return The AccessControList object constructed from the user object.
318      *
319      * @throws DataBackendException if there was an error accessing the data backend.
320      * @throws UnknownEntityException if user account is not present.
321      */

322     public static AccessControlList getACL(User user)
323         throws DataBackendException, UnknownEntityException
324     {
325         return getService().getACL(user);
326     }
327
328     /*-----------------------------------------------------------------------
329       Security management
330       -----------------------------------------------------------------------*/

331
332     /**
333      * Grant an User a Role in a Group.
334      *
335      * @param user the user.
336      * @param group the group.
337      * @param role the role.
338      * @throws DataBackendException if there was an error accessing the data backend.
339      * @throws UnknownEntityException if user account, group or role is not present.
340      */

341     public static void grant(User user, Group group, Role role)
342         throws DataBackendException, UnknownEntityException
343     {
344         getService().grant(user, group, role);
345     }
346
347     /**
348      * Revoke a Role in a Group from an User.
349      *
350      * @param user the user.
351      * @param group the group.
352      * @param role the role.
353      * @throws DataBackendException if there was an error accessing the data backend.
354      * @throws UnknownEntityException if user account, group or role is not present.
355      */

356     public static void revoke(User user, Group group, Role role)
357         throws DataBackendException, UnknownEntityException
358     {
359         getService().revoke(user, group, role);
360     }
361
362     /**
363      * Revokes all roles from an User.
364      *
365      * This method is used when deleting an account.
366      *
367      * @param user the User.
368      * @throws DataBackendException if there was an error accessing the data backend.
369      * @throws UnknownEntityException if the account is not present.
370      */

371     public static void revokeAll(User user)
372         throws DataBackendException, UnknownEntityException
373     {
374         getService().revokeAll(user);
375     }
376
377     /**
378      * Grants a Role a Permission
379      *
380      * @param role the Role.
381      * @param permission the Permission.
382      * @throws DataBackendException if there was an error accessing the data backend.
383      * @throws UnknownEntityException if role or permission is not present.
384      */

385     public static void grant(Role role, Permission permission)
386         throws DataBackendException, UnknownEntityException
387     {
388         getService().grant(role, permission);
389     }
390
391     /**
392      * Revokes a Permission from a Role.
393      *
394      * @param role the Role.
395      * @param permission the Permission.
396      * @throws DataBackendException if there was an error accessing the data backend.
397      * @throws UnknownEntityException if role or permission is not present.
398      */

399     public static void revoke(Role role, Permission permission)
400         throws DataBackendException, UnknownEntityException
401     {
402         getService().revoke(role, permission);
403     }
404
405     /**
406      * Revokes all permissions from a Role.
407      *
408      * This method is user when deleting a Role.
409      *
410      * @param role the Role
411      * @throws DataBackendException if there was an error accessing the data backend.
412      * @throws UnknownEntityException if the Role is not present.
413      */

414     public static void revokeAll(Role role)
415         throws DataBackendException, UnknownEntityException
416     {
417         getService().revokeAll(role);
418     }
419
420     /*-----------------------------------------------------------------------
421       Account management
422       -----------------------------------------------------------------------*/

423
424     /**
425      * Creates new user account with specified attributes.
426      *
427      * <strong>TODO</strong> throw more specific exception<br>
428      *
429      * @param user the object describing account to be created.
430      * @param password The password to use.
431      *
432      * @throws DataBackendException if there was an error accessing the data backend.
433      * @throws EntityExistsException if the user account already exists.
434      */

435     public static void addUser(User user, String JavaDoc password)
436         throws DataBackendException, EntityExistsException
437     {
438         getService().addUser(user, password);
439     }
440
441
442     /**
443      * Removes an user account from the system.
444      *
445      * <strong>TODO</strong> throw more specific exception<br>
446      *
447      * @param user the object describing the account to be removed.
448      * @throws DataBackendException if there was an error accessing the data backend.
449      * @throws UnknownEntityException if the user account is not present.
450      */

451     public static void removeUser(User user)
452         throws DataBackendException, UnknownEntityException
453     {
454         getService().removeUser(user);
455     }
456
457
458     /*-----------------------------------------------------------------------
459       Group/Role/Permission management
460       -----------------------------------------------------------------------*/

461     /**
462      * Provides a reference to the Group object that represents the
463      * <a name="global">global group</a>.
464      *
465      * @return a Group object that represents the global group.
466      */

467     public static Group getGlobalGroup()
468     {
469         return getService().getGlobalGroup();
470     }
471
472     /**
473      * Creates a new Group in the system. This is a convenience
474      * method.
475      *
476      * @param name The name of the new Group.
477      * @return An object representing the new Group.
478      * @throws TurbineSecurityException if the Group could not be created.
479      */

480     public static Group createGroup(String JavaDoc name)
481         throws TurbineSecurityException
482     {
483         return getService().addGroup(getNewGroup(name));
484     }
485
486     /**
487      * Creates a new Permission in the system. This is a convenience
488      * method.
489      *
490      * @param name The name of the new Permission.
491      * @return An object representing the new Permission.
492      * @throws TurbineSecurityException if the Permission could not be created.
493      */

494     public static Permission createPermission(String JavaDoc name)
495         throws TurbineSecurityException
496     {
497         return getService().addPermission(getNewPermission(name));
498     }
499
500     /**
501      * Creates a new Role in the system. This is a convenience
502      * method.
503      *
504      * @param name The name of the Role.
505      *
506      * @return An object representing the new Role.
507      *
508      * @throws TurbineSecurityException if the Role could not be created.
509      */

510     public static Role createRole(String JavaDoc name)
511         throws TurbineSecurityException
512     {
513         return getService().addRole(getNewRole(name));
514     }
515
516     /**
517      * Retrieves a named Group.
518      *
519      * @param groupName The name of the Group to be retrieved.
520      *
521      * @return an object representing the Group with specified name.
522      *
523      * @throws DataBackendException if there was an error accessing the data backend.
524      * @throws UnknownEntityException if the Group is not present.
525      */

526     public static Group getGroup(String JavaDoc groupName)
527         throws DataBackendException, UnknownEntityException
528     {
529         return getService().getGroup(groupName);
530     }
531
532     /**
533      * Retrieves a named Group. If the Group does not exist, it creates
534      * a new Group based on the Services Group implementation. It is ok
535      * to pass in null or "" here and then use Group.setName() at a later
536      * point.
537      *
538      * @param groupName The name of the Group to be retrieved.
539      *
540      * @return an object representing the Group with specified name.
541      *
542      * @throws DataBackendException if there was an error accessing the data backend.
543      */

544     public static Group getNewGroup(String JavaDoc groupName)
545         throws DataBackendException
546     {
547         return getService().getNewGroup(groupName);
548     }
549
550     /**
551      * Retrieves a named Permission. If the Permission does not exist, it creates
552      * a new Permission based on the Services Permission implementation. It is ok
553      * to pass in null or "" here and then use Permission.setName() at a later
554      * point.
555      *
556      * @param roleName The name of the Role to be retrieved.
557      *
558      * @return an object representing the Role with specified name.
559      *
560      * @throws TurbineSecurityException if the Role could not be created.
561      */

562     public static Role getNewRole(String JavaDoc roleName)
563         throws TurbineSecurityException
564     {
565         return getService().getNewRole(roleName);
566     }
567
568     /**
569      * Retrieves a named Permission. If the Permission does not exist, it creates
570      * a new Permission based on the Services Permission implementation. It is ok
571      * to pass in null or "" here and then use Permission.setName() at a later
572      * point.
573      *
574      * @param permissionName The name of the Permission to be retrieved.
575      *
576      * @return an object representing the Permission with specified name.
577      *
578      * @throws DataBackendException if there was an error accessing the data backend.
579      */

580     public static Permission getNewPermission(String JavaDoc permissionName)
581         throws DataBackendException
582     {
583         return getService().getNewPermission(permissionName);
584     }
585
586     /**
587      * Retrieves a named Role.
588      *
589      * @param roleName The name of the Role to be retrieved.
590      *
591      * @return an object representing the Role with specified name.
592      *
593      * @throws DataBackendException if there was an error accessing the data backend.
594      * @throws UnknownEntityException if the Role is not present.
595      */

596     public static Role getRole(String JavaDoc roleName)
597         throws DataBackendException, UnknownEntityException
598     {
599         return getService().getRole(roleName);
600     }
601
602     /**
603      * Retrieves a named Permission.
604      *
605      * @param permissionName The name of the Permission to be retrieved.
606      *
607      * @return an object representing the Permission with specified name.
608      *
609      * @throws DataBackendException if there was an error accessing the data backend.
610      * @throws UnknownEntityException if the Permission is not present.
611      */

612     public static Permission getPermission(String JavaDoc permissionName)
613         throws DataBackendException, UnknownEntityException
614     {
615         return getService().getPermission(permissionName);
616     }
617
618     /**
619      * Retrieve a set of Groups that meet the specified Criteria.
620      *
621      * @param criteria A Criteria of Group selection.
622      *
623      * @return a set of Groups that meet the specified Criteria.
624      *
625      * @exception DataBackendException if there is a problem accessing the
626      * storage.
627      */

628     public static GroupSet getGroups(Criteria criteria)
629         throws DataBackendException
630     {
631         return getService().getGroups(criteria);
632     }
633
634
635     /**
636      * Retrieve a set of Roles that meet the specified Criteria.
637      *
638      * @param criteria a Criteria of Roles selection.
639      * @return a set of Roles that meet the specified Criteria.
640      *
641      * @exception DataBackendException if there is a problem accessing the
642      * storage.
643      */

644     public static RoleSet getRoles(Criteria criteria)
645         throws DataBackendException
646     {
647         return getService().getRoles(criteria);
648     }
649
650     /**
651      * Retrieve a set of Permissions that meet the specified Criteria.
652      *
653      * @param criteria a Criteria of Permissions selection.
654      *
655      * @return a set of Permissions that meet the specified Criteria.
656      *
657      * @exception DataBackendException if there is a problem accessing the
658      * storage.
659      */

660     public static PermissionSet getPermissions(Criteria criteria)
661         throws DataBackendException
662     {
663         return getService().getPermissions(criteria);
664     }
665
666     /**
667      * Retrieves all groups defined in the system.
668      *
669      * @return the names of all groups defined in the system.
670      *
671      * @exception DataBackendException if there is a problem accessing the
672      * storage.
673      */

674     public static GroupSet getAllGroups()
675         throws DataBackendException
676     {
677         return getService().getAllGroups();
678     }
679
680     /**
681      * Retrieves all roles defined in the system.
682      *
683      * @return the names of all roles defined in the system.
684      *
685      * @throws DataBackendException if there was an error accessing the data backend.
686      */

687     public static RoleSet getAllRoles()
688         throws DataBackendException
689     {
690         return getService().getAllRoles();
691     }
692
693     /**
694      * Retrieves all permissions defined in the system.
695      *
696      * @return the names of all roles defined in the system.
697      *
698      * @throws DataBackendException if there was an error accessing the data backend.
699      */

700     public static PermissionSet getAllPermissions()
701         throws DataBackendException
702     {
703         return getService().getAllPermissions();
704     }
705
706     /**
707      * Retrieves all permissions associated with a role.
708      *
709      * @param role the role name, for which the permissions are to be retrieved.
710      *
711      * @return an PermissionSet with all permissions for the supplied role.
712      *
713      * @throws DataBackendException if there was an error accessing the data backend.
714      * @throws UnknownEntityException if the role is not present.
715      */

716     public static PermissionSet getPermissions(Role role)
717         throws DataBackendException, UnknownEntityException
718     {
719         return getService().getPermissions(role);
720     }
721
722     /**
723      * Stores Group's attributes. The Groups is required to exist in the system.
724      *
725      * @param group The Group to be stored.
726      *
727      * @throws DataBackendException if there was an error accessing the data backend.
728      * @throws UnknownEntityException if the group does not exist.
729      */

730     public static void saveGroup(Group group)
731         throws DataBackendException, UnknownEntityException
732     {
733         getService().saveGroup(group);
734     }
735
736     /**
737      * Stores Role's attributes. The Roles is required to exist in the system.
738      *
739      * @param role The Role to be stored.
740      *
741      * @throws DataBackendException if there was an error accessing the data backend.
742      * @throws UnknownEntityException if the role does not exist.
743      */

744     public static void saveRole(Role role)
745         throws DataBackendException, UnknownEntityException
746     {
747         getService().saveRole(role);
748     }
749
750     /**
751      * Stores Permission's attributes. The Permissions is required to exist in
752      * the system.
753      *
754      * @param permission The Permission to be stored.
755      * @throws DataBackendException if there was an error accessing the data backend.
756      * @throws UnknownEntityException if the permission does not exist.
757      */

758     public static void savePermission(Permission permission)
759         throws DataBackendException, UnknownEntityException
760     {
761         getService().savePermission(permission);
762     }
763
764     /**
765      * Creates a new group with specified attributes.
766      *
767      * @param group the object describing the group to be created.
768      * @throws DataBackendException if there was an error accessing the data backend.
769      * @throws EntityExistsException if the group already exists.
770      */

771     public static void addGroup(Group group)
772         throws DataBackendException, EntityExistsException
773     {
774         getService().addGroup(group);
775     }
776
777     /**
778      * Creates a new role with specified attributes.
779      *
780      * @param role the objects describing the role to be created.
781      * @throws DataBackendException if there was an error accessing the data backend.
782      * @throws EntityExistsException if the role already exists.
783      */

784     public static void addRole(Role role)
785         throws DataBackendException, EntityExistsException
786     {
787         getService().addRole(role);
788     }
789
790     /**
791      * Creates a new permission with specified attributes.
792      *
793      * @param permission the objects describing the permission to be created.
794      * @throws DataBackendException if there was an error accessing the data backend.
795      * @throws EntityExistsException if the permission already exists.
796      */

797     public static void addPermission(Permission permission)
798         throws DataBackendException, EntityExistsException
799     {
800         getService().addPermission(permission);
801     }
802
803     /**
804      * Removes a Group from the system.
805      *
806      * @param group the object describing group to be removed.
807      *
808      * @throws DataBackendException if there was an error accessing the data backend.
809      * @throws UnknownEntityException if the group does not exist.
810      */

811     public static void removeGroup(Group group)
812         throws DataBackendException, UnknownEntityException
813     {
814         getService().removeGroup(group);
815     }
816
817     /**
818      * Removes a Role from the system.
819      *
820      * @param role The object describing role to be removed.
821      * @throws DataBackendException if there was an error accessing the data backend.
822      * @throws UnknownEntityException if the role does not exist.
823      */

824     public static void removeRole(Role role)
825         throws DataBackendException, UnknownEntityException
826     {
827         getService().removeRole(role);
828     }
829
830     /**
831      * Removes a Permission from the system.
832      *
833      * @param permission The object describing permission to be removed.
834      * @throws DataBackendException if there was an error accessing the data backend.
835      * @throws UnknownEntityException if the permission does not exist.
836      */

837     public static void removePermission(Permission permission)
838         throws DataBackendException, UnknownEntityException
839     {
840         getService().removePermission(permission);
841     }
842
843     /**
844      * Renames an existing Group.
845      *
846      * @param group The object describing the group to be renamed.
847      * @param name the new name for the group.
848      * @throws DataBackendException if there was an error accessing the data backend.
849      * @throws UnknownEntityException if the group does not exist.
850      */

851     public static void renameGroup(Group group, String JavaDoc name)
852         throws DataBackendException, UnknownEntityException
853     {
854         getService().renameGroup(group, name);
855     }
856
857     /**
858      * Renames an existing Role.
859      *
860      * @param role The object describing the role to be renamed.
861      * @param name the new name for the role.
862      * @throws DataBackendException if there was an error accessing the data backend.
863      * @throws UnknownEntityException if the role does not exist.
864      */

865     public static void renameRole(Role role, String JavaDoc name)
866         throws DataBackendException, UnknownEntityException
867     {
868         getService().renameRole(role, name);
869     }
870
871     /**
872      * Renames an existing Permission.
873      *
874      * @param permission The object describing the permission to be renamed.
875      * @param name the new name for the permission.
876      * @throws DataBackendException if there was an error accessing the data backend.
877      * @throws UnknownEntityException if the permission does not exist.
878      */

879     public static void renamePermission(Permission permission, String JavaDoc name)
880         throws DataBackendException, UnknownEntityException
881     {
882         getService().renamePermission(permission, name);
883     }
884 }
885
Popular Tags