1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package fulmine.context;
17
18 import fulmine.model.field.IField;
19 import fulmine.util.Utils;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class DefaultPermissionProfile implements IPermissionProfile
37 {
38
39 private IPermissionProfile applicationPermissions;
40
41 public boolean contains(byte application, short permission)
42 {
43 if (application == IPermissionProfile.DEFAULT_APPLICATION
44 && permission == IPermissionProfile.DEFAULT_PERMISSION)
45 {
46 return true;
47 }
48 if (getApplicationPermissions() != null)
49 {
50 return getApplicationPermissions().contains(application, permission);
51 }
52 return false;
53 }
54
55 public boolean matches(byte receivedApplication, short receivedPermission,
56 byte matchWithApplication, short matchWithPermission)
57 {
58 if (matchWithApplication == IPermissionProfile.DEFAULT_APPLICATION
59 && matchWithPermission == IPermissionProfile.DEFAULT_PERMISSION)
60 {
61 return true;
62 }
63 if (getApplicationPermissions() != null)
64 {
65 return getApplicationPermissions().matches(receivedApplication,
66 receivedPermission, matchWithApplication, matchWithPermission);
67 }
68 return false;
69 }
70
71
72
73
74
75
76
77 public IPermissionProfile getApplicationPermissions()
78 {
79 return this.applicationPermissions;
80 }
81
82
83
84
85
86
87
88
89 public void setApplicationPermissions(
90 IPermissionProfile applicationPermissions)
91 {
92 this.applicationPermissions = applicationPermissions;
93 }
94
95 public byte getApplicationCode()
96 {
97 return this.applicationPermissions == null ? DEFAULT_APPLICATION
98 : this.applicationPermissions.getApplicationCode();
99 }
100
101 public short getPermissionCode()
102 {
103 return this.applicationPermissions == null ? DEFAULT_PERMISSION
104 : this.applicationPermissions.getPermissionCode();
105 }
106
107 @Override
108 public String toString()
109 {
110 return Utils.string(this, "application=" + getApplicationCode()
111 + ", permission=" + getPermissionCode());
112 }
113 }