1 30 31 34 package com.nightlabs.ipanema.security; 35 36 import java.util.Iterator ; 37 38 48 public class UserGroupRef extends UserRef 49 { 50 51 public UserGroupRef() { } 52 57 public UserGroupRef(Authority _authority, User _user, boolean _visible) 58 { 59 super(_authority, _user, _visible); 60 if (!(_user instanceof UserGroup)) 61 throw new IllegalArgumentException ("user must be an instance of UserGroup!"); 62 } 63 64 67 protected void _addRole(Role role, int incRefCount) 68 { 69 super._addRole(role, incRefCount); 70 71 UserGroup userGroup = (UserGroup)getUser(); 73 74 for (Iterator itUsers = userGroup.getUsers().iterator(); itUsers.hasNext(); ) { 76 User user = (User)itUsers.next(); 77 UserRef userRef = user.getUserRef(getAuthorityID()); 78 if (userRef == null) 79 LOGGER.warn("User \""+user.getUserID()+"\" is member of UserGroup \""+getUserID()+"\", which has a UserGroupRef in authority \""+getAuthorityID()+"\", but there is no UserRef for this User in this Authority!", new IllegalStateException ("Missing UserRef!")); 80 else 81 userRef._addRole(role, incRefCount); 82 } 83 } 84 85 88 protected void _removeRole(Role role, int decRefCount) 89 { 90 UserGroup userGroup = (UserGroup)getUser(); 91 92 for (Iterator itUsers = userGroup.getUsers().iterator(); itUsers.hasNext(); ) { 94 User user = (User)itUsers.next(); 95 UserRef userRef = user.getUserRef(getAuthorityID()); 96 if (userRef == null) 97 LOGGER.warn("User \""+user.getUserID()+"\" is member of UserGroup \""+getUserID()+"\", which has a UserGroupRef in authority \""+getAuthorityID()+"\", but there is no UserRef for this User in this Authority!", new IllegalStateException ("Missing UserRef!")); 98 else 99 userRef._removeRole(role, decRefCount); 100 } 101 102 super._removeRole(role, decRefCount); 103 } 104 105 } 106 | Popular Tags |