1 package org.apache.turbine.om.security; 2 3 18 19 import java.sql.Connection ; 20 import java.util.Iterator ; 21 22 import org.apache.turbine.services.security.TurbineSecurity; 23 import org.apache.turbine.util.security.PermissionSet; 24 import org.apache.turbine.util.security.TurbineSecurityException; 25 26 35 public class TurbineRole extends SecurityObject implements Role 36 { 37 40 public TurbineRole() 41 { 42 super(); 43 } 44 45 50 public TurbineRole(String name) 51 { 52 super(name); 53 } 54 55 56 private PermissionSet permissionSet = null; 57 58 64 public PermissionSet getPermissions() 65 throws Exception 66 { 67 return permissionSet; 68 } 69 70 75 public void setPermissions(PermissionSet permissionSet) 76 { 77 this.permissionSet = permissionSet; 78 } 79 80 82 89 public Role create(String name) 90 throws TurbineSecurityException 91 { 92 Role role = new TurbineRole(name); 94 TurbineSecurity.addRole(role); 95 return role; 96 } 97 98 104 public void save() 105 throws TurbineSecurityException 106 { 107 TurbineSecurity.saveRole(this); 108 } 109 110 116 public void save(Connection conn) throws Exception 117 { 118 throw new Exception ("not implemented"); 119 } 120 121 127 public void save(String dbname) throws Exception 128 { 129 throw new Exception ("not implemented"); 130 } 131 132 137 public void remove() 138 throws TurbineSecurityException 139 { 140 TurbineSecurity.removeRole(this); 141 } 142 143 149 public void rename(String name) 150 throws TurbineSecurityException 151 { 152 TurbineSecurity.renameRole(this, name); 153 } 154 155 162 public void grant(Permission permission) 163 throws TurbineSecurityException 164 { 165 TurbineSecurity.grant(this, permission); 166 } 167 168 175 public void grant(PermissionSet permissionSet) 176 throws TurbineSecurityException 177 { 178 for (Iterator permissions = permissionSet.iterator(); permissions.hasNext();) 179 { 180 TurbineSecurity.grant(this, (Permission) permissions.next()); 181 } 182 } 183 184 191 public void revoke(Permission permission) 192 throws TurbineSecurityException 193 { 194 TurbineSecurity.revoke(this, permission); 195 } 196 197 204 public void revoke(PermissionSet permissionSet) 205 throws TurbineSecurityException 206 { 207 for (Iterator permissions = permissionSet.iterator(); permissions.hasNext();) 208 { 209 TurbineSecurity.revoke(this, (Permission) permissions.next()); 210 } 211 } 212 } 213 | Popular Tags |