01: package com.jat.business.privileges;
02:
03: import com.jat.business.BusinessObject;
04: import com.jat.business.BusinessObjectProperties;
05: import com.jat.business.JatUser;
06:
07: /**
08: * <p>Title: JAT</p>
09: * <p>Description: </p>
10: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
11: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
12: * @author stf
13: * @version 1.0
14: * @since 1.2
15: */
16:
17: public class Privilege extends BusinessObject {
18:
19: public static final String NAME = "PRIVILEGE_NAME";
20:
21: public String getName() {
22: return super .getField(NAME);
23: }
24:
25: public void setName(String name) {
26: super .putField(NAME, name);
27: }
28:
29: public Privilegeable getCondition() {
30: return this .condition;
31: }
32:
33: public void setCondition(Privilegeable condition) {
34: this .condition = condition;
35: }
36:
37: public boolean hasPrivilege(String functionality, JatUser user,
38: Object object) {
39: if (!this .getName().equals(functionality))
40: return false;
41: if (condition != null)
42: return condition.hasPrivilege(user, object);
43: return true;
44: }
45:
46: public boolean equals(Object other) {
47: if (other == this )
48: return true;
49: if (other == null)
50: return false;
51: if (getClass() != other.getClass())
52: return false;
53: Privilege priv = (Privilege) other;
54: return this .getName() != null
55: && this .getName().equals(priv.getName());
56: }
57:
58: protected Privilege(String dataSourceName) {
59: super (dataSourceName, NAME);
60: }
61:
62: protected Privilege(String dataSourceName,
63: BusinessObjectProperties props) {
64: super (dataSourceName, props, NAME);
65: }
66:
67: private Privilegeable condition;
68: }
|