1 18 package net.sf.drftpd.master.config; 19 20 import java.util.Collection ; 21 import java.util.Iterator ; 22 23 import net.sf.drftpd.master.usermanager.User; 24 25 29 public class Permission { 30 private Collection _users; 31 public Permission(Collection users) { 32 _users = users; 33 } 34 35 public boolean check(User user) { 36 for (Iterator iter = _users.iterator(); iter.hasNext();) { 37 String aclUser = (String ) iter.next(); 38 boolean allow = true; 39 if (aclUser.charAt(0) == '!') { 40 allow = false; 41 aclUser = aclUser.substring(1); 42 } 43 if (aclUser.equals("*")) { 44 return allow; 45 } 46 else if(aclUser.charAt(0) == '-') { 47 if(aclUser.substring(1).equals(user.getUsername())) { 49 return allow; 50 } 51 continue; 52 } 53 else if (aclUser.charAt(0) == '=') { 54 if(user.isMemberOf(aclUser.substring(1))) { 56 return allow; 57 } 58 } 59 else { 60 if(user.isMemberOf(aclUser)) { 62 return allow; 63 } 64 } 65 } 66 return false; 68 } 69 70 } 71 | Popular Tags |