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 |
|
package issrg.pba.rbac; |
33 |
|
|
34 |
|
import java.util.Vector; |
35 |
|
import issrg.pba.Credentials; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@author |
45 |
|
@author |
46 |
|
@author |
47 |
|
@version |
48 |
|
|
49 |
|
|
|
|
| 96.3% |
Uncovered Elements: 6 (164) |
Complexity: 31 |
Complexity Density: 0.49 |
|
50 |
|
public class SetOfSubsetsCredentials implements Credentials{ |
51 |
|
private Vector Creds=new Vector(); |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
57 |
7593
|
public SetOfSubsetsCredentials(){}... |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
@param |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
64 |
97
|
public SetOfSubsetsCredentials(Credentials [] Creds){... |
65 |
291
|
for(int i=0;i<Creds.length;i++){ |
66 |
194
|
this.Creds.add(Creds[i]); |
67 |
|
} |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
8271
|
public SetOfSubsetsCredentials(Vector creds){... |
77 |
8271
|
Creds = new Vector(creds); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@return |
84 |
|
|
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
19024
|
public Vector getValue (){... |
87 |
19024
|
return new Vector(Creds); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@param |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
@return |
100 |
|
|
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
9765
|
public boolean contains(Credentials subSet){... |
103 |
9765
|
return _contains_(subSet, false); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@param |
112 |
|
|
113 |
|
|
114 |
|
@return |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
116 |
2
|
public boolean partOf(Credentials superSet){... |
117 |
2
|
return _contains_(superSet, true); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
@param |
126 |
|
@param |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
@return |
131 |
|
|
|
|
| 96.6% |
Uncovered Elements: 1 (29) |
Complexity: 5 |
Complexity Density: 0.33 |
|
132 |
9767
|
private boolean _contains_(Credentials subSet, boolean reverse){... |
133 |
9767
|
Vector v; |
134 |
|
|
135 |
9767
|
if (subSet instanceof SetOfSubsetsCredentials){ |
136 |
9764
|
v = ((SetOfSubsetsCredentials)subSet).getValue(); |
137 |
|
}else{ |
138 |
3
|
v = new java.util.Vector(); |
139 |
3
|
if (subSet!=null) v.add(subSet); |
140 |
|
} |
141 |
|
|
142 |
9767
|
Vector lhs = reverse?v:Creds; |
143 |
9767
|
Vector rhs = reverse?Creds:v; |
144 |
|
|
145 |
|
|
146 |
9767
|
cont_loop: |
147 |
9986
|
for (int i=rhs.size(); i-->0; ){ |
148 |
4944
|
Credentials c = (Credentials)rhs.get(i); |
149 |
|
|
150 |
7067
|
for (int j=lhs.size(); j-->0; ){ |
151 |
2342
|
if (((Credentials)lhs.get(j)).contains(c)){ |
152 |
|
|
153 |
219
|
continue cont_loop; |
154 |
|
} |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
4725
|
return false; |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
5042
|
return true; |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
@param |
172 |
|
|
173 |
|
@return |
174 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
175 |
3869
|
public boolean equals(Credentials creds){... |
176 |
3869
|
return contains(creds) && creds.contains(this); |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
@param |
184 |
|
|
185 |
|
@return |
186 |
|
|
187 |
|
@see |
188 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
189 |
3856
|
public boolean equals(Object o){... |
190 |
3856
|
if (o instanceof Credentials){ |
191 |
3856
|
return equals((Credentials)o); |
192 |
|
} |
193 |
|
|
194 |
0
|
return false; |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
@return |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
107
|
public Object clone(){... |
203 |
107
|
return intersection(this); |
204 |
|
} |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
@param |
213 |
|
|
214 |
|
@return |
215 |
|
|
216 |
|
|
|
|
| 98.6% |
Uncovered Elements: 1 (74) |
Complexity: 19 |
Complexity Density: 0.45 |
|
217 |
3305
|
public Credentials intersection(Credentials set){... |
218 |
3305
|
Vector alien; |
219 |
3305
|
if (set instanceof SetOfSubsetsCredentials){ |
220 |
2998
|
alien = ((SetOfSubsetsCredentials)set).getValue(); |
221 |
|
}else{ |
222 |
307
|
alien = new Vector(); |
223 |
307
|
if (set!=null) alien.add(set); |
224 |
|
} |
225 |
|
|
226 |
3305
|
Vector r = new Vector(); |
227 |
3305
|
int credsize = Creds.size(); |
228 |
3305
|
int aliensize = alien.size(); |
229 |
|
|
230 |
7928
|
for (int i = 0; i < credsize; i++) { |
231 |
4623
|
Credentials c = (Credentials) Creds.get(i); |
232 |
4623
|
Credentials m = null; |
233 |
9653
|
for (int j = 0; j < aliensize; j++) { |
234 |
5030
|
Credentials c1 = ((Credentials) alien.get(j)).intersection(c); |
235 |
5030
|
if (c1 != null) { |
236 |
4068
|
if (m == null) { |
237 |
3951
|
m = c1; |
238 |
|
} else { |
239 |
117
|
if (c1.contains(m)) { |
240 |
11
|
m = c1; |
241 |
|
} else { |
242 |
106
|
if ((!c1.contains(m)) && (!m.contains(c1))) { |
243 |
98
|
m = m.union(c1); |
244 |
|
} |
245 |
|
} |
246 |
|
} |
247 |
|
} |
248 |
|
} |
249 |
4623
|
if (m != null) { |
250 |
3951
|
r.add(m); |
251 |
|
} |
252 |
|
} |
253 |
|
|
254 |
3305
|
credsize = r.size(); |
255 |
3305
|
Vector l = new Vector(); |
256 |
7256
|
for (int i = 0; i < credsize; i++) { |
257 |
3951
|
Credentials c = (Credentials) r.get(i); |
258 |
3951
|
Credentials temp = null; |
259 |
4913
|
for (int j = 0; j < l.size(); j++) { |
260 |
962
|
temp = (Credentials) l.get(j); |
261 |
962
|
if ((c.contains(temp)) && (!c.equals(temp))) { |
262 |
1
|
l.remove(j); |
263 |
|
} |
264 |
|
} |
265 |
3951
|
if (temp == null) { |
266 |
2990
|
l.add(c.clone()); |
267 |
|
} else { |
268 |
961
|
if (!temp.contains(c)) l.add(c.clone()); |
269 |
|
} |
270 |
|
} |
271 |
3305
|
SetOfSubsetsCredentials a = new SetOfSubsetsCredentials(l); |
272 |
3305
|
if (l.isEmpty()) return a; |
273 |
3087
|
while (a.getValue().get(0) instanceof issrg.pba.rbac.SetOfSubsetsCredentials) a = (SetOfSubsetsCredentials) a.getValue().get(0); |
274 |
2990
|
return a; |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
} |
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
@param |
306 |
|
|
307 |
|
@return |
308 |
|
|
309 |
|
|
|
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 7 |
Complexity Density: 0.39 |
|
310 |
2915
|
public Credentials union(Credentials set){... |
311 |
2915
|
Vector alien; |
312 |
|
|
313 |
2915
|
if (set instanceof SetOfSubsetsCredentials){ |
314 |
2914
|
alien = ((SetOfSubsetsCredentials)set).getValue(); |
315 |
|
}else{ |
316 |
1
|
alien = new Vector(); |
317 |
1
|
if (set!=null) alien.add(set); |
318 |
|
} |
319 |
|
|
320 |
2915
|
Vector r = new Vector(); |
321 |
2915
|
Vector p = Creds; |
322 |
|
|
323 |
|
|
324 |
8745
|
while (p!=null){ |
325 |
|
|
326 |
8903
|
for(int i=p.size(); i-->0;){ |
327 |
3073
|
Credentials c = (Credentials)p.get(i); |
328 |
|
|
329 |
3839
|
for (int j=r.size(); j-->0;){ |
330 |
|
|
331 |
766
|
if (c.contains((Credentials)r.get(j))){ |
332 |
91
|
r.remove(j); |
333 |
|
} |
334 |
|
} |
335 |
|
|
336 |
3073
|
r.add(c.clone()); |
337 |
|
} |
338 |
|
|
339 |
|
|
340 |
5830
|
p=alien; |
341 |
5830
|
alien=null; |
342 |
|
} |
343 |
|
|
344 |
2915
|
return new SetOfSubsetsCredentials(r); |
345 |
|
} |
346 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
347 |
6634
|
public String toString(){... |
348 |
6634
|
return "set of subsets "+(Creds==null?"null":Creds.toString()); |
349 |
|
} |
350 |
|
} |
351 |
|
|
352 |
|
|