KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > web > security > impl > GroupImpl


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package web.security.impl;
17
18 import java.io.Serializable JavaDoc;
19 import java.util.List JavaDoc;
20
21 import web.security.Group;
22 import web.security.Privilege;
23 import web.security.Role;
24
25
26 /**
27  * 用户组的实现类
28  * @author liudong
29  */

30 public class GroupImpl implements Group, Serializable JavaDoc {
31
32     String JavaDoc name;
33     String JavaDoc desc;
34     List JavaDoc roles;
35     
36     /* (non-Javadoc)
37      * @see com.clickcom.web.security.Actor#roles()
38      */

39     public Role[] roles() {
40         if(roles == null)
41             return null;
42         return (Role[])roles.toArray(new Role[roles.size()]);
43     }
44
45     /* (non-Javadoc)
46      * @see com.clickcom.web.security.Actor#canDo(com.clickcom.web.security.Privilege)
47      */

48     public boolean canDo(Privilege pvg) {
49         for(int i=0;roles!=null&&i<roles.size();i++){
50             if(((Role)roles.get(i)).canDo(pvg))
51                 return true;
52         }
53         return false;
54     }
55
56     /* (non-Javadoc)
57      * @see com.clickcom.web.security.Actor#getName()
58      */

59     public String JavaDoc getName() {
60         return name;
61     }
62
63     /* (non-Javadoc)
64      * @see com.clickcom.web.security.Group#getDesc()
65      */

66     public String JavaDoc getDesc() {
67         return desc;
68     }
69
70     public void setDesc(String JavaDoc desc) {
71         this.desc = desc;
72     }
73     public void setName(String JavaDoc name) {
74         this.name = name;
75     }
76     public List JavaDoc getRoles() {
77         return roles;
78     }
79     public void setRoles(List JavaDoc roles) {
80         this.roles = roles;
81     }
82 }
83
Popular Tags