1 package org.apache.turbine.om.security; 2 3 /* 4 * Copyright 2001-2004 The Apache Software Foundation. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License") 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 import org.apache.turbine.util.security.PermissionSet; 20 import org.apache.turbine.util.security.TurbineSecurityException; 21 22 /** 23 * This class represents a role played by the User associated with the 24 * current Session. 25 * 26 * @author <a HREF="mailto:frank.kim@clearink.com">Frank Y. Kim</a> 27 * @author <a HREF="mailto:john.mcnally@clearink.com">John D. McNally</a> 28 * @author <a HREF="mailto:bmclaugh@algx.net">Brett McLaughlin</a> 29 * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 30 * @version $Id: Role.java,v 1.4.2.2 2004/05/20 03:05:17 seade Exp $ 31 */ 32 public interface Role extends SecurityEntity 33 { 34 /** 35 * Returns the set of Permissions associated with this Role. 36 * 37 * @return A PermissionSet. 38 * @exception Exception A generic exception. 39 */ 40 PermissionSet getPermissions() 41 throws Exception; 42 43 /** 44 * Sets the Permissions associated with this Role. 45 * 46 * @param permissionSet A PermissionSet. 47 */ 48 void setPermissions(PermissionSet permissionSet); 49 50 // These following methods are wrappers around TurbineSecurity 51 52 /** 53 * Creates a new Role in the system. 54 * 55 * @param name The name of the new Role. 56 * @return An object representing the new Role. 57 * @throws TurbineSecurityException if the Role could not be created. 58 */ 59 Role create(String name) 60 throws TurbineSecurityException; 61 62 /** 63 * Makes changes made to the Role attributes permanent. 64 * 65 * @throws TurbineSecurityException if there is a problem while 66 * saving data. 67 */ 68 void save() 69 throws TurbineSecurityException; 70 71 /** 72 * Removes a role from the system. 73 * 74 * @throws TurbineSecurityException if the Role could not be removed. 75 */ 76 void remove() 77 throws TurbineSecurityException; 78 79 /** 80 * Renames the role. 81 * 82 * @param name The new Role name. 83 * @throws TurbineSecurityException if the Role could not be renamed. 84 */ 85 void rename(String name) 86 throws TurbineSecurityException; 87 88 /** 89 * Grants a Permission to this Role. 90 * 91 * @param permission A Permission. 92 * @throws TurbineSecurityException if there is a problem while assigning 93 * the Permission. 94 */ 95 void grant(Permission permission) 96 throws TurbineSecurityException; 97 98 /** 99 * Grants Permissions from a PermissionSet to this Role. 100 * 101 * @param permissionSet A PermissionSet. 102 * @throws TurbineSecurityException if there is a problem while assigning 103 * the Permissions. 104 */ 105 void grant(PermissionSet permissionSet) 106 throws TurbineSecurityException; 107 108 /** 109 * Revokes a Permission from this Role. 110 * 111 * @param permission A Permission. 112 * @throws TurbineSecurityException if there is a problem while unassigning 113 * the Permission. 114 */ 115 void revoke(Permission permission) 116 throws TurbineSecurityException; 117 118 /** 119 * Revokes Permissions from a PermissionSet from this Role. 120 * 121 * @param permissionSet A PermissionSet. 122 * @throws TurbineSecurityException if there is a problem while unassigning 123 * the Permissions. 124 */ 125 void revoke(PermissionSet permissionSet) 126 throws TurbineSecurityException; 127 } 128