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 dlog4j.security;
17:
18: import java.io.IOException;
19:
20: import org.xml.sax.SAXException;
21:
22: import web.security.Operation;
23: import web.security.Privilege;
24: import web.security.Range;
25: import web.security.Resource;
26: import web.security.impl.PrivilegeImpl;
27: import web.security.impl.RoleImpl;
28:
29: /**
30: * DLOG平台的角色扩展
31: * @author Winter Lau
32: */
33: public class DlogRole extends RoleImpl {
34:
35: public final static int ROLE_GUEST = 1;
36: public final static int ROLE_COMMON = 2;
37: public final static int ROLE_FRIEND = 4;
38: public final static int ROLE_BUDDY = 8;
39: public final static int ROLE_MANAGER = 16;
40:
41: protected int id;
42:
43: /**
44: * 该方法是提供给Digester使用,请不要使用该方法
45: * @param pvg
46: * @throws SAXException
47: * @throws IOException
48: */
49: public void addPrivilege(String res, String opt, String rng)
50: throws IOException, SAXException {
51: SecurityConfig sc = SecurityConfig.getConfig();
52: Resource oRes = sc.getResourceByName(res);
53: Operation oOpt = sc.getOperationByName(opt);
54: Range oRng = sc.getRangeByName(rng);
55: Privilege pvg = new PrivilegeImpl(oRes, oOpt, oRng);
56: privileges.add(pvg);
57: }
58:
59: public int getId() {
60: return id;
61: }
62:
63: public void setId(int id) {
64: this .id = id;
65: }
66:
67: public String toString() {
68: return "ROLE:(" + id + ',' + name + ',' + desc + ','
69: + privileges.size() + ')';
70: }
71: }
|