1 package org.apache.fulcrum.security.impl.db.entity; 2 3 56 57 import java.util.Iterator ; 58 import org.apache.fulcrum.security.TurbineSecurity; 59 import org.apache.fulcrum.security.entity.Group; 60 import org.apache.fulcrum.security.entity.Role; 61 import org.apache.fulcrum.security.entity.User; 62 import org.apache.fulcrum.security.entity.SecurityEntity; 63 import org.apache.fulcrum.security.util.RoleSet; 64 import org.apache.fulcrum.security.util.TurbineSecurityException; 65 66 83 public class TurbineGroup 84 extends org.apache.fulcrum.security.impl.db.entity.BaseTurbineGroup 85 implements Group, Comparable 86 { 87 90 public TurbineGroup() 91 { 92 } 93 94 99 public TurbineGroup(String name) 100 { 101 setName(name); 102 } 103 104 111 public static Group getGlobalGroup() 112 { 113 return TurbineSecurity.getGlobalGroup(); 114 } 115 116 124 public static Group create(String name) 125 throws TurbineSecurityException 126 { 127 return TurbineSecurity.createGroup(name); 128 } 129 130 132 138 public void save() 139 throws TurbineSecurityException 140 { 141 TurbineSecurity.saveGroup(this); 142 } 143 144 149 public void remove() 150 throws TurbineSecurityException 151 { 152 TurbineSecurity.removeGroup(this); 153 } 154 155 161 public void rename(String name) 162 throws TurbineSecurityException 163 { 164 TurbineSecurity.renameGroup(this, name); 165 } 166 167 175 public void grant(User user, Role role) 176 throws TurbineSecurityException 177 { 178 TurbineSecurity.grant(user, this, role); 179 } 180 181 189 public void grant(User user, RoleSet roleSet) 190 throws TurbineSecurityException 191 { 192 Iterator roles = roleSet.elements(); 193 while(roles.hasNext()) 194 { 195 TurbineSecurity.grant(user, this, (Role)roles.next()); 196 } 197 } 198 199 207 public void revoke(User user, Role role) 208 throws TurbineSecurityException 209 { 210 TurbineSecurity.revoke(user, this, role); 211 } 212 213 221 public void revoke(User user, RoleSet roleSet) 222 throws TurbineSecurityException 223 { 224 Iterator roles = roleSet.elements(); 225 while(roles.hasNext()) 226 { 227 TurbineSecurity.revoke(user, this, (Role)roles.next()); 228 } 229 } 230 231 238 public int compareTo(Object obj) 239 { 240 if(this.getClass() != obj.getClass()) 241 throw new ClassCastException (); 242 String name1 = ((SecurityEntity)obj).getName(); 243 String name2 = this.getName(); 244 return name2.compareTo(name1); 245 } 246 247 } 248 | Popular Tags |