KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 import web.security.Operation;
21 import web.security.Privilege;
22 import web.security.Range;
23 import web.security.Resource;
24
25
26 /**
27  * 操作权限的实现类
28  * @author liudong
29  */

30 public class PrivilegeImpl implements Privilege, Serializable JavaDoc {
31     
32     Resource resource;
33     Operation operation;
34     Range range;
35
36     public PrivilegeImpl() {
37     }
38
39     public PrivilegeImpl(Resource resource,Operation operation,Range range) {
40         this.resource = resource;
41         this.operation = operation;
42         this.range = range;
43     }
44
45     /* (non-Javadoc)
46      * @see com.clickcom.web.security.Privilege#equals(com.clickcom.web.security.Privilege)
47      */

48     public boolean equals(Privilege pvg) {
49         if(pvg==this)
50             return true;
51         if(resource==null || operation==null || range==null)
52             return false;
53         if(pvg==null||pvg.getResource()==null||pvg.getOperation()==null||pvg.getRange()==null)
54             return false;
55         boolean bResource = resource.equals(pvg.getResource());
56         boolean bOperation= operation.equals(pvg.getOperation());
57         boolean bRange = range.equals(pvg.getRange());
58         return bResource && bOperation && bRange;
59     }
60
61     /* (non-Javadoc)
62      * @see com.clickcom.web.security.Privilege#getResource()
63      */

64     public Resource getResource() {
65         return resource;
66     }
67
68     /* (non-Javadoc)
69      * @see com.clickcom.web.security.Privilege#getOperation()
70      */

71     public Operation getOperation() {
72         return operation;
73     }
74
75     /* (non-Javadoc)
76      * @see com.clickcom.web.security.Privilege#getRange()
77      */

78     public Range getRange() {
79         return range;
80     }
81
82     public void setOperation(Operation operation) {
83         this.operation = operation;
84     }
85     public void setRange(Range range) {
86         this.range = range;
87     }
88     public void setResource(Resource resource) {
89         this.resource = resource;
90     }
91
92 }
93
Popular Tags