01: /*
02: * This program is free software; you can redistribute it and/or modify
03: * it under the terms of the GNU General Public License as published by
04: * the Free Software Foundation; either version 2 of the License, or
05: * (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * 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;
19: import java.util.List;
20:
21: import web.security.Group;
22: import web.security.Privilege;
23: import web.security.Role;
24:
25: /**
26: * 用户组的实现类
27: * @author liudong
28: */
29: public class GroupImpl implements Group, Serializable {
30:
31: String name;
32: String desc;
33: List roles;
34:
35: /* (non-Javadoc)
36: * @see com.clickcom.web.security.Actor#roles()
37: */
38: public Role[] roles() {
39: if (roles == null)
40: return null;
41: return (Role[]) roles.toArray(new Role[roles.size()]);
42: }
43:
44: /* (non-Javadoc)
45: * @see com.clickcom.web.security.Actor#canDo(com.clickcom.web.security.Privilege)
46: */
47: public boolean canDo(Privilege pvg) {
48: for (int i = 0; roles != null && i < roles.size(); i++) {
49: if (((Role) roles.get(i)).canDo(pvg))
50: return true;
51: }
52: return false;
53: }
54:
55: /* (non-Javadoc)
56: * @see com.clickcom.web.security.Actor#getName()
57: */
58: public String getName() {
59: return name;
60: }
61:
62: /* (non-Javadoc)
63: * @see com.clickcom.web.security.Group#getDesc()
64: */
65: public String getDesc() {
66: return desc;
67: }
68:
69: public void setDesc(String desc) {
70: this .desc = desc;
71: }
72:
73: public void setName(String name) {
74: this .name = name;
75: }
76:
77: public List getRoles() {
78: return roles;
79: }
80:
81: public void setRoles(List roles) {
82: this.roles = roles;
83: }
84: }
|