KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > security > DlogRole


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 dlog4j.security;
17
18 import java.io.IOException JavaDoc;
19
20 import org.xml.sax.SAXException JavaDoc;
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 JavaDoc res, String JavaDoc opt, String JavaDoc rng) throws IOException JavaDoc, SAXException JavaDoc{
50         SecurityConfig sc = SecurityConfig.getConfig();
51         Resource oRes = sc.getResourceByName(res);
52         Operation oOpt = sc.getOperationByName(opt);
53         Range oRng = sc.getRangeByName(rng);
54         Privilege pvg = new PrivilegeImpl(oRes,oOpt,oRng);
55         privileges.add(pvg);
56     }
57
58     public int getId() {
59         return id;
60     }
61     public void setId(int id) {
62         this.id = id;
63     }
64     public String JavaDoc toString() {
65         return "ROLE:("+id+','+name+','+desc+','+privileges.size()+')';
66     }
67 }
68
Popular Tags