1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
package issrg.pba.rbac.policies; |
47 |
|
|
48 |
|
|
49 |
|
import issrg.pba.PbaException; |
50 |
|
import issrg.pba.rbac.xmlpolicy.XMLPolicyParser; |
51 |
|
import issrg.pba.rbac.Argument; |
52 |
|
import java.util.Map; |
53 |
|
import java.util.Hashtable; |
54 |
|
import java.util.Vector; |
55 |
|
import issrg.pba.rbac.*; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
@author |
63 |
|
@version |
64 |
|
|
65 |
|
|
|
|
| 91.3% |
Uncovered Elements: 9 (104) |
Complexity: 23 |
Complexity Density: 0.45 |
|
66 |
|
public class MSoDRule { |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
protected java.util.Vector mmerVec; |
72 |
|
protected java.util.Vector mmepVec; |
73 |
|
|
74 |
|
protected String contextName; |
75 |
|
protected ContextNamePrincipal policyDN = null; |
76 |
|
|
77 |
|
String firstAction, firstTarget, lastAction, lastTarget; |
78 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
79 |
0
|
protected MSoDRule(){} ... |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
93 |
28
|
public MSoDRule(String context, String firstAction,String firstTarget, String lastAction,String lastTarget, java.util.Vector mmerv, java.util.Vector mmepv) {... |
94 |
28
|
contextName = context; |
95 |
28
|
this.firstAction = firstAction; |
96 |
28
|
this.firstTarget = firstTarget; |
97 |
28
|
this.lastAction = lastAction; |
98 |
28
|
this.lastTarget = lastTarget; |
99 |
28
|
mmerVec = mmerv; |
100 |
28
|
mmepVec = mmepv; |
101 |
28
|
try { |
102 |
28
|
policyDN = new ContextNamePrincipal(contextName); |
103 |
|
} |
104 |
|
catch (Exception e) { |
105 |
0
|
e.printStackTrace(System.err); |
106 |
|
} |
107 |
|
|
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
@param |
115 |
|
|
116 |
|
@return |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
118 |
334
|
public boolean contains(ContextNamePrincipal instanceDN){ ... |
119 |
|
|
120 |
334
|
if ( policyDN.contains(instanceDN) ) { |
121 |
49
|
return true; |
122 |
|
} |
123 |
285
|
return false; |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@return |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
3
|
public ContextNamePrincipal getPolicyContext(){... |
132 |
3
|
return policyDN; |
133 |
|
|
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
@param |
141 |
|
|
142 |
|
@return |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 5 |
Complexity Density: 1.67 |
|
144 |
33
|
public boolean isLastStep(String actionName, String targetName){... |
145 |
33
|
if ((lastAction!= null && lastTarget!= null) && actionName.compareTo(lastAction)==0 && targetName.compareTo(lastTarget) == 0) { |
146 |
3
|
return true; |
147 |
|
} |
148 |
30
|
return false; |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
@param |
157 |
|
@param |
158 |
|
@param |
159 |
|
@param |
160 |
|
@param |
161 |
|
@param |
162 |
|
@param |
163 |
|
|
164 |
|
@return |
165 |
|
|
|
|
| 90.9% |
Uncovered Elements: 7 (77) |
Complexity: 17 |
Complexity Density: 0.38 |
|
166 |
32
|
public boolean separationOfDutiesApplies( RetainedADI retainedADI, ... |
167 |
|
issrg.pba.Credentials creds, |
168 |
|
issrg.pba.Subject subject, issrg.pba.Action a, |
169 |
|
issrg.pba.Target t, java.util.Map environment, |
170 |
|
ContextNamePrincipal instanceDN){ |
171 |
32
|
String userID = (String) ( (issrg.pba.rbac.PermisSubject)subject).getName(); |
172 |
|
|
173 |
32
|
Vector userCredsVec = ((SetOfSubsetsCredentials)creds).getValue(); |
174 |
|
|
175 |
|
|
176 |
32
|
String actionName = a.getActionName(); |
177 |
32
|
String targetName = ((PermisTarget)t).getName(); |
178 |
|
|
179 |
32
|
Vector roleVec = null; |
180 |
32
|
Vector historyVector = retainedADI.getHistoryRecords(policyDN, instanceDN, userID) ; |
181 |
32
|
issrg.pba.Credentials historySSC = null; |
182 |
|
|
183 |
32
|
int historySize = (historyVector==null)?0:historyVector.size(); |
184 |
45
|
for (int j = 0; j< historySize ; ++j ) { |
185 |
13
|
DecisionRecord dr = (DecisionRecord) historyVector.get(j); |
186 |
13
|
if (historySSC == null) { |
187 |
12
|
historySSC = dr.getCreds(); |
188 |
|
} else { |
189 |
1
|
historySSC.union(dr.getCreds() ); |
190 |
|
} |
191 |
|
} |
192 |
32
|
if (historySSC!= null) { |
193 |
12
|
roleVec = ((SetOfSubsetsCredentials)historySSC).getValue(); |
194 |
|
} |
195 |
|
|
196 |
32
|
if (mmerVec != null ) { |
197 |
32
|
boolean matchResult = false; |
198 |
56
|
for (int i = 0; i<mmerVec.size(); ++i) { |
199 |
32
|
MMERUnit mmerUnit = (MMERUnit) mmerVec.get(i); |
200 |
32
|
mmerUnit.startMatch(); |
201 |
32
|
matchResult = mmerUnit.MMERMatches(userCredsVec); |
202 |
32
|
if (matchResult ){ |
203 |
6
|
return true; |
204 |
26
|
} else if (mmerUnit.getMatchCount() == 0 ) { |
205 |
6
|
continue; |
206 |
|
} |
207 |
|
|
208 |
20
|
if (historyVector == null) { |
209 |
0
|
continue; |
210 |
|
} |
211 |
|
|
212 |
20
|
if (roleVec!=null && mmerUnit.MMERMatches(roleVec ) ) { |
213 |
2
|
return true; |
214 |
|
} |
215 |
|
} |
216 |
|
} |
217 |
|
|
218 |
24
|
if (historyVector == null) { |
219 |
|
|
220 |
0
|
return false; |
221 |
|
} |
222 |
24
|
if ( mmepVec != null ) { |
223 |
24
|
boolean matchResult = false; |
224 |
54
|
for (int i = 0; i<mmepVec.size(); ++i) { |
225 |
38
|
MMEPUnit mmepUnit = (MMEPUnit) mmepVec.get(i); |
226 |
38
|
mmepUnit.startMatch(); |
227 |
38
|
matchResult = mmepUnit.MMEPMatches(actionName, targetName); |
228 |
|
|
229 |
38
|
if ( mmepUnit.getMatchCount() == 0 ) { |
230 |
13
|
continue; |
231 |
|
} |
232 |
|
|
233 |
25
|
historySize = historyVector.size(); |
234 |
28
|
for (int j = 0; j< historySize ; ++j ) { |
235 |
11
|
DecisionRecord dr = (DecisionRecord) historyVector.get(j); |
236 |
11
|
if ( mmepUnit.MMEPMatches(dr.getAction(), dr.getTarget() ) ) { |
237 |
8
|
return true; |
238 |
|
} |
239 |
|
} |
240 |
|
} |
241 |
|
} |
242 |
|
|
243 |
16
|
return false; |
244 |
|
} |
245 |
|
|
246 |
|
|
247 |
|
} |
248 |
|
|
249 |
|
|