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:
20: import web.security.Operation;
21: import web.security.Privilege;
22: import web.security.Range;
23: import web.security.Resource;
24:
25: /**
26: * 操作权限的实现类
27: * @author liudong
28: */
29: public class PrivilegeImpl implements Privilege, Serializable {
30:
31: Resource resource;
32: Operation operation;
33: Range range;
34:
35: public PrivilegeImpl() {
36: }
37:
38: public PrivilegeImpl(Resource resource, Operation operation,
39: 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
54: || pvg.getOperation() == null || pvg.getRange() == null)
55: return false;
56: boolean bResource = resource.equals(pvg.getResource());
57: boolean bOperation = operation.equals(pvg.getOperation());
58: boolean bRange = range.equals(pvg.getRange());
59: return bResource && bOperation && bRange;
60: }
61:
62: /* (non-Javadoc)
63: * @see com.clickcom.web.security.Privilege#getResource()
64: */
65: public Resource getResource() {
66: return resource;
67: }
68:
69: /* (non-Javadoc)
70: * @see com.clickcom.web.security.Privilege#getOperation()
71: */
72: public Operation getOperation() {
73: return operation;
74: }
75:
76: /* (non-Javadoc)
77: * @see com.clickcom.web.security.Privilege#getRange()
78: */
79: public Range getRange() {
80: return range;
81: }
82:
83: public void setOperation(Operation operation) {
84: this .operation = operation;
85: }
86:
87: public void setRange(Range range) {
88: this .range = range;
89: }
90:
91: public void setResource(Resource resource) {
92: this.resource = resource;
93: }
94:
95: }
|