1 package org.apache.turbine.services.security.torque; 2 3 18 19 import java.util.Iterator ; 20 21 import org.apache.torque.om.Persistent; 22 23 import org.apache.turbine.om.security.Group; 24 import org.apache.turbine.om.security.Role; 25 import org.apache.turbine.om.security.User; 26 import org.apache.turbine.services.security.TurbineSecurity; 27 import org.apache.turbine.util.security.RoleSet; 28 import org.apache.turbine.util.security.TurbineSecurityException; 29 30 50 51 public class TorqueGroup 52 extends TorqueObject 53 implements Group, 54 Comparable , 55 Persistent 56 { 57 60 public TorqueGroup() 61 { 62 super(); 63 } 64 65 70 71 public TorqueGroup(String name) 72 { 73 super(name); 74 } 75 76 84 public TorqueGroup(Persistent obj) 85 { 86 super(obj); 87 } 88 89 97 98 public Persistent getPersistentObj() 99 { 100 if (obj == null) 101 { 102 obj = GroupPeerManager.newPersistentInstance(); 103 } 104 return obj; 105 } 106 107 112 public String getName() 113 { 114 return GroupPeerManager.getGroupName(getPersistentObj()); 115 } 116 117 122 public void setName(String name) 123 { 124 GroupPeerManager.setGroupName(getPersistentObj(), name); 125 } 126 127 132 public int getId() 133 { 134 return GroupPeerManager.getIdAsObj(getPersistentObj()).intValue(); 135 } 136 137 142 public Integer getIdAsObj() 143 { 144 return GroupPeerManager.getIdAsObj(getPersistentObj()); 145 } 146 147 152 public void setId(int id) 153 { 154 GroupPeerManager.setId(getPersistentObj(), id); 155 } 156 157 164 public static Group getGlobalGroup() 165 { 166 return TurbineSecurity.getGlobalGroup(); 167 } 168 169 177 public static Group create(String name) 178 throws TurbineSecurityException 179 { 180 return TurbineSecurity.createGroup(name); 181 } 182 183 185 191 public void save() 192 throws TurbineSecurityException 193 { 194 TurbineSecurity.saveGroup(this); 195 } 196 197 202 public void remove() 203 throws TurbineSecurityException 204 { 205 TurbineSecurity.removeGroup(this); 206 } 207 208 214 public void rename(String name) 215 throws TurbineSecurityException 216 { 217 TurbineSecurity.renameGroup(this, name); 218 } 219 220 228 public void grant(User user, Role role) 229 throws TurbineSecurityException 230 { 231 TurbineSecurity.grant(user, this, role); 232 } 233 234 242 public void grant(User user, RoleSet roleSet) 243 throws TurbineSecurityException 244 { 245 Iterator roles = roleSet.iterator(); 246 while (roles.hasNext()) 247 { 248 TurbineSecurity.grant(user, this, (Role) roles.next()); 249 } 250 } 251 252 260 public void revoke(User user, Role role) 261 throws TurbineSecurityException 262 { 263 TurbineSecurity.revoke(user, this, role); 264 } 265 266 274 public void revoke(User user, RoleSet roleSet) 275 throws TurbineSecurityException 276 { 277 Iterator roles = roleSet.iterator(); 278 while (roles.hasNext()) 279 { 280 TurbineSecurity.revoke(user, this, (Role) roles.next()); 281 } 282 } 283 284 } 285 286 | Popular Tags |