1 16 package web.security.impl; 17 18 import java.io.Serializable ; 19 import java.util.List ; 20 import java.util.Vector ; 21 22 import web.security.Privilege; 23 import web.security.Role; 24 25 26 30 public class RoleImpl implements Role, Serializable { 31 32 protected List privileges; 33 protected String name; 34 protected String desc; 35 36 public RoleImpl(){ 37 this(null,null); 38 } 39 40 public RoleImpl(String name, String desc){ 41 this.name = name; 42 this.desc = desc; 43 this.privileges = new Vector (); 44 } 45 46 49 public Privilege[] privileges() { 50 if(privileges==null) 51 return null; 52 return (Privilege[])privileges.toArray(new Privilege[privileges.size()]); 53 } 54 55 58 public boolean canDo(Privilege pvg) { 59 for(int i=0;privileges!=null&&i<privileges.size();i++){ 60 Privilege p = (Privilege)privileges.get(i); 61 boolean bEqual = p.equals(pvg); 62 if(bEqual) 64 return true; 65 break; 66 } 67 return false; 68 } 69 70 73 public String getName() { 74 return name; 75 } 76 77 80 public String getDesc() { 81 return desc; 82 } 83 84 public void setDesc(String desc) { 85 this.desc = desc; 86 } 87 public void setName(String name) { 88 this.name = name; 89 } 90 91 public List getPrivileges() { 92 return privileges; 93 } 94 public void setPrivileges(List privileges) { 95 this.privileges = privileges; 96 } 97 public String toString() { 98 return "ROLE:("+name+','+desc+')'; 99 } 100 } 101 | Popular Tags |