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.xmlpolicy; |
33 |
|
|
34 |
|
import issrg.pba.rbac.policies.*; |
35 |
|
import issrg.pba.rbac.*; |
36 |
|
import issrg.pba.Obligations; |
37 |
|
import issrg.pba.SimpleObligations; |
38 |
|
|
39 |
|
import org.xml.sax.Attributes; |
40 |
|
import javax.xml.parsers.SAXParserFactory; |
41 |
|
|
42 |
|
import issrg.pba.rbac.policies.DITSubtree; |
43 |
|
import issrg.pba.rbac.policies.Subtree; |
44 |
|
|
45 |
|
import issrg.pba.rbac.PolicyParsingException; |
46 |
|
import issrg.pba.rbac.LDAPDNPrincipal; |
47 |
|
import issrg.pba.rbac.BadURLException; |
48 |
|
import issrg.pba.rbac.URLHandler; |
49 |
|
|
50 |
|
|
51 |
|
import java.security.Principal; |
52 |
|
|
53 |
|
import java.util.ArrayList; |
54 |
|
import java.util.Vector; |
55 |
|
import java.util.Map; |
56 |
|
import java.util.Enumeration; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
@author |
85 |
|
@version |
86 |
|
|
87 |
|
|
|
|
| 76.7% |
Uncovered Elements: 42 (180) |
Complexity: 25 |
Complexity Density: 0.52 |
|
88 |
|
public class XMLPolicyParser implements issrg.pba.PolicyParser, |
89 |
|
org.xml.sax.ContentHandler, |
90 |
|
org.xml.sax.ErrorHandler { |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
@see |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
|
102 |
21
|
public static void registerDefaultNodes(){... |
103 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.ArgNode.register(); |
104 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.ConstantNode.register(); |
105 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode.register(); |
106 |
|
|
107 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.OperatorNode.register(); |
108 |
|
|
109 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.PresentNode.register(); |
110 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.NotNode.register(); |
111 |
|
|
112 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.AndNode.register(); |
113 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.OrNode.register(); |
114 |
|
|
115 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.EqNode.register(); |
116 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.GeNode.register(); |
117 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.LeNode.register(); |
118 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.GtNode.register(); |
119 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.LtNode.register(); |
120 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.SubstringsNode.register(); |
121 |
|
|
122 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.IntegerInterpreter.register(); |
123 |
21
|
issrg.pba.rbac.xmlpolicy.ifstatement.StringInterpreter.register(); |
124 |
|
|
125 |
21
|
issrg.pba.rbac.Time.register(); |
126 |
21
|
issrg.pba.rbac.TimeInterpreter.register(); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@param |
133 |
|
|
134 |
|
@return |
135 |
|
|
136 |
|
@throws |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
138 |
0
|
public static XMLPolicyParser getXMLPolicyParser(String policy) throws issrg.pba.PbaException{... |
139 |
0
|
return new XMLPolicyParser(policy); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
@param |
148 |
|
|
149 |
|
@return |
150 |
|
|
151 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
1
|
public static XMLPolicyParser getXMLPolicyParser(java.io.InputStream is) throws issrg.pba.PbaException{... |
153 |
1
|
return new XMLPolicyParser(new org.xml.sax.InputSource(is)); |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
protected final static java.util.Map knownNodes = new java.util.Hashtable(); |
161 |
|
private static Class [] defaultConstr = new Class[]{XMLPolicyParser.class, org.xml.sax.Attributes.class}; |
|
|
| 94.1% |
Uncovered Elements: 1 (17) |
Complexity: 2 |
Complexity Density: 0.12 |
|
162 |
21
|
static{... |
163 |
21
|
try{ |
164 |
21
|
registerXMLNode(XMLTags.ROLE_HIERARCHY_POLICY_NODE, RoleHierarchyPolicyNode.class); |
165 |
21
|
registerXMLNode(XMLTags.ROLE_SPEC_NODE, RoleSpecNode.class); |
166 |
21
|
registerXMLNode(XMLTags.SUP_ROLE_NODE, RoleHierarchyNode.class); |
167 |
21
|
registerXMLNode(XMLTags.SUBJECT_POLICY_NODE, SubjectDomainPolicyNode.class); |
168 |
21
|
registerXMLNode(XMLTags.SUBJECT_DOMAIN_SPEC_NODE, SubjectDomainSpecNode.class); |
169 |
21
|
registerXMLNode(XMLTags.SOA_POLICY_NODE, SOAPolicyNode.class); |
170 |
21
|
registerXMLNode(XMLTags.REPOSITORY_POLICY_NODE, RepositoryPolicyNode.class); |
171 |
21
|
registerXMLNode(XMLTags.TARGET_ACCESS_POLICY_NODE, TargetAccessPolicyNode.class); |
172 |
21
|
registerXMLNode(XMLTags.TARGET_POLICY_NODE, TargetDomainPolicyNode.class); |
173 |
21
|
registerXMLNode(XMLTags.TARGET_DOMAIN_SPEC_NODE, TargetDomainSpecNode.class); |
174 |
21
|
registerXMLNode(XMLTags.ACTION_POLICY_NODE, ActionPolicyNode.class); |
175 |
21
|
registerXMLNode(XMLTags.ROLE_ASSIGNMENT_POLICY_NODE, RoleAssignmentPolicyNode.class); |
176 |
21
|
registerXMLNode(XMLTags.ROLE_LIST_NODE, RoleListNode.class); |
177 |
21
|
registerXMLNode(XMLTags.X_509_PMI_RBAC_POLICY_NODE, PMIXMLPolicyNode.class); |
178 |
|
|
179 |
21
|
registerXMLNode(XMLTags.MSoD_POLICY_SET_NODE, MSoDPolicySetNode.class); |
180 |
|
|
181 |
|
}catch (NoSuchMethodException nsme){ |
182 |
0
|
nsme.printStackTrace(); |
183 |
|
} |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
190 |
0
|
public static void printNodes(){... |
191 |
0
|
System.out.println("The nodes registered with the XML Policy parser:"); |
192 |
0
|
Object [] keys = knownNodes.keySet().toArray(); |
193 |
|
|
194 |
0
|
for (int i=0; i<keys.length; i++){ |
195 |
0
|
System.out.println(keys[i]); |
196 |
|
} |
197 |
0
|
System.out.println(); |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
@param |
206 |
|
|
207 |
|
@param |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
214 |
609
|
public static void registerXMLNode(String nodeName, Class nodeClass) throws NoSuchMethodException {... |
215 |
609
|
knownNodes.put(nodeName, nodeClass.getConstructor(defaultConstr)); |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
protected PMIXMLPolicyNode pmiXMLPolicy; |
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
protected java.util.Vector nodeStack; |
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
protected RoleHierarchyPolicyNode roleHierarchyPolicy; |
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
protected issrg.pba.rbac.ValidityPeriod validityForRoleList; |
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
private java.util.Map rolespec; |
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
private DomainPolicyNode subjectPolicy; |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
private SOAPolicyNode soaPolicy; |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
private DomainPolicyNode targetPolicy; |
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
private ActionPolicyNode actionPolicy; |
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
private TargetAccessPolicyNode targetAccessPolicy; |
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
private MSoDPolicySetNode msodPolicySetNode; |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
private RepositoryPolicyNode repositoryPolicy; |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
protected org.xml.sax.Locator locator; |
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
protected RoleAssignmentPolicyNode delegationPolicy; |
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
protected org.xml.sax.Attributes attrs; |
309 |
|
|
310 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
311 |
0
|
protected XMLPolicyParser(){}... |
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
@param |
318 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
319 |
1
|
public XMLPolicyParser(org.xml.sax.InputSource xmlSource) throws issrg.pba.PbaException{... |
320 |
1
|
_init_(xmlSource); |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
@param |
328 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
329 |
24
|
public XMLPolicyParser(String xml) throws issrg.pba.PbaException {... |
330 |
24
|
org.xml.sax.InputSource xmlSource = new org.xml.sax.InputSource(new java.io.StringReader(xml)); |
331 |
24
|
_init_(xmlSource); |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
@param |
340 |
|
|
|
|
| 46.7% |
Uncovered Elements: 8 (15) |
Complexity: 6 |
Complexity Density: 0.46 |
|
341 |
25
|
private void _init_(org.xml.sax.InputSource xmlSource) throws issrg.pba.PbaException {... |
342 |
25
|
SAXParserFactory sf = SAXParserFactory.newInstance(); |
343 |
|
|
344 |
25
|
sf.setValidating(false); |
345 |
25
|
sf.setNamespaceAware(false); |
346 |
|
|
347 |
25
|
try{ |
348 |
25
|
org.xml.sax.XMLReader parser = sf.newSAXParser().getXMLReader(); |
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
25
|
parser.setContentHandler(this); |
362 |
25
|
parser.parse(xmlSource); |
363 |
|
|
364 |
|
}catch (org.xml.sax.SAXParseException se){ |
365 |
0
|
if (se.getException()!=null){ |
366 |
|
|
367 |
0
|
throw new issrg.pba.PbaException("Could not initialise; parse error @ line "+se.getLineNumber(), se.getException()); |
368 |
|
|
369 |
|
}else{ |
370 |
|
|
371 |
0
|
throw new issrg.pba.PbaException("Could not initialise; parse error @ line "+se.getLineNumber(), se); |
372 |
|
|
373 |
|
} |
374 |
|
}catch (org.xml.sax.SAXException sae){ |
375 |
0
|
throw new issrg.pba.PbaException("Policy parse failed: "+sae.getMessage(), sae); |
376 |
|
}catch (javax.xml.parsers.ParserConfigurationException pce){ |
377 |
0
|
throw new issrg.pba.PbaException("Policy parse failed: "+pce.getMessage(), pce); |
378 |
|
}catch (java.io.IOException io){ |
379 |
0
|
throw new issrg.pba.PbaException("IO failure: "+io.getMessage(), io); |
380 |
|
} |
381 |
|
} |
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
386 |
0
|
public void skippedEntity(String what){... |
387 |
|
} |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
392 |
0
|
public void processingInstruction(String target, String data){... |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
398 |
0
|
public void ignorableWhitespace(char [] arr, int start, int len){... |
399 |
|
} |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
416 |
10141
|
public void characters(char [] arr, int start, int len){... |
417 |
10141
|
if (len>0 && nodeStack.size()>0) |
418 |
7094
|
((PolicyXMLNode)nodeStack.get(0)).addString(new String(arr, start, len).trim()); |
419 |
|
} |
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
@see |
431 |
|
|
|
|
| 83.3% |
Uncovered Elements: 3 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
432 |
2668
|
public void startElement(String URI, String localName, String qName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXParseException{... |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
2668
|
if (localName.intern()==""){ |
443 |
0
|
localName=qName; |
444 |
|
} |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
2668
|
this.attrs=attrs; |
449 |
|
|
450 |
2668
|
PolicyXMLNode node=null; |
451 |
2668
|
try{ |
452 |
2668
|
java.lang.reflect.Constructor co = (java.lang.reflect.Constructor)knownNodes.get(localName); |
453 |
2668
|
if (co!=null){ |
454 |
926
|
node=(PolicyXMLNode)(co.newInstance(new Object[]{this, this.attrs})); |
455 |
|
} |
456 |
|
}catch(Exception iae){ |
457 |
0
|
throw new org.xml.sax.SAXParseException(iae.getMessage(), locator, iae); |
458 |
|
|
459 |
|
|
460 |
|
} |
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
2668
|
if (node==null){ |
468 |
1742
|
node = new PolicyXMLNode(localName, attrs); |
469 |
|
} |
470 |
2668
|
nodeStack.insertElementAt(node, 0); |
471 |
|
|
472 |
|
|
473 |
|
} |
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
@link |
481 |
|
|
482 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 4 |
Complexity Density: 0.5 |
|
483 |
2668
|
public void endElement(String URI, String localName, String qName) throws org.xml.sax.SAXException {... |
484 |
|
|
485 |
|
|
486 |
2668
|
try{ |
487 |
2668
|
PolicyXMLNode node = (PolicyXMLNode)nodeStack.remove(0); |
488 |
|
|
489 |
2668
|
if (nodeStack.size()==0){ |
490 |
25
|
pmiXMLPolicy=(PMIXMLPolicyNode)node; |
491 |
|
}else{ |
492 |
2643
|
((PolicyXMLNode)nodeStack.get(0)).addChild(node); |
493 |
|
} |
494 |
|
|
495 |
|
|
496 |
|
|
497 |
2668
|
node.construct(); |
498 |
|
|
499 |
|
}catch (Exception e){ |
500 |
0
|
throw new org.xml.sax.SAXParseException(e.getMessage(), locator, e); |
501 |
|
}catch (Throwable th){ |
502 |
0
|
throw new org.xml.sax.SAXParseException(th.getMessage(), locator); |
503 |
|
} |
504 |
|
} |
505 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
506 |
25
|
public void startDocument(){... |
507 |
25
|
pmiXMLPolicy = null; |
508 |
25
|
roleHierarchyPolicy = null; |
509 |
25
|
nodeStack = new java.util.Vector(); |
510 |
|
} |
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
515 |
25
|
public void endDocument(){... |
516 |
|
} |
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
522 |
25
|
public void setDocumentLocator(org.xml.sax.Locator l){... |
523 |
25
|
this.locator=l; |
524 |
|
} |
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
529 |
0
|
public void startPrefixMapping(String prefix, String URI){... |
530 |
|
} |
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
535 |
0
|
public void endPrefixMapping(String prefix){... |
536 |
|
} |
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
546 |
0
|
public void warning(org.xml.sax.SAXParseException spe){... |
547 |
|
} |
548 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
549 |
0
|
public void fatalError(org.xml.sax.SAXParseException spe){... |
550 |
|
} |
551 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
552 |
0
|
public void error(org.xml.sax.SAXParseException spe){... |
553 |
|
} |
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
|
558 |
|
@see |
559 |
|
|
560 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
561 |
770
|
private static PolicyXMLNode expect(java.util.Vector where, int pos, String what) throws PolicyParsingException{... |
562 |
770
|
return expect(where, pos, what, false); |
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
@param |
575 |
|
@param |
576 |
|
|
577 |
|
@param |
578 |
|
@param |
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
@return |
585 |
|
|
586 |
|
@throws |
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
|
|
| 71.4% |
Uncovered Elements: 6 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
591 |
1439
|
private static PolicyXMLNode expect(java.util.Vector where, int pos, String what, boolean optional) throws PolicyParsingException{... |
592 |
1439
|
try{ |
593 |
1439
|
if (where.size()<=pos){ |
594 |
0
|
if (!optional) throw new PolicyParsingException("Cannot access an expected child node: "+what); |
595 |
416
|
return null; |
596 |
|
} |
597 |
1023
|
PolicyXMLNode c2 = (PolicyXMLNode)where.get(pos); |
598 |
1023
|
if (c2.getName().intern()!=what.intern()){ |
599 |
0
|
if (!optional) throw new PolicyParsingException(what+" node has been exected, but "+c2.getName()+" was found"); |
600 |
11
|
c2=null; |
601 |
|
} |
602 |
|
|
603 |
1023
|
return c2; |
604 |
|
}catch (PolicyParsingException ppe){ |
605 |
0
|
throw ppe; |
606 |
|
}catch (Throwable th){ |
607 |
|
|
608 |
0
|
throw new PolicyParsingException("Parse error", th); |
609 |
|
} |
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
@param |
621 |
|
|
622 |
|
|
623 |
|
@param |
624 |
|
|
625 |
|
|
626 |
|
@return |
627 |
|
|
628 |
|
|
629 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 1 |
Complexity Density: 0.5 |
|
630 |
89
|
public RoleHierarchyNode getRole(String roleType, String roleValue){... |
631 |
89
|
RoleSpecNode rsn = roleHierarchyPolicy.getByType(roleType); |
632 |
89
|
return rsn==null?null:rsn.getRole(roleValue); |
633 |
|
} |
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
@return |
642 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
643 |
24
|
public java.util.Map getAccessRules(){... |
644 |
|
|
645 |
24
|
return targetAccessPolicy.getRules(); |
646 |
|
} |
647 |
|
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
@see |
653 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
654 |
25
|
public java.util.Map getAssignmentRules(){... |
655 |
25
|
return delegationPolicy.getRules(); |
656 |
|
} |
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
|
663 |
|
|
664 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
665 |
28
|
public java.util.Map getAuthTokenParsingRules(){... |
666 |
28
|
java.util.Map h = new java.util.Hashtable(); |
667 |
28
|
h.put(issrg.pba.rbac.RoleHierarchyPolicy.class, roleHierarchyPolicy); |
668 |
28
|
return h; |
669 |
|
} |
670 |
|
|
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
@return |
675 |
|
|
676 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
677 |
14
|
public String getPolicyID(){... |
678 |
14
|
return pmiXMLPolicy.getOID(); |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
@return |
686 |
|
|
687 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
688 |
25
|
public String [] getRepositoryURLs(){... |
689 |
25
|
if (repositoryPolicy==null) return null; |
690 |
|
|
691 |
2
|
return repositoryPolicy.getURLs(); |
692 |
|
} |
693 |
|
|
694 |
|
|
695 |
|
|
696 |
|
|
697 |
|
|
698 |
|
@return |
699 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
700 |
0
|
public Subtree getSubjectDomains() {... |
701 |
0
|
return subjectPolicy.getCoverageDomain(); |
702 |
|
} |
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
@return |
707 |
|
|
708 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
709 |
1
|
public java.util.Map getSOAs() {... |
710 |
1
|
return soaPolicy.getSOAs(); |
711 |
|
} |
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
|
|
720 |
|
|
721 |
|
|
722 |
|
|
723 |
|
|
724 |
|
|
725 |
|
@see |
726 |
|
@author |
727 |
|
@version |
728 |
|
|
729 |
|
|
|
|
| 96% |
Uncovered Elements: 2 (50) |
Complexity: 8 |
Complexity Density: 0.39 |
|
730 |
|
public class ActionPolicyNode extends PolicyXMLNode{ |
731 |
|
|
732 |
|
|
733 |
|
|
734 |
|
|
735 |
|
public final static String ARGS_SEPARATORS = ","; |
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
|
740 |
|
private java.util.Map actions = new java.util.Hashtable(); |
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
|
745 |
|
private java.util.Map targets = new java.util.Hashtable(); |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
750 |
25
|
public ActionPolicyNode(Attributes attrs) {... |
751 |
25
|
super(XMLTags.ACTION_POLICY_NODE, attrs); |
752 |
|
|
753 |
25
|
actionPolicy = this; |
754 |
|
} |
755 |
|
|
756 |
|
|
757 |
|
|
758 |
|
|
759 |
|
@link |
760 |
|
|
761 |
|
|
|
|
| 96.8% |
Uncovered Elements: 1 (31) |
Complexity: 6 |
Complexity Density: 0.29 |
|
762 |
25
|
public void construct(){... |
763 |
|
|
764 |
|
|
765 |
|
|
766 |
134
|
for (int i=children.size(); i-->0;){ |
767 |
109
|
PolicyXMLNode c = (PolicyXMLNode)children.get(i); |
768 |
109
|
if (c.getName().intern()!=XMLTags.ACTION_NODE){ |
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
} |
773 |
|
|
774 |
109
|
java.util.Map m = c.getAttributes(); |
775 |
109
|
String n = (String)m.get(XMLTags.NAME_ATTRIBUTE); |
776 |
109
|
String ret = (String)m.get(XMLTags.RETURN_TYPE_ATTRIBUTE); |
777 |
|
|
778 |
109
|
String args = (String)m.get(XMLTags.ARGS_ATTRIBUTE); |
779 |
109
|
String [] def = new String [] {ret}; |
780 |
109
|
if (args!=null){ |
781 |
68
|
java.util.Vector v = split(args); |
782 |
68
|
def = new String[1+v.size()]; |
783 |
68
|
def[0]=ret; |
784 |
|
|
785 |
68
|
if (def.length>1){ |
786 |
13
|
System.arraycopy(v.toArray(), 0, def, 1, def.length-1); |
787 |
|
} |
788 |
|
} |
789 |
|
|
790 |
109
|
actions.put(n, def); |
791 |
|
|
792 |
109
|
String targetAttribute = (String)m.get(XMLTags.TARGET_ATTRIBUTE); |
793 |
109
|
if(targetAttribute != null) |
794 |
|
{ |
795 |
1
|
java.util.Vector targetVector = split(targetAttribute); |
796 |
1
|
String[] tars = new String[targetVector.size()]; |
797 |
1
|
System.arraycopy(targetVector.toArray(), 0, tars, 0, targetVector.size()); |
798 |
1
|
targets.put(n, tars); |
799 |
|
} |
800 |
|
} |
801 |
|
} |
802 |
|
|
803 |
|
|
804 |
|
|
805 |
|
|
806 |
|
|
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
|
811 |
|
|
812 |
|
|
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
@param |
817 |
|
|
818 |
|
@return |
819 |
|
|
820 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
821 |
1250
|
public String [] getActionDefinition(String name){... |
822 |
1250
|
return (String [])actions.get(name); |
823 |
|
} |
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
|
828 |
|
@param |
829 |
|
|
830 |
|
@return |
831 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
832 |
197
|
public String[] getApplyToTargets(String name)... |
833 |
|
{ |
834 |
197
|
return (String [])targets.get(name); |
835 |
|
} |
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
@param |
841 |
|
|
842 |
|
@return |
843 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
844 |
69
|
private java.util.Vector split(String args){... |
845 |
69
|
java.util.Vector v = new java.util.Vector(); |
846 |
|
|
847 |
69
|
if (args!=null){ |
848 |
69
|
java.util.Enumeration st = new java.util.StringTokenizer(args, ARGS_SEPARATORS); |
849 |
|
|
850 |
85
|
while (st.hasMoreElements()){ |
851 |
16
|
v.add(st.nextElement()); |
852 |
|
} |
853 |
|
} |
854 |
|
|
855 |
69
|
return v; |
856 |
|
} |
857 |
|
} |
858 |
|
|
859 |
|
|
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
|
866 |
|
|
867 |
|
@author |
868 |
|
@version |
869 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 2 |
Complexity Density: 0.45 |
|
870 |
|
public class DomainPolicyNode extends PolicyXMLNode{ |
871 |
|
|
872 |
|
|
873 |
|
|
874 |
|
|
875 |
|
public final static String NODE_NAME = "Policy"; |
876 |
|
|
877 |
|
protected java.util.Map domains; |
878 |
|
protected issrg.pba.rbac.policies.Subtree coverageDomain; |
879 |
|
|
880 |
|
|
881 |
|
|
882 |
|
|
883 |
|
|
884 |
|
@param |
885 |
|
|
886 |
|
@param |
887 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
888 |
50
|
public DomainPolicyNode(String prefix, Attributes attrs) {... |
889 |
50
|
super(prefix+NODE_NAME, attrs); |
890 |
|
} |
891 |
|
|
892 |
|
|
893 |
|
|
894 |
|
|
895 |
|
|
896 |
|
|
897 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
898 |
50
|
public void construct(){... |
899 |
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
50
|
DomainSpecNode [] s = new DomainSpecNode[children.size()]; |
904 |
50
|
System.arraycopy(children.toArray(), 0, s, 0, s.length); |
905 |
|
|
906 |
50
|
domains = new java.util.Hashtable(); |
907 |
50
|
java.util.Vector coverage = new java.util.Vector(); |
908 |
|
|
909 |
|
|
910 |
166
|
for (int i=0; i<s.length; i++){ |
911 |
|
|
912 |
116
|
domains.put(s[i].getID(), s[i].getSubtree()); |
913 |
116
|
coverage.add(s[i].getSubtree()); |
914 |
|
} |
915 |
|
|
916 |
50
|
coverageDomain = new issrg.pba.rbac.policies.ComplexSubtree(coverage, null); |
917 |
|
|
918 |
|
|
919 |
|
} |
920 |
|
|
921 |
|
|
922 |
|
|
923 |
|
|
924 |
|
|
925 |
|
@param |
926 |
|
|
927 |
|
@return |
928 |
|
|
929 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
930 |
233
|
public issrg.pba.rbac.policies.Subtree getDomain(String id){... |
931 |
|
|
932 |
233
|
return (issrg.pba.rbac.policies.Subtree)domains.get(id); |
933 |
|
} |
934 |
|
|
935 |
|
|
936 |
|
|
937 |
|
|
938 |
|
|
939 |
|
|
940 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
941 |
1384
|
public issrg.pba.rbac.policies.Subtree getCoverageDomain(){... |
942 |
1384
|
return coverageDomain; |
943 |
|
} |
944 |
|
|
945 |
|
} |
946 |
|
|
947 |
|
|
948 |
|
|
949 |
|
|
950 |
|
|
951 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.5 |
|
952 |
|
public class SubjectDomainPolicyNode extends DomainPolicyNode{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
953 |
25
|
public SubjectDomainPolicyNode(Attributes attrs){... |
954 |
25
|
super(XMLTags.SUBJECT_PREFIX, attrs); |
955 |
25
|
subjectPolicy = this; |
956 |
|
} |
957 |
|
} |
958 |
|
|
959 |
|
|
960 |
|
|
961 |
|
|
962 |
|
|
963 |
|
|
964 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.5 |
|
965 |
|
public class TargetDomainPolicyNode extends DomainPolicyNode{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
966 |
25
|
public TargetDomainPolicyNode(Attributes attrs){... |
967 |
25
|
super(XMLTags.TARGET_PREFIX, attrs); |
968 |
25
|
targetPolicy = this; |
969 |
|
} |
970 |
|
} |
971 |
|
|
972 |
|
|
973 |
|
|
974 |
|
|
975 |
|
|
976 |
|
|
977 |
|
@author |
978 |
|
@version |
979 |
|
|
|
|
| 82% |
Uncovered Elements: 18 (100) |
Complexity: 20 |
Complexity Density: 0.41 |
|
980 |
|
public class DomainSpecNode extends PolicyXMLNode { |
981 |
|
|
982 |
|
|
983 |
|
|
984 |
|
|
985 |
|
public static final String NODE_NAME = "DomainSpec"; |
986 |
|
|
987 |
|
private String domainID; |
988 |
|
|
989 |
|
private issrg.pba.rbac.policies.Subtree subTree; |
990 |
|
|
991 |
|
|
992 |
|
|
993 |
|
|
994 |
|
|
995 |
|
private boolean expectObjClasses; |
996 |
|
|
997 |
|
|
998 |
|
|
999 |
|
|
1000 |
|
|
1001 |
|
|
1002 |
|
@param |
1003 |
|
|
1004 |
|
|
1005 |
|
@param |
1006 |
|
|
1007 |
|
|
1008 |
|
|
1009 |
|
@param |
1010 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1011 |
116
|
public DomainSpecNode(String prefix, boolean objClass, Attributes attrs) {... |
1012 |
116
|
super(prefix+NODE_NAME, attrs); |
1013 |
|
|
1014 |
116
|
expectObjClasses = objClass; |
1015 |
|
} |
1016 |
|
|
1017 |
|
|
1018 |
|
|
1019 |
|
|
1020 |
|
|
|
|
| 50% |
Uncovered Elements: 3 (6) |
Complexity: 4 |
Complexity Density: 0.67 |
|
1021 |
116
|
public void construct() throws PolicyParsingException{... |
1022 |
116
|
try{ |
1023 |
116
|
subTree = new issrg.pba.rbac.policies.ComplexSubtree(gatherSubtrees(children, true), null); |
1024 |
116
|
domainID = (String)this.attributes.get(XMLTags.ID_ATTRIBUTE); |
1025 |
|
|
1026 |
|
|
1027 |
|
}catch(issrg.utils.RFC2253ParsingException rpe){ |
1028 |
0
|
throw new PolicyParsingException(rpe.getMessage(), rpe); |
1029 |
|
}catch(BadURLException bue){ |
1030 |
0
|
throw new PolicyParsingException(bue.getMessage(), bue); |
1031 |
|
}catch(java.lang.NumberFormatException nfe){ |
1032 |
0
|
throw new PolicyParsingException("Error parsing integer", nfe); |
1033 |
|
} |
1034 |
|
} |
1035 |
|
|
1036 |
|
|
1037 |
|
|
1038 |
|
|
1039 |
|
|
1040 |
|
|
1041 |
|
|
1042 |
|
|
1043 |
|
|
1044 |
|
|
1045 |
|
|
1046 |
|
@param |
1047 |
|
@param |
1048 |
|
|
1049 |
|
|
1050 |
|
|
1051 |
|
|
1052 |
|
|
|
|
| 82.4% |
Uncovered Elements: 15 (85) |
Complexity: 17 |
Complexity Density: 0.35 |
|
1053 |
118
|
protected java.util.Vector gatherSubtrees(java.util.Vector children, boolean includes) throws PolicyParsingException, issrg.utils.RFC2253ParsingException, BadURLException {... |
1054 |
118
|
java.util.Vector subtrees = new java.util.Vector(); |
1055 |
|
|
1056 |
118
|
java.util.Vector excl = includes?new java.util.Vector():subtrees; |
1057 |
118
|
java.util.Vector classes = null; |
1058 |
118
|
int i=children.size(); |
1059 |
118
|
boolean objClasses = includes && expectObjClasses; |
1060 |
|
|
1061 |
|
|
1062 |
303
|
while(i-->0){ |
1063 |
185
|
PolicyXMLNode child = (PolicyXMLNode)children.get(i); |
1064 |
185
|
String s = child.getName().intern(); |
1065 |
|
|
1066 |
|
|
1067 |
185
|
String minmax = (String)child.getAttributes().get(XMLTags.MIN_ATTRIBUTE); |
1068 |
185
|
int min=minmax==null?0:Integer.parseInt(minmax); |
1069 |
|
|
1070 |
185
|
minmax = (String)child.getAttributes().get(XMLTags.MAX_ATTRIBUTE); |
1071 |
185
|
int max=minmax==null?-1:Integer.parseInt(minmax); |
1072 |
|
|
1073 |
|
|
1074 |
|
|
1075 |
185
|
String dn = (String)child.getAttributes().get(XMLTags.LDAPDN_ATTRIBUTE); |
1076 |
185
|
String url = (String)child.getAttributes().get(XMLTags.URL_ATTRIBUTE); |
1077 |
|
|
1078 |
185
|
if (dn!=null && url!=null){ |
1079 |
0
|
throw new PolicyParsingException("Invalid subtree specification: cannot have "+XMLTags.LDAPDN_ATTRIBUTE+" and "+XMLTags.URL_ATTRIBUTE+" attributes at the same time."); |
1080 |
|
} |
1081 |
|
|
1082 |
185
|
if (dn==null && url==null){ |
1083 |
1
|
dn=""; |
1084 |
|
} |
1085 |
|
|
1086 |
185
|
Subtree sub=null; |
1087 |
|
|
1088 |
185
|
objClasses &= s==XMLTags.OBJECT_CLASS_NODE; |
1089 |
|
|
1090 |
185
|
if (s==XMLTags.INCLUDE_NODE){ |
1091 |
0
|
if (!includes) throw new PolicyParsingException(s+" nodes cannot be nested"); |
1092 |
|
|
1093 |
|
|
1094 |
172
|
if (child.getChildren().size()!=0){ |
1095 |
2
|
excl.addAll(0, gatherSubtrees(child.getChildren(), false)); |
1096 |
|
} |
1097 |
|
|
1098 |
172
|
Subtree [] exclude = (Subtree[])excl.toArray(new Subtree[0]); |
1099 |
172
|
excl = new java.util.Vector(); |
1100 |
|
|
1101 |
172
|
if (dn==null){ |
1102 |
|
|
1103 |
42
|
sub=issrg.pba.rbac.URLHandler.getSubtreeByURL(url, min, max, exclude); |
1104 |
|
}else{ |
1105 |
130
|
sub=new DITSubtree(new LDAPDNPrincipal(dn), min, max, classes==null?null:(String[])classes.toArray(new String[0]), exclude); |
1106 |
|
} |
1107 |
|
|
1108 |
|
|
1109 |
|
|
1110 |
0
|
if (sub==null) throw new PolicyParsingException("Invalid subtree specification: DN="+dn+", URL="+url); |
1111 |
|
|
1112 |
|
|
1113 |
|
|
1114 |
|
|
1115 |
172
|
subtrees.add(0, sub); |
1116 |
13
|
}else if (s==XMLTags.EXCLUDE_NODE){ |
1117 |
12
|
if (dn==null){ |
1118 |
2
|
sub=issrg.pba.rbac.URLHandler.getSubtreeByURL(url, min, max, null); |
1119 |
|
}else{ |
1120 |
10
|
sub=new DITSubtree(new LDAPDNPrincipal(dn), min, max, null, null); |
1121 |
|
} |
1122 |
|
|
1123 |
|
|
1124 |
0
|
if (sub==null) throw new PolicyParsingException("Invalid subtree specification: DN="+dn+", URL="+url); |
1125 |
|
|
1126 |
12
|
excl.add(0, sub); |
1127 |
1
|
}else if (objClasses){ |
1128 |
1
|
if (classes==null){ |
1129 |
1
|
classes = new java.util.Vector(); |
1130 |
|
} |
1131 |
|
|
1132 |
1
|
s=(String)child.getAttributes().get(XMLTags.NAME_ATTRIBUTE); |
1133 |
1
|
if (s==null){ |
1134 |
0
|
throw new PolicyParsingException(XMLTags.NAME_ATTRIBUTE+" is required, but not found"); |
1135 |
|
} |
1136 |
1
|
classes.add(s); |
1137 |
|
}else{ |
1138 |
0
|
throw new PolicyParsingException(s+" node was found, but was not expected"); |
1139 |
|
} |
1140 |
|
} |
1141 |
|
|
1142 |
|
|
1143 |
|
|
1144 |
118
|
return subtrees; |
1145 |
|
} |
1146 |
|
|
1147 |
|
|
1148 |
|
|
1149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1150 |
116
|
public String getID(){... |
1151 |
116
|
return domainID; |
1152 |
|
} |
1153 |
|
|
1154 |
|
|
1155 |
|
|
1156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1157 |
232
|
public Subtree getSubtree(){... |
1158 |
232
|
return subTree; |
1159 |
|
} |
1160 |
|
|
1161 |
|
} |
1162 |
|
|
1163 |
|
|
1164 |
|
|
1165 |
|
|
1166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
1167 |
|
public class SubjectDomainSpecNode extends DomainSpecNode{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1168 |
50
|
public SubjectDomainSpecNode(Attributes attrs){... |
1169 |
50
|
super(XMLTags.SUBJECT_PREFIX, false, attrs); |
1170 |
|
} |
1171 |
|
} |
1172 |
|
|
1173 |
|
|
1174 |
|
|
1175 |
|
|
1176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
1177 |
|
public class TargetDomainSpecNode extends DomainSpecNode{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1178 |
66
|
public TargetDomainSpecNode(Attributes attrs){... |
1179 |
66
|
super(XMLTags.TARGET_PREFIX, true, attrs); |
1180 |
|
} |
1181 |
|
} |
1182 |
|
|
1183 |
|
|
1184 |
|
|
1185 |
|
|
1186 |
|
|
1187 |
|
|
1188 |
|
@author |
1189 |
|
@version |
1190 |
|
|
|
|
| 86.3% |
Uncovered Elements: 17 (124) |
Complexity: 22 |
Complexity Density: 0.31 |
|
1191 |
|
public class RoleAssignmentPolicyNode extends PolicyXMLNode{ |
1192 |
|
|
1193 |
|
|
1194 |
|
|
1195 |
|
public static final int SUBJECT_DOMAIN_NODE_SEQUENCE = 0; |
1196 |
|
public static final int ROLE_LIST_NODE_SEQUENCE = 1; |
1197 |
|
public static final int DELEGATE_NODE_SEQUENCE = 2; |
1198 |
|
public static final int SOA_NODE_SEQUENCE = 3; |
1199 |
|
public static final int VALIDITY_NODE_SEQUENCE = 4; |
1200 |
|
|
1201 |
|
public static final int ABSOLUTE_VALIDITY_NODE_SEQUENCE = 0; |
1202 |
|
public static final int AGE_VALIDITY_NODE_SEQUENCE = 1; |
1203 |
|
public static final int MAXIMUM_VALIDITY_NODE_SEQUENCE = 2; |
1204 |
|
public static final int MINIMUM_VALIDITY_NODE_SEQUENCE = 3; |
1205 |
|
|
1206 |
|
|
1207 |
|
|
1208 |
|
|
1209 |
|
private DomainPolicyNode subjectPol; |
1210 |
|
private SOAPolicyNode soas; |
1211 |
|
|
1212 |
|
|
1213 |
|
|
1214 |
|
|
1215 |
|
protected java.util.Map rules; |
1216 |
|
|
1217 |
|
|
1218 |
|
|
1219 |
|
|
1220 |
|
|
1221 |
|
|
1222 |
|
|
1223 |
|
@param |
1224 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1225 |
25
|
public RoleAssignmentPolicyNode(Attributes attrs){... |
1226 |
25
|
this(subjectPolicy, soaPolicy, attrs); |
1227 |
|
} |
1228 |
|
|
1229 |
|
|
1230 |
|
|
1231 |
|
|
1232 |
|
|
1233 |
|
@param |
1234 |
|
@param |
1235 |
|
@param |
1236 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1237 |
25
|
public RoleAssignmentPolicyNode(DomainPolicyNode subjectPolicy,... |
1238 |
|
SOAPolicyNode soaPolicy, Attributes attrs) { |
1239 |
25
|
super(XMLTags.ROLE_ASSIGNMENT_POLICY_NODE, attrs); |
1240 |
|
|
1241 |
25
|
this.subjectPol = subjectPolicy; |
1242 |
25
|
soas = soaPolicy; |
1243 |
25
|
delegationPolicy = this; |
1244 |
|
} |
1245 |
|
|
1246 |
|
|
1247 |
|
|
1248 |
|
|
1249 |
|
|
1250 |
|
|
1251 |
|
|
1252 |
|
|
|
|
| 84.7% |
Uncovered Elements: 17 (111) |
Complexity: 22 |
Complexity Density: 0.29 |
|
1253 |
25
|
public void construct() throws PolicyParsingException{... |
1254 |
25
|
rules = new java.util.Hashtable(); |
1255 |
|
|
1256 |
25
|
rules.put(issrg.pba.rbac.policies.Subtree.class, subjectPol.getCoverageDomain()); |
1257 |
|
|
1258 |
|
|
1259 |
77
|
for (int i=children.size(); i-->0; ){ |
1260 |
52
|
PolicyXMLNode c = (PolicyXMLNode)children.get(i); |
1261 |
52
|
String s = c.getName().intern(); |
1262 |
52
|
if (s!=XMLTags.ROLE_ASSIGNMENT_NODE){ |
1263 |
0
|
throw new PolicyParsingException("Only "+XMLTags.ROLE_ASSIGNMENT_NODE+" nodes are allowed under this node"); |
1264 |
|
} |
1265 |
|
|
1266 |
52
|
java.util.Vector v = c.getChildren(); |
1267 |
|
|
1268 |
|
|
1269 |
52
|
String subjId = (String)expect(v, SUBJECT_DOMAIN_NODE_SEQUENCE, XMLTags.SUBJECT_DOMAIN_NODE).getAttributes().get(XMLTags.ID_ATTRIBUTE); |
1270 |
|
|
1271 |
|
|
1272 |
52
|
RoleListNode roleList = (RoleListNode)expect(v, ROLE_LIST_NODE_SEQUENCE, XMLTags.ROLE_LIST_NODE); |
1273 |
|
|
1274 |
52
|
String delegationDepth = (String)expect(v, DELEGATE_NODE_SEQUENCE, XMLTags.DELEGATE_NODE).getAttributes().get(XMLTags.DEPTH_ATTRIBUTE); |
1275 |
|
|
1276 |
52
|
int delegation; |
1277 |
|
|
1278 |
52
|
try{ |
1279 |
52
|
delegation=delegationDepth==null? -1 : Integer.parseInt(delegationDepth); |
1280 |
0
|
if (delegation<-1) throw new NumberFormatException(); |
1281 |
|
}catch(java.lang.NumberFormatException ex){ |
1282 |
0
|
throw new PolicyParsingException("Delegation Depth should be a valid non-negative integer number, or be missing", ex); |
1283 |
|
} |
1284 |
|
|
1285 |
|
|
1286 |
52
|
String soaId = (String)expect(v, SOA_NODE_SEQUENCE, XMLTags.SOA_NODE).getAttributes().get(XMLTags.ID_ATTRIBUTE); |
1287 |
|
|
1288 |
|
|
1289 |
52
|
Vector validity = expect(v, VALIDITY_NODE_SEQUENCE, XMLTags.VALIDITY_NODE).getChildren(); |
1290 |
|
|
1291 |
52
|
validityForRoleList = new issrg.pba.rbac.AnyTimeValidityPeriod(); |
1292 |
52
|
int missingnodes=0; |
1293 |
52
|
PolicyXMLNode val_node = expect(validity, ABSOLUTE_VALIDITY_NODE_SEQUENCE, XMLTags.ABSOLUTE_NODE, true); |
1294 |
52
|
issrg.pba.rbac.RelativeDate rd; |
1295 |
|
|
1296 |
52
|
if (val_node==null){ |
1297 |
33
|
missingnodes++; |
1298 |
|
}else{ |
1299 |
19
|
java.util.Date nb = null; |
1300 |
19
|
java.util.Date na = null; |
1301 |
19
|
s = (String)val_node.getAttributes().get(XMLTags.START_ATTRIBUTE); |
1302 |
19
|
if (s!=null && s.intern()!=""){ |
1303 |
19
|
rd = parseDateTime(s); |
1304 |
19
|
rd.months--; |
1305 |
19
|
nb = rd.getDate(); |
1306 |
|
} |
1307 |
|
|
1308 |
19
|
s = (String)val_node.getAttributes().get(XMLTags.END_ATTRIBUTE); |
1309 |
19
|
if (s!=null && s.intern()!=""){ |
1310 |
19
|
rd = parseDateTime(s); |
1311 |
19
|
rd.months--; |
1312 |
19
|
na = rd.getDate(); |
1313 |
|
} |
1314 |
|
|
1315 |
19
|
validityForRoleList=new issrg.pba.rbac.AbsoluteValidityPeriod(nb, na); |
1316 |
|
} |
1317 |
|
|
1318 |
52
|
issrg.pba.rbac.RelativeDate age=null; |
1319 |
52
|
issrg.pba.rbac.RelativeDate min=null; |
1320 |
52
|
issrg.pba.rbac.RelativeDate max=null; |
1321 |
|
|
1322 |
52
|
val_node = expect(validity, AGE_VALIDITY_NODE_SEQUENCE-missingnodes, XMLTags.AGE_NODE, true); |
1323 |
52
|
if (val_node==null){ |
1324 |
50
|
missingnodes++; |
1325 |
|
}else{ |
1326 |
2
|
s = (String)val_node.getAttributes().get(XMLTags.TIME_ATTRIBUTE); |
1327 |
2
|
if (s==null){ |
1328 |
0
|
throw new PolicyParsingException(XMLTags.TIME_ATTRIBUTE+" attribute is missing in "+XMLTags.AGE_NODE); |
1329 |
|
} |
1330 |
|
|
1331 |
2
|
age=parseDateTime(s); |
1332 |
|
} |
1333 |
|
|
1334 |
52
|
val_node = expect(validity, MAXIMUM_VALIDITY_NODE_SEQUENCE-missingnodes, XMLTags.MAXIMUM_NODE, true); |
1335 |
52
|
if (val_node==null){ |
1336 |
50
|
missingnodes++; |
1337 |
|
}else{ |
1338 |
2
|
s = (String)val_node.getAttributes().get(XMLTags.TIME_ATTRIBUTE); |
1339 |
2
|
if (s==null){ |
1340 |
0
|
throw new PolicyParsingException(XMLTags.TIME_ATTRIBUTE+" attribute is missing in "+XMLTags.MAXIMUM_NODE); |
1341 |
|
} |
1342 |
|
|
1343 |
2
|
max=parseDateTime(s); |
1344 |
|
} |
1345 |
|
|
1346 |
52
|
val_node = expect(validity, MINIMUM_VALIDITY_NODE_SEQUENCE-missingnodes, XMLTags.MINIMUM_NODE, true); |
1347 |
52
|
if (val_node==null){ |
1348 |
51
|
missingnodes++; |
1349 |
|
}else{ |
1350 |
1
|
s = (String)val_node.getAttributes().get(XMLTags.TIME_ATTRIBUTE); |
1351 |
1
|
if (s==null){ |
1352 |
0
|
throw new PolicyParsingException(XMLTags.TIME_ATTRIBUTE+" attribute is missing in "+XMLTags.MINIMUM_NODE); |
1353 |
|
} |
1354 |
|
|
1355 |
1
|
min=parseDateTime(s); |
1356 |
|
} |
1357 |
|
|
1358 |
52
|
if (age!=null || min!=null || max!=null){ |
1359 |
5
|
validityForRoleList = new issrg.pba.rbac.AdjustedPeriodCollection( |
1360 |
|
validityForRoleList, |
1361 |
|
new issrg.pba.rbac.AdjustedValidityPeriod(age, min, max) |
1362 |
|
); |
1363 |
|
} |
1364 |
|
|
1365 |
52
|
roleList.construct(); |
1366 |
|
|
1367 |
|
|
1368 |
52
|
issrg.pba.Credentials soaCreds = roleList.getCredential(); |
1369 |
|
|
1370 |
|
|
1371 |
52
|
java.security.Principal soa = soas.getSOA(soaId); |
1372 |
|
|
1373 |
52
|
if (soa==null){ |
1374 |
0
|
throw new PolicyParsingException("No SOA with "+soaId+" has been defined"); |
1375 |
|
} |
1376 |
|
|
1377 |
|
|
1378 |
52
|
Subtree subj = subjectPol.getDomain(subjId); |
1379 |
|
|
1380 |
52
|
if (subj==null){ |
1381 |
0
|
throw new PolicyParsingException("No Subject Domain with "+subjId+" has been defined"); |
1382 |
|
} |
1383 |
|
|
1384 |
52
|
java.util.Vector v2 = (java.util.Vector)rules.get(soa.getName()); |
1385 |
52
|
if (v2==null){ |
1386 |
40
|
v2 = new java.util.Vector(); |
1387 |
40
|
rules.put(soa.getName(), v2); |
1388 |
|
} |
1389 |
|
|
1390 |
|
|
1391 |
52
|
v2.add(new issrg.pba.rbac.policies.AssignmentRule(subj, delegation, soaCreds)); |
1392 |
|
|
1393 |
|
} |
1394 |
|
} |
1395 |
|
|
1396 |
|
|
1397 |
|
|
1398 |
|
|
1399 |
|
|
1400 |
|
|
1401 |
|
|
1402 |
|
|
1403 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1404 |
25
|
public java.util.Map getRules(){... |
1405 |
25
|
return rules; |
1406 |
|
} |
1407 |
|
|
1408 |
|
|
1409 |
|
|
1410 |
|
|
1411 |
|
|
1412 |
|
|
1413 |
|
|
1414 |
|
|
1415 |
|
|
1416 |
|
|
1417 |
|
|
1418 |
|
|
1419 |
|
|
1420 |
|
|
1421 |
|
|
1422 |
|
|
1423 |
|
|
1424 |
|
|
1425 |
|
|
1426 |
|
@param |
1427 |
|
|
1428 |
|
@return |
1429 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1430 |
43
|
protected issrg.pba.rbac.RelativeDate parseDateTime(String s){... |
1431 |
43
|
int [] d = new issrg.pba.rbac.Time(s).getEvaluationTime(); |
1432 |
|
|
1433 |
43
|
return new issrg.pba.rbac.RelativeDate(d[0], d[1], d[2], d[3], d[4], d[5]); |
1434 |
|
} |
1435 |
|
} |
1436 |
|
|
1437 |
|
|
1438 |
|
|
1439 |
|
|
1440 |
|
|
1441 |
|
|
1442 |
|
|
1443 |
|
|
1444 |
|
|
1445 |
|
|
1446 |
|
@author |
1447 |
|
@version |
1448 |
|
|
|
|
| 82.7% |
Uncovered Elements: 14 (81) |
Complexity: 18 |
Complexity Density: 0.64 |
|
1449 |
|
public class RoleHierarchyNode extends PolicyXMLNode implements issrg.pba.rbac.RoleHierarchyNode { |
1450 |
|
|
1451 |
|
|
1452 |
|
|
1453 |
|
|
1454 |
|
|
1455 |
|
|
1456 |
|
|
1457 |
|
|
1458 |
|
|
1459 |
|
|
1460 |
|
|
1461 |
|
|
1462 |
|
protected int hierarchyLevel = -1; |
1463 |
|
|
1464 |
|
protected String type; |
1465 |
|
protected String value; |
1466 |
|
|
1467 |
|
protected RoleHierarchyNode [] subordinates=null; |
1468 |
|
|
1469 |
|
|
1470 |
|
|
1471 |
|
|
1472 |
|
|
1473 |
|
|
1474 |
|
private int loops = 0; |
1475 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1476 |
101
|
public RoleHierarchyNode(org.xml.sax.Attributes attrs) {... |
1477 |
101
|
super(XMLTags.SUP_ROLE_NODE, attrs); |
1478 |
|
|
1479 |
101
|
_init_(); |
1480 |
|
} |
1481 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1482 |
101
|
private void _init_(){... |
1483 |
101
|
value = attrs.getValue(XMLTags.VALUE_ATTRIBUTE); |
1484 |
|
} |
1485 |
|
|
1486 |
|
|
1487 |
|
|
1488 |
|
|
1489 |
|
|
1490 |
|
|
1491 |
|
|
1492 |
|
|
1493 |
|
|
1494 |
|
@param |
1495 |
|
|
1496 |
|
|
|
|
| 69.6% |
Uncovered Elements: 7 (23) |
Complexity: 6 |
Complexity Density: 0.4 |
|
1497 |
101
|
public void optimise(java.util.Map roleHierarchy) throws PolicyParsingException{... |
1498 |
101
|
try{ |
1499 |
101
|
if (subordinates!=null){ |
1500 |
0
|
return; |
1501 |
|
} |
1502 |
|
|
1503 |
101
|
Object [] childs = children.toArray(); |
1504 |
101
|
subordinates = new RoleHierarchyNode[childs.length]; |
1505 |
|
|
1506 |
149
|
for (int i=0; i<childs.length; i++){ |
1507 |
48
|
String s = (String)(((PolicyXMLNode)childs[i]).getAttributes().get(XMLTags.VALUE_ATTRIBUTE)); |
1508 |
|
|
1509 |
48
|
RoleHierarchyNode sub = (RoleHierarchyNode)roleHierarchy.get(s); |
1510 |
|
|
1511 |
48
|
if (sub==null){ |
1512 |
0
|
throw new PolicyParsingException("Could not find Role "+s+" in this hierarchy"); |
1513 |
|
} |
1514 |
|
|
1515 |
48
|
subordinates[i]=sub; |
1516 |
48
|
sub.setLevel(getLevel()+1); |
1517 |
|
|
1518 |
|
} |
1519 |
|
}catch(Throwable th){ |
1520 |
0
|
throw new PolicyParsingException(th.getMessage()); |
1521 |
|
} |
1522 |
|
|
1523 |
101
|
if (loops!=0){ |
1524 |
0
|
throw new PolicyParsingException("Role Hierarchy directed graph contains loops"); |
1525 |
|
} |
1526 |
|
} |
1527 |
|
|
1528 |
|
|
1529 |
|
|
1530 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1531 |
24231
|
public int getLevel(){... |
1532 |
24231
|
return hierarchyLevel; |
1533 |
|
} |
1534 |
|
|
1535 |
|
|
1536 |
|
|
1537 |
|
|
1538 |
|
|
1539 |
|
|
1540 |
|
|
1541 |
|
|
1542 |
|
|
1543 |
|
|
1544 |
|
|
1545 |
|
@param |
1546 |
|
|
1547 |
|
|
1548 |
|
|
|
|
| 82.4% |
Uncovered Elements: 3 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
1549 |
113
|
public void setLevel(int level){... |
1550 |
113
|
loops++; |
1551 |
113
|
if (loops!=1){ |
1552 |
0
|
return; |
1553 |
|
} |
1554 |
|
|
1555 |
113
|
if (level>=getLevel()){ |
1556 |
|
|
1557 |
108
|
hierarchyLevel = level; |
1558 |
108
|
if (subordinates!=null) |
1559 |
173
|
for(int i=0; i<subordinates.length; i++){ |
1560 |
65
|
subordinates[i].setLevel(level+1); |
1561 |
|
} |
1562 |
|
} |
1563 |
113
|
loops--; |
1564 |
|
} |
1565 |
|
|
1566 |
|
|
1567 |
|
|
1568 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1569 |
45595
|
public String getValue(){... |
1570 |
45595
|
return value; |
1571 |
|
} |
1572 |
|
|
1573 |
|
|
1574 |
|
|
1575 |
|
|
1576 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1577 |
17244
|
public Object getRoleValue(){... |
1578 |
17244
|
return getValue(); |
1579 |
|
} |
1580 |
|
|
1581 |
|
|
1582 |
|
|
1583 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1584 |
2711
|
public String getRoleType(){... |
1585 |
2711
|
return type; |
1586 |
|
} |
1587 |
|
|
1588 |
|
|
1589 |
|
|
1590 |
|
|
1591 |
|
|
1592 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1593 |
101
|
protected void setRoleType(String t){... |
1594 |
101
|
type=t; |
1595 |
|
} |
1596 |
|
|
1597 |
|
|
1598 |
|
|
1599 |
|
|
1600 |
|
|
1601 |
|
|
1602 |
|
|
1603 |
|
|
1604 |
|
|
1605 |
|
|
1606 |
|
@return |
1607 |
|
|
|
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 9 |
Complexity Density: 0.82 |
|
1608 |
17641
|
public boolean isSuperiorTo(issrg.pba.rbac.RoleHierarchyNode rhn){... |
1609 |
|
|
1610 |
|
|
1611 |
17641
|
if (rhn==null || !(rhn instanceof RoleHierarchyNode)){ |
1612 |
|
|
1613 |
0
|
return false; |
1614 |
|
} |
1615 |
|
|
1616 |
17641
|
RoleHierarchyNode rhn1 = (RoleHierarchyNode)rhn; |
1617 |
|
|
1618 |
17641
|
if (rhn1==this || rhn1.getValue().intern()==getValue().intern()){ |
1619 |
|
|
1620 |
5606
|
return true; |
1621 |
|
} |
1622 |
|
|
1623 |
|
|
1624 |
|
|
1625 |
12035
|
if (rhn1.getLevel()<=getLevel() || subordinates==null){ |
1626 |
|
|
1627 |
6715
|
return false; |
1628 |
|
} |
1629 |
|
|
1630 |
6029
|
for (int i=0; i<subordinates.length; i++){ |
1631 |
|
|
1632 |
5963
|
if (subordinates[i].isSuperiorTo(rhn)){ |
1633 |
|
|
1634 |
5254
|
return true; |
1635 |
|
} |
1636 |
|
|
1637 |
|
} |
1638 |
|
|
1639 |
|
|
1640 |
66
|
return false; |
1641 |
|
} |
1642 |
|
|
1643 |
|
|
1644 |
|
|
1645 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1646 |
0
|
public String toString(){... |
1647 |
0
|
return getValue(); |
1648 |
|
} |
1649 |
|
} |
1650 |
|
|
1651 |
|
|
1652 |
|
|
1653 |
|
|
1654 |
|
|
1655 |
|
|
1656 |
|
@author |
1657 |
|
@version |
1658 |
|
|
|
|
| 85.7% |
Uncovered Elements: 6 (42) |
Complexity: 4 |
Complexity Density: 0.48 |
|
1659 |
|
public class RoleHierarchyPolicyNode extends PolicyXMLNode implements issrg.pba.rbac.RoleHierarchyPolicy { |
1660 |
|
|
1661 |
|
|
1662 |
|
|
1663 |
|
protected java.util.Map byType = new java.util.Hashtable(); |
1664 |
|
|
1665 |
|
|
1666 |
|
|
1667 |
|
|
1668 |
|
protected java.util.Map byOID = new java.util.Hashtable(); |
1669 |
|
protected java.util.Map typeOid = new java.util.Hashtable(); |
1670 |
|
|
1671 |
|
|
1672 |
|
|
1673 |
|
|
1674 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1675 |
25
|
public RoleHierarchyPolicyNode(Attributes attrs) {... |
1676 |
25
|
super(XMLTags.ROLE_HIERARCHY_POLICY_NODE, attrs); |
1677 |
|
|
1678 |
25
|
roleHierarchyPolicy = this; |
1679 |
|
} |
1680 |
|
|
1681 |
|
|
1682 |
|
|
1683 |
|
|
1684 |
|
|
1685 |
|
|
1686 |
|
@throws |
1687 |
|
|
1688 |
|
|
1689 |
|
|
|
|
| 77.8% |
Uncovered Elements: 4 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
1690 |
25
|
public void construct() throws PolicyParsingException{... |
1691 |
25
|
Object [] childs = children.toArray(); |
1692 |
|
|
1693 |
55
|
for (int i=0; i<childs.length; i++){ |
1694 |
30
|
RoleSpecNode rsn = (RoleSpecNode)childs[i]; |
1695 |
|
|
1696 |
30
|
String s = rsn.getType(); |
1697 |
30
|
String oid = rsn.getOID(); |
1698 |
30
|
if (byType.get(s)!=null){ |
1699 |
0
|
throw new PolicyParsingException("Role Type "+s+" defined more than once"); |
1700 |
|
} |
1701 |
|
|
1702 |
30
|
if (byOID.get(oid)!=null){ |
1703 |
0
|
throw new PolicyParsingException("Role OID "+oid+" defined more than once"); |
1704 |
|
} |
1705 |
|
|
1706 |
30
|
byType.put(s, rsn); |
1707 |
30
|
byOID.put(oid, rsn); |
1708 |
30
|
typeOid.put(s,oid); |
1709 |
|
} |
1710 |
|
} |
1711 |
|
|
1712 |
|
|
1713 |
|
|
1714 |
|
|
1715 |
|
|
1716 |
|
@param |
1717 |
|
|
1718 |
|
@return |
1719 |
|
|
1720 |
|
|
1721 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
1722 |
2919
|
public RoleSpecNode getByType(String roleType){... |
1723 |
2919
|
return roleType==null ? null : (RoleSpecNode)byType.get(roleType); |
1724 |
|
} |
1725 |
|
|
1726 |
|
|
1727 |
|
|
1728 |
|
|
1729 |
|
|
1730 |
|
|
1731 |
|
@param |
1732 |
|
|
1733 |
|
|
1734 |
|
@return |
1735 |
|
|
1736 |
|
|
1737 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
1738 |
1803
|
public RoleSpecNode getByOID(String roleOID){... |
1739 |
1803
|
return roleOID==null ? null : (RoleSpecNode)byOID.get(roleOID); |
1740 |
|
} |
1741 |
|
|
1742 |
|
|
1743 |
|
|
1744 |
|
|
1745 |
|
@param |
1746 |
|
|
1747 |
|
@return |
1748 |
|
|
1749 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1750 |
1803
|
public String getTypeByOID(String roleOID){... |
1751 |
1803
|
RoleSpecNode rsn = getByOID(roleOID); |
1752 |
|
|
1753 |
1803
|
return rsn==null ? null : rsn.getType(); |
1754 |
|
} |
1755 |
|
|
1756 |
|
|
1757 |
|
|
1758 |
|
|
1759 |
|
|
1760 |
|
@param |
1761 |
|
@param |
1762 |
|
|
1763 |
|
@return |
1764 |
|
|
1765 |
|
|
1766 |
|
|
1767 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1768 |
2589
|
public issrg.pba.rbac.RoleHierarchyNode getRole(String type, String value){... |
1769 |
2589
|
RoleSpecNode rsn = getByType(type); |
1770 |
2589
|
return rsn==null ? null : rsn.getRole(value); |
1771 |
|
} |
1772 |
|
|
1773 |
|
|
1774 |
|
|
1775 |
|
|
1776 |
|
|
1777 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1778 |
1
|
public Map getTypeOid() {... |
1779 |
1
|
return typeOid; |
1780 |
|
} |
1781 |
|
} |
1782 |
|
|
1783 |
|
|
1784 |
|
|
1785 |
|
|
1786 |
|
|
1787 |
|
|
1788 |
|
|
1789 |
|
|
1790 |
|
|
1791 |
|
@author |
1792 |
|
@version |
1793 |
|
|
|
|
| 82% |
Uncovered Elements: 9 (50) |
Complexity: 8 |
Complexity Density: 0.39 |
|
1794 |
|
public class RoleListNode extends PolicyXMLNode { |
1795 |
|
|
1796 |
|
|
1797 |
|
|
1798 |
|
protected RoleHierarchyPolicyNode policy; |
1799 |
|
|
1800 |
|
|
1801 |
|
|
1802 |
|
|
1803 |
|
protected issrg.pba.Credentials credential; |
1804 |
|
|
1805 |
|
|
1806 |
|
|
1807 |
|
|
1808 |
|
|
1809 |
|
|
1810 |
|
|
1811 |
|
|
1812 |
|
@param |
1813 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1814 |
151
|
public RoleListNode(Attributes attrs){... |
1815 |
151
|
this(null, attrs); |
1816 |
|
} |
1817 |
|
|
1818 |
|
|
1819 |
|
|
1820 |
|
|
1821 |
|
|
1822 |
|
@param |
1823 |
|
|
1824 |
|
|
1825 |
|
@param |
1826 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1827 |
151
|
public RoleListNode(RoleHierarchyPolicyNode rhpn, Attributes attrs){... |
1828 |
151
|
super(XMLTags.ROLE_LIST_NODE, attrs); |
1829 |
|
|
1830 |
151
|
policy = rhpn==null?roleHierarchyPolicy:rhpn; |
1831 |
|
} |
1832 |
|
|
1833 |
|
|
1834 |
|
|
1835 |
|
|
1836 |
|
|
1837 |
|
|
1838 |
|
|
1839 |
|
|
1840 |
|
|
1841 |
|
|
|
|
| 80% |
Uncovered Elements: 8 (40) |
Complexity: 8 |
Complexity Density: 0.33 |
|
1842 |
203
|
public void construct() throws PolicyParsingException {... |
1843 |
203
|
java.util.Vector v = new java.util.Vector(); |
1844 |
|
|
1845 |
444
|
for (int i=children.size(); i-->0; ){ |
1846 |
241
|
PolicyXMLNode c2 = (PolicyXMLNode)children.get(i); |
1847 |
241
|
if (c2.getName().intern()!=XMLTags.ROLE_NODE){ |
1848 |
0
|
throw new PolicyParsingException("Syntax error. "+XMLTags.ROLE_NODE+" node was expected, but "+c2.getName()+" was found"); |
1849 |
|
} |
1850 |
241
|
String roleType = (String)c2.getAttributes().get(XMLTags.TYPE_ATTRIBUTE); |
1851 |
241
|
String roleValue = (String)c2.getAttributes().get(XMLTags.VALUE_ATTRIBUTE); |
1852 |
|
|
1853 |
241
|
RoleSpecNode rsn = null; |
1854 |
241
|
RoleHierarchyNode rhn = null; |
1855 |
|
|
1856 |
241
|
issrg.pba.Credentials cred=null; |
1857 |
|
|
1858 |
241
|
if (roleType==null){ |
1859 |
0
|
throw new PolicyParsingException("No Role Type has been specified"); |
1860 |
|
} |
1861 |
|
|
1862 |
241
|
rsn = policy.getByType(roleType); |
1863 |
241
|
if (rsn==null){ |
1864 |
0
|
throw new PolicyParsingException("No Role Type "+roleType+" has been defined"); |
1865 |
|
} |
1866 |
|
|
1867 |
241
|
if (roleValue==null){ |
1868 |
24
|
roleValue=""; |
1869 |
|
|
1870 |
|
} |
1871 |
|
|
1872 |
241
|
if (roleValue.intern()!=""){ |
1873 |
203
|
rhn = rsn.getRole(roleValue); |
1874 |
203
|
if (rhn==null){ |
1875 |
0
|
throw new PolicyParsingException("No such Role Value "+roleValue+" for Role Type "+roleType+" has been defined"); |
1876 |
|
} |
1877 |
|
} |
1878 |
|
|
1879 |
241
|
cred = new issrg.pba.rbac.ExpirableCredentials( |
1880 |
241
|
rhn==null ? new issrg.pba.rbac.PermisCredentials(roleType) :new issrg.pba.rbac.PermisCredentials(rhn), |
1881 |
|
validityForRoleList |
1882 |
|
); |
1883 |
|
|
1884 |
|
|
1885 |
|
|
1886 |
|
|
1887 |
|
|
1888 |
|
|
1889 |
|
|
1890 |
|
|
1891 |
|
|
1892 |
|
|
1893 |
|
|
1894 |
|
|
1895 |
|
|
1896 |
|
|
1897 |
|
|
1898 |
241
|
v.add(cred); |
1899 |
|
|
1900 |
|
} |
1901 |
203
|
credential = new issrg.pba.rbac.SetOfSubsetsCredentials(v); |
1902 |
|
} |
1903 |
|
|
1904 |
|
|
1905 |
|
|
1906 |
|
|
1907 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1908 |
151
|
public issrg.pba.Credentials getCredential(){... |
1909 |
151
|
return credential; |
1910 |
|
} |
1911 |
|
} |
1912 |
|
|
1913 |
|
|
1914 |
|
|
1915 |
|
|
1916 |
|
|
1917 |
|
|
1918 |
|
|
1919 |
|
|
1920 |
|
|
1921 |
|
|
1922 |
|
@author |
1923 |
|
@version |
1924 |
|
|
|
|
| 90% |
Uncovered Elements: 3 (30) |
Complexity: 4 |
Complexity Density: 0.47 |
|
1925 |
|
public class RoleSpecNode extends PolicyXMLNode{ |
1926 |
|
|
1927 |
|
|
1928 |
|
|
1929 |
|
protected String type; |
1930 |
|
protected String oid; |
1931 |
|
|
1932 |
|
|
1933 |
|
|
1934 |
|
|
1935 |
|
protected java.util.Map roles = new java.util.Hashtable(); |
1936 |
|
|
1937 |
|
|
1938 |
|
|
1939 |
|
|
1940 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1941 |
30
|
public RoleSpecNode(org.xml.sax.Attributes attrs) {... |
1942 |
30
|
super(XMLTags.ROLE_SPEC_NODE, attrs); |
1943 |
|
|
1944 |
30
|
type = attrs.getValue(XMLTags.TYPE_ATTRIBUTE); |
1945 |
30
|
oid = attrs.getValue(XMLTags.OID_ATTRIBUTE); |
1946 |
|
} |
1947 |
|
|
1948 |
|
|
1949 |
|
|
1950 |
|
|
1951 |
|
|
1952 |
|
|
1953 |
|
|
1954 |
|
|
1955 |
|
|
1956 |
|
|
1957 |
|
@throws |
1958 |
|
|
1959 |
|
|
1960 |
|
|
|
|
| 88.2% |
Uncovered Elements: 2 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
1961 |
30
|
public void construct() throws PolicyParsingException{... |
1962 |
|
|
1963 |
|
|
1964 |
|
|
1965 |
|
|
1966 |
30
|
Object [] curr_roles=children.toArray(); |
1967 |
|
|
1968 |
|
|
1969 |
|
|
1970 |
131
|
for (int i=0; i<curr_roles.length; i++){ |
1971 |
101
|
RoleHierarchyNode rhn = (RoleHierarchyNode)curr_roles[i]; |
1972 |
101
|
String s = rhn.getValue(); |
1973 |
101
|
if (roles.get(s)!=null){ |
1974 |
0
|
throw new PolicyParsingException("Role reference ID "+s+" defined elsewhere"); |
1975 |
|
} |
1976 |
|
|
1977 |
101
|
rhn.setRoleType(type); |
1978 |
|
|
1979 |
101
|
roles.put(s, rhn); |
1980 |
|
} |
1981 |
|
|
1982 |
131
|
for (int i=0; i<curr_roles.length; i++){ |
1983 |
101
|
RoleHierarchyNode rhn = (RoleHierarchyNode)curr_roles[i]; |
1984 |
101
|
rhn.optimise(roles); |
1985 |
|
} |
1986 |
|
|
1987 |
|
|
1988 |
|
} |
1989 |
|
|
1990 |
|
|
1991 |
|
|
1992 |
|
|
1993 |
|
@param |
1994 |
|
|
1995 |
|
@return |
1996 |
|
|
1997 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
1998 |
2875
|
public RoleHierarchyNode getRole(String value){... |
1999 |
2875
|
return value==null ? null : (RoleHierarchyNode)roles.get(value); |
2000 |
|
} |
2001 |
|
|
2002 |
|
|
2003 |
|
|
2004 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2005 |
1829
|
public String getType(){... |
2006 |
1829
|
return type; |
2007 |
|
} |
2008 |
|
|
2009 |
|
|
2010 |
|
|
2011 |
|
|
2012 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2013 |
30
|
public String getOID(){... |
2014 |
30
|
return oid; |
2015 |
|
} |
2016 |
|
} |
2017 |
|
|
2018 |
|
|
2019 |
|
|
2020 |
|
|
2021 |
|
|
2022 |
|
|
2023 |
|
@author |
2024 |
|
@version |
2025 |
|
|
2026 |
|
|
|
|
| 75.6% |
Uncovered Elements: 10 (41) |
Complexity: 10 |
Complexity Density: 0.52 |
|
2027 |
|
public class SOAPolicyNode extends PolicyXMLNode{ |
2028 |
|
|
2029 |
|
|
2030 |
|
|
2031 |
|
private java.util.Map soas; |
2032 |
|
|
2033 |
|
|
2034 |
|
|
2035 |
|
|
2036 |
|
|
2037 |
|
|
2038 |
|
@param |
2039 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2040 |
25
|
public SOAPolicyNode(Attributes attrs) {... |
2041 |
25
|
super(XMLTags.SOA_POLICY_NODE, attrs); |
2042 |
|
|
2043 |
25
|
soaPolicy = this; |
2044 |
|
} |
2045 |
|
|
2046 |
|
|
2047 |
|
|
2048 |
|
|
2049 |
|
|
2050 |
|
|
2051 |
|
|
|
|
| 69.7% |
Uncovered Elements: 10 (33) |
Complexity: 10 |
Complexity Density: 0.48 |
|
2052 |
25
|
public void construct() throws PolicyParsingException{... |
2053 |
25
|
try{ |
2054 |
25
|
soas = new java.util.Hashtable(); |
2055 |
65
|
for (int i=children.size(); i-->0; ){ |
2056 |
40
|
PolicyXMLNode c = (PolicyXMLNode)children.get(i); |
2057 |
40
|
if (c.getName().intern()!=XMLTags.SOA_SPEC_NODE){ |
2058 |
0
|
throw new PolicyParsingException(XMLTags.SOA_SPEC_NODE+" nodes are allowed under this node"); |
2059 |
|
} |
2060 |
40
|
String id = (String) c.getAttributes().get(XMLTags.ID_ATTRIBUTE); |
2061 |
40
|
String dn = (String) c.getAttributes().get(XMLTags.LDAPDN_ATTRIBUTE); |
2062 |
40
|
String url = (String) c.getAttributes().get(XMLTags.URL_ATTRIBUTE); |
2063 |
|
|
2064 |
40
|
if (id==null || (dn==null && url==null)){ |
2065 |
0
|
throw new PolicyParsingException(XMLTags.ID_ATTRIBUTE+" and "+XMLTags.LDAPDN_ATTRIBUTE+" or "+XMLTags.URL_ATTRIBUTE+" attributes are required for "+XMLTags.SOA_SPEC_NODE+" nodes"); |
2066 |
|
} |
2067 |
|
|
2068 |
40
|
if (soas.get(id)!=null){ |
2069 |
0
|
throw new PolicyParsingException("Several SOAs with the same id: "+id); |
2070 |
|
} |
2071 |
|
|
2072 |
|
|
2073 |
40
|
Principal soa; |
2074 |
40
|
try{ |
2075 |
|
|
2076 |
40
|
soa = dn!=null?new LDAPDNPrincipal(dn): URLHandler.getPrincipalByURL(url); |
2077 |
|
}catch (BadURLException bue){ |
2078 |
0
|
throw new PolicyParsingException("URL Handling failed: "+bue.getMessage(), bue); |
2079 |
|
} |
2080 |
|
|
2081 |
40
|
if (soa==null){ |
2082 |
0
|
throw new PolicyParsingException("URL Handler was not found for "+URLHandler.getProtocolName(url)); |
2083 |
|
} |
2084 |
|
|
2085 |
40
|
soas.put(id, soa); |
2086 |
|
} |
2087 |
|
|
2088 |
|
}catch (Throwable th){ |
2089 |
0
|
throw new PolicyParsingException("Syntax error: "+th.getMessage()); |
2090 |
|
} |
2091 |
|
} |
2092 |
|
|
2093 |
|
|
2094 |
|
|
2095 |
|
|
2096 |
|
|
2097 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2098 |
52
|
public java.security.Principal getSOA(String id){... |
2099 |
52
|
return (java.security.Principal)soas.get(id); |
2100 |
|
} |
2101 |
|
|
2102 |
|
|
2103 |
|
|
2104 |
|
@return |
2105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2106 |
1
|
public java.util.Map getSOAs(){... |
2107 |
1
|
return soas; |
2108 |
|
} |
2109 |
|
} |
2110 |
|
|
2111 |
|
|
2112 |
|
|
2113 |
|
|
2114 |
|
|
|
|
| 79.6% |
Uncovered Elements: 33 (162) |
Complexity: 34 |
Complexity Density: 0.36 |
|
2115 |
|
public class TargetAccessPolicyNode extends PolicyXMLNode { |
2116 |
|
|
2117 |
|
|
2118 |
|
public static final int ROLE_LIST_SEQUENCE = 0; |
2119 |
|
public static final int TARGET_LIST_SEQUENCE = 1; |
2120 |
|
public static final int IF_SEQUENCE = 2; |
2121 |
|
|
2122 |
|
|
2123 |
|
|
2124 |
|
|
2125 |
|
|
2126 |
|
|
2127 |
|
public static final int OBLIGATIONS_SEQUENCE=3; |
2128 |
|
public static final int OBLIGATIONS_SHIFT=-1; |
2129 |
|
|
2130 |
|
|
2131 |
|
|
2132 |
|
|
2133 |
|
public static final char ACTIONS_SEPARATORS = ','; |
2134 |
|
|
2135 |
|
|
2136 |
|
|
2137 |
|
|
2138 |
|
private java.util.Map rules = new java.util.Hashtable(); |
2139 |
|
|
2140 |
|
|
2141 |
|
|
2142 |
|
|
2143 |
|
|
2144 |
|
private PolicyXMLNode[] if_statementNodes = null; |
2145 |
|
|
2146 |
|
|
2147 |
|
|
2148 |
|
|
2149 |
|
|
2150 |
|
@return |
2151 |
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
2152 |
1
|
public issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode[] getAllNeededAttributes() {... |
2153 |
1
|
ArrayList list = new ArrayList(); |
2154 |
2
|
for (int i=0; i<this.if_statementNodes.length; i++) { |
2155 |
1
|
ArrayList local=travers(this.if_statementNodes[i]); |
2156 |
1
|
if (!local.isEmpty()) list.addAll(local); |
2157 |
|
} |
2158 |
1
|
issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode[] nodes = |
2159 |
|
new issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode[list.size()]; |
2160 |
1
|
nodes = (issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode[])list.toArray(nodes); |
2161 |
1
|
return nodes; |
2162 |
|
} |
2163 |
|
|
2164 |
|
|
2165 |
|
|
2166 |
|
@param |
2167 |
|
@return |
2168 |
|
|
2169 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
2170 |
8
|
private ArrayList travers(PolicyXMLNode node) {... |
2171 |
8
|
ArrayList list = new ArrayList(); |
2172 |
8
|
if (node.getChildren().size()>0) { |
2173 |
11
|
for (int i=0; i<node.getChildren().size(); i++) { |
2174 |
7
|
PolicyXMLNode child = (PolicyXMLNode)node.getChildren().get(i); |
2175 |
7
|
ArrayList sub = this.travers(child); |
2176 |
7
|
list.addAll(sub); |
2177 |
|
} |
2178 |
|
} else { |
2179 |
4
|
if (node instanceof issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode) { |
2180 |
2
|
list.add(node); |
2181 |
|
} |
2182 |
|
} |
2183 |
8
|
return list; |
2184 |
|
} |
2185 |
|
|
2186 |
|
|
2187 |
|
|
2188 |
|
|
2189 |
|
|
2190 |
|
|
2191 |
|
|
2192 |
|
|
2193 |
|
|
2194 |
|
@param |
2195 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
2196 |
25
|
public TargetAccessPolicyNode(Attributes attrs){... |
2197 |
25
|
super(XMLTags.TARGET_ACCESS_POLICY_NODE, attrs); |
2198 |
|
|
2199 |
25
|
targetAccessPolicy = this; |
2200 |
|
|
2201 |
25
|
validityForRoleList = new issrg.pba.rbac.NowValidityPeriod(); |
2202 |
|
} |
2203 |
|
|
2204 |
|
|
2205 |
|
|
2206 |
|
|
2207 |
|
|
2208 |
|
|
2209 |
|
|
|
|
| 74.6% |
Uncovered Elements: 32 (126) |
Complexity: 29 |
Complexity Density: 0.35 |
|
2210 |
25
|
public void construct() throws PolicyParsingException{... |
2211 |
|
|
2212 |
|
|
2213 |
25
|
ArrayList envList = new ArrayList(); |
2214 |
|
|
2215 |
|
|
2216 |
|
|
2217 |
|
|
2218 |
|
|
2219 |
|
|
2220 |
|
|
2221 |
|
|
2222 |
|
|
2223 |
|
|
2224 |
25
|
int oblgs_shift_factor=0; |
2225 |
|
|
2226 |
|
|
2227 |
|
|
2228 |
|
|
2229 |
124
|
for(int i=children.size(); i-->0;){ |
2230 |
|
|
2231 |
99
|
oblgs_shift_factor=0; |
2232 |
|
|
2233 |
|
|
2234 |
99
|
PolicyXMLNode ta = expect(children, i, XMLTags.TARGET_ACCESS_NODE); |
2235 |
|
|
2236 |
|
|
2237 |
99
|
Vector ta_children = ta.getChildren(); |
2238 |
|
|
2239 |
|
|
2240 |
99
|
issrg.pba.Credentials cred = ((RoleListNode)expect(ta_children, ROLE_LIST_SEQUENCE, XMLTags.ROLE_LIST_NODE)).getCredential(); |
2241 |
|
|
2242 |
|
|
2243 |
99
|
Vector tl = expect(ta_children, TARGET_LIST_SEQUENCE, XMLTags.TARGET_LIST_NODE).getChildren(); |
2244 |
99
|
if (tl.size()<1){ |
2245 |
0
|
throw new PolicyParsingException("TargetList cannot be empty"); |
2246 |
|
} |
2247 |
|
|
2248 |
|
|
2249 |
99
|
PolicyXMLNode _if = expect(ta_children, IF_SEQUENCE, XMLTags.IF_NODE, true); |
2250 |
99
|
issrg.pba.rbac.xmlpolicy.ifstatement.Term the_if=null; |
2251 |
|
|
2252 |
99
|
if (_if!=null){ |
2253 |
35
|
envList.add(_if); |
2254 |
35
|
oblgs_shift_factor=0; |
2255 |
35
|
Vector if_children = _if.getChildren(); |
2256 |
|
|
2257 |
35
|
if (if_children.size()!=1){ |
2258 |
0
|
throw new PolicyParsingException("IF-statement must contain one child node"); |
2259 |
|
} |
2260 |
|
|
2261 |
35
|
Object o=if_children.get(0); |
2262 |
35
|
if (!(o instanceof issrg.pba.rbac.xmlpolicy.ifstatement.Term)){ |
2263 |
0
|
throw new PolicyParsingException("IF-statement can contain only valid evaluation operations: "+o.getClass().getName()+" object found, but Term was expected. Node name: "+((PolicyXMLNode)o).getName()); |
2264 |
|
} |
2265 |
|
|
2266 |
35
|
the_if=(issrg.pba.rbac.xmlpolicy.ifstatement.Term)o; |
2267 |
35
|
if (the_if.getType().intern()!=issrg.pba.rbac.xmlpolicy.ifstatement.Types.BOOLEAN_TYPE.intern()){ |
2268 |
0
|
throw new PolicyParsingException("IF-statement can start only with a boolean term"); |
2269 |
|
} |
2270 |
|
}else{ |
2271 |
|
|
2272 |
64
|
oblgs_shift_factor=OBLIGATIONS_SHIFT; |
2273 |
|
} |
2274 |
|
|
2275 |
|
|
2276 |
280
|
for (int j=tl.size(); j-->0;){ |
2277 |
|
|
2278 |
181
|
PolicyXMLNode t = expect(tl, j, XMLTags.TARGET_NODE); |
2279 |
|
|
2280 |
|
|
2281 |
|
|
2282 |
181
|
Vector v = t.getChildren(); |
2283 |
181
|
if (v.size()!=1){ |
2284 |
0
|
throw new PolicyParsingException(XMLTags.TARGET_NODE+" must contain one node"); |
2285 |
|
} |
2286 |
|
|
2287 |
|
|
2288 |
181
|
PolicyXMLNode t1 = expect(v, 0, XMLTags.TARGET_DOMAIN_NODE, true); |
2289 |
181
|
Subtree targetDomain; |
2290 |
181
|
String targetAttribute; |
2291 |
|
|
2292 |
181
|
if (t1==null){ |
2293 |
0
|
t1 = expect(v, 0, XMLTags.TARGET_NAME_NODE); |
2294 |
|
|
2295 |
0
|
targetAttribute = (String)t1.getAttributes().get(XMLTags.LDAPDN_ATTRIBUTE); |
2296 |
0
|
if (targetAttribute==null){ |
2297 |
0
|
throw new PolicyParsingException(XMLTags.LDAPDN_ATTRIBUTE+" attribute is required for "+XMLTags.TARGET_NAME_NODE+" tag"); |
2298 |
|
} |
2299 |
|
|
2300 |
0
|
try{ |
2301 |
|
|
2302 |
0
|
issrg.pba.rbac.PermisTarget target = new issrg.pba.rbac.PermisTarget(targetAttribute, null); |
2303 |
|
|
2304 |
|
|
2305 |
|
|
2306 |
|
|
2307 |
0
|
targetDomain = new DITSubtree(target.getDN(), 0, 0, null, null); |
2308 |
|
|
2309 |
|
|
2310 |
|
}catch (issrg.utils.RFC2253ParsingException rpe){ |
2311 |
0
|
throw new PolicyParsingException(targetAttribute+" is not a valid target name", rpe); |
2312 |
|
} |
2313 |
|
}else{ |
2314 |
|
|
2315 |
181
|
targetAttribute = (String)t1.getAttributes().get(XMLTags.ID_ATTRIBUTE); |
2316 |
181
|
if (targetAttribute==null){ |
2317 |
0
|
throw new PolicyParsingException(XMLTags.ID_ATTRIBUTE+" attribute is required for "+XMLTags.TARGET_DOMAIN_NODE+" tag"); |
2318 |
|
} |
2319 |
|
|
2320 |
181
|
targetDomain = targetPolicy.getDomain(targetAttribute); |
2321 |
|
} |
2322 |
|
|
2323 |
181
|
if (targetDomain==null){ |
2324 |
0
|
throw new PolicyParsingException(targetAttribute+" is not within declared Target domains"); |
2325 |
|
} |
2326 |
|
|
2327 |
|
|
2328 |
|
|
2329 |
|
|
2330 |
|
|
2331 |
181
|
Obligations oblgsOfRule=null; |
2332 |
181
|
SimpleObligations ruleObligations=null; |
2333 |
|
|
2334 |
181
|
PolicyXMLNode obligationsNode = expect(ta_children, OBLIGATIONS_SEQUENCE+oblgs_shift_factor, XMLTags.OBLIGATIONS_NODE, true); |
2335 |
|
|
2336 |
181
|
if(obligationsNode!=null){ |
2337 |
|
|
2338 |
2
|
ruleObligations=new SimpleObligations(obligationsNode); |
2339 |
|
|
2340 |
|
|
2341 |
|
}else{ |
2342 |
179
|
ruleObligations=null; |
2343 |
|
} |
2344 |
|
|
2345 |
|
|
2346 |
181
|
oblgsOfRule=ruleObligations; |
2347 |
|
|
2348 |
|
|
2349 |
181
|
issrg.pba.rbac.policies.AccessRule ar = new |
2350 |
|
issrg.pba.rbac.policies.AccessRule(targetDomain, cred, the_if, oblgsOfRule); |
2351 |
|
|
2352 |
181
|
String acts = (String)t.getAttributes().get(XMLTags.ACTIONS_ATTRIBUTE); |
2353 |
|
|
2354 |
181
|
Object act = null; |
2355 |
181
|
if (acts==null || acts.intern()==""){ |
2356 |
0
|
acts=""; |
2357 |
0
|
act=""; |
2358 |
|
} |
2359 |
|
|
2360 |
|
|
2361 |
|
|
2362 |
|
|
2363 |
|
|
2364 |
|
|
2365 |
181
|
java.util.Enumeration actions=new EscapedStringTokenizer(acts, ACTIONS_SEPARATORS); |
2366 |
181
|
while(true){ |
2367 |
|
|
2368 |
378
|
if (act!=null){ |
2369 |
|
|
2370 |
|
|
2371 |
197
|
java.util.Vector v1 = (java.util.Vector)rules.get(act); |
2372 |
197
|
if (v1==null){ |
2373 |
93
|
rules.put(act, v1=new java.util.Vector()); |
2374 |
|
} |
2375 |
|
|
2376 |
197
|
String[] applyToTargets = actionPolicy.getApplyToTargets((String)act); |
2377 |
197
|
if(applyToTargets != null && applyToTargets.length>0) |
2378 |
|
{ |
2379 |
1
|
boolean foundTarget = false; |
2380 |
1
|
for(int k=0;k<applyToTargets.length;k++) |
2381 |
1
|
if((t1.getName().intern() == XMLTags.TARGET_DOMAIN_NODE |
2382 |
|
&& applyToTargets[k].equals(targetAttribute)) |
2383 |
|
||(t1.getName().intern() == XMLTags.TARGET_NAME_NODE |
2384 |
|
&& targetPolicy.getDomain(applyToTargets[k]).equals(targetDomain))) |
2385 |
|
{ |
2386 |
1
|
foundTarget = true; |
2387 |
1
|
break; |
2388 |
|
} |
2389 |
1
|
if(!foundTarget) |
2390 |
0
|
throw new PolicyParsingException(act + " can not be applied to " + targetAttribute); |
2391 |
|
} |
2392 |
|
|
2393 |
197
|
v1.add(ar); |
2394 |
|
} |
2395 |
|
|
2396 |
378
|
if (!actions.hasMoreElements()){ |
2397 |
181
|
break; |
2398 |
|
} |
2399 |
|
|
2400 |
197
|
act = actions.nextElement(); |
2401 |
|
} |
2402 |
|
} |
2403 |
|
} |
2404 |
25
|
this.if_statementNodes = new PolicyXMLNode[envList.size()]; |
2405 |
25
|
this.if_statementNodes = (PolicyXMLNode[])envList.toArray(this.if_statementNodes); |
2406 |
|
|
2407 |
|
|
2408 |
|
|
2409 |
|
|
2410 |
|
|
2411 |
|
|
2412 |
|
|
2413 |
25
|
rules.put(ActionPolicyNode.class, actionPolicy); |
2414 |
25
|
rules.put(DomainPolicyNode.class, targetPolicy); |
2415 |
|
} |
2416 |
|
|
2417 |
|
|
2418 |
|
|
2419 |
|
|
2420 |
|
|
2421 |
|
|
2422 |
|
|
2423 |
|
|
2424 |
|
|
2425 |
|
|
2426 |
|
|
2427 |
|
|
2428 |
|
|
2429 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2430 |
24
|
public Map getRules(){... |
2431 |
24
|
return rules; |
2432 |
|
} |
2433 |
|
|
2434 |
|
} |
2435 |
|
|
2436 |
|
|
2437 |
|
|
2438 |
|
|
2439 |
|
|
2440 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.67 |
|
2441 |
|
public class PMIXMLPolicyNode extends PolicyXMLNode{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2442 |
25
|
public PMIXMLPolicyNode(Attributes attrs){... |
2443 |
25
|
super(XMLTags.X_509_PMI_RBAC_POLICY_NODE, attrs); |
2444 |
|
|
2445 |
25
|
pmiXMLPolicy = this; |
2446 |
|
} |
2447 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2448 |
14
|
public String getOID(){... |
2449 |
14
|
return (String)getAttributes().get(XMLTags.OID_ATTRIBUTE); |
2450 |
|
} |
2451 |
|
} |
2452 |
|
|
2453 |
|
|
2454 |
|
|
2455 |
|
|
2456 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 3 |
Complexity Density: 0.56 |
|
2457 |
|
public class RepositoryPolicyNode extends PolicyXMLNode{ |
2458 |
|
String [] urls; |
2459 |
|
|
2460 |
|
|
2461 |
|
|
2462 |
|
|
2463 |
|
|
2464 |
|
|
2465 |
|
@param |
2466 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2467 |
2
|
public RepositoryPolicyNode(Attributes attrs){... |
2468 |
2
|
super(XMLTags.REPOSITORY_POLICY_NODE, attrs); |
2469 |
|
|
2470 |
2
|
repositoryPolicy = this; |
2471 |
|
} |
2472 |
|
|
2473 |
|
|
2474 |
|
|
2475 |
|
|
2476 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
2477 |
2
|
public void construct() throws PolicyParsingException {... |
2478 |
2
|
urls=new String[children.size()]; |
2479 |
6
|
for (int i=children.size(); i-->0;){ |
2480 |
4
|
PolicyXMLNode t = expect(children, i, XMLTags.REPOSITORY_NODE); |
2481 |
4
|
urls[i]=(String)t.getAttributes().get(XMLTags.URL_ATTRIBUTE); |
2482 |
0
|
if (urls[i]==null) throw new PolicyParsingException(XMLTags.URL_ATTRIBUTE+" attribute must be specified for "+XMLTags.REPOSITORY_NODE); |
2483 |
|
} |
2484 |
|
} |
2485 |
|
|
2486 |
|
|
2487 |
|
|
2488 |
|
|
2489 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2490 |
2
|
public String[] getURLs(){... |
2491 |
2
|
return urls; |
2492 |
|
} |
2493 |
|
} |
2494 |
|
|
2495 |
|
|
2496 |
|
|
2497 |
|
|
2498 |
|
|
|
|
| 81.7% |
Uncovered Elements: 21 (115) |
Complexity: 21 |
Complexity Density: 0.3 |
|
2499 |
|
public class MSoDPolicySetNode extends PolicyXMLNode{ |
2500 |
|
|
2501 |
|
private java.util.Vector msodRules = new java.util.Vector(); |
2502 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
2503 |
4
|
public MSoDPolicySetNode(Attributes attrs){... |
2504 |
4
|
super("MSoDPolicySetNode", attrs); |
2505 |
4
|
msodPolicySetNode = this; |
2506 |
|
} |
2507 |
|
|
|
|
| 80.7% |
Uncovered Elements: 21 (109) |
Complexity: 21 |
Complexity Density: 0.29 |
|
2508 |
4
|
public void construct() throws PolicyParsingException {... |
2509 |
32
|
for(int i=children.size(); i-->0;){ |
2510 |
28
|
issrg.pba.rbac.policies.MSoDRule msodRule = null; |
2511 |
|
|
2512 |
28
|
PolicyXMLNode ta = expect(children, i, XMLTags.MSoD_POLICY_NODE); |
2513 |
|
|
2514 |
28
|
String contextName = (String) ( (java.util.Hashtable)(ta.getAttributes()) ).get(XMLTags.CONTEXT_NAME); |
2515 |
|
|
2516 |
28
|
String firstAction=null, firstTarget=null, lastAction=null, lastTarget=null; |
2517 |
|
|
2518 |
28
|
java.util.Vector mmer = new java.util.Vector(); |
2519 |
28
|
java.util.Vector mmep = new java.util.Vector(); |
2520 |
|
|
2521 |
28
|
Vector ta_children = ta.getChildren(); |
2522 |
128
|
for (int j=0; j<ta_children.size(); ++j) { |
2523 |
100
|
PolicyXMLNode t2=(PolicyXMLNode) ta_children.get(j); |
2524 |
100
|
if (t2.getName().equals(XMLTags.MSoD_POLICY_FIRSTSTEP) ) { |
2525 |
12
|
firstAction = (String) t2.getAttributes().get("operation"); |
2526 |
12
|
if (actionPolicy.getActionDefinition(firstAction) == null ) { |
2527 |
0
|
throw new PolicyParsingException(firstAction + " does not exist in the Action policy."); |
2528 |
|
} |
2529 |
12
|
firstTarget = (String) t2.getAttributes().get("targetURI"); |
2530 |
|
|
2531 |
|
|
2532 |
|
} else |
2533 |
|
|
2534 |
88
|
if (t2.getName().equals(XMLTags.MSoD_POLICY_LASTSTEP) ) { |
2535 |
24
|
lastAction = (String) t2.getAttributes().get("operation"); |
2536 |
24
|
if (actionPolicy.getActionDefinition(lastAction) == null ) { |
2537 |
0
|
throw new PolicyParsingException(lastAction + " does not exist in the Action policy."); |
2538 |
|
} |
2539 |
24
|
lastTarget = (String) t2.getAttributes().get("targetURI"); |
2540 |
|
|
2541 |
|
|
2542 |
|
} else |
2543 |
|
|
2544 |
64
|
if (t2.getName().equals("MMER") ) { |
2545 |
28
|
int forbiddenCardinality; |
2546 |
28
|
String intS =(String) t2.getAttributes().get("ForbiddenCardinality"); |
2547 |
28
|
try { |
2548 |
28
|
forbiddenCardinality = Integer.parseInt( intS ); |
2549 |
|
} |
2550 |
|
catch (Exception me) { |
2551 |
0
|
throw new PolicyParsingException(intS + " for ForbiddenCardinality is not a valid integer", me); |
2552 |
|
} |
2553 |
|
|
2554 |
28
|
if (forbiddenCardinality <=1 ) { |
2555 |
0
|
throw new PolicyParsingException("ForbiddenCardinality =" + forbiddenCardinality + ", it is less then 2, this is not allowed"); |
2556 |
|
} |
2557 |
|
|
2558 |
28
|
Vector mmer_children = t2.getChildren(); |
2559 |
28
|
Vector mmerRoles = new Vector(); |
2560 |
28
|
int roleCount = 0; |
2561 |
|
|
2562 |
92
|
for (int k=0; k<mmer_children.size(); ++k) { |
2563 |
64
|
PolicyXMLNode t3=(PolicyXMLNode) mmer_children.get(k); |
2564 |
64
|
if (t3.getName().equals("Role") ) { |
2565 |
64
|
String type = (String) t3.getAttributes().get("type"); |
2566 |
64
|
String value = (String) t3.getAttributes().get("value"); |
2567 |
|
|
2568 |
|
|
2569 |
64
|
RoleHierarchyNode rhn2 = getRole(type, value); |
2570 |
64
|
if (rhn2 == null) { |
2571 |
0
|
throw new PolicyParsingException(type + " " + value + " does not exist in the role assignment policy."); |
2572 |
|
} |
2573 |
64
|
issrg.pba.Credentials roleC = new PermisCredentials( rhn2); |
2574 |
64
|
mmerRoles.add(roleC); |
2575 |
64
|
++roleCount; |
2576 |
|
} |
2577 |
|
} |
2578 |
28
|
if ( roleCount < forbiddenCardinality ) { |
2579 |
0
|
throw new PolicyParsingException("Number of roles is less than ForbiddenCardinality " + forbiddenCardinality + ", this is not allowed"); |
2580 |
|
} |
2581 |
28
|
MMERUnit mmerUnit = |
2582 |
|
new MMERUnit(forbiddenCardinality, mmerRoles); |
2583 |
28
|
mmer.add(mmerUnit); |
2584 |
|
|
2585 |
|
} else |
2586 |
36
|
if (t2.getName().equals("MMEP") ) { |
2587 |
36
|
int forbiddenCardinality; |
2588 |
36
|
String intS = (String) t2.getAttributes().get("ForbiddenCardinality"); |
2589 |
36
|
try { |
2590 |
36
|
forbiddenCardinality = Integer.parseInt( intS ); |
2591 |
|
} |
2592 |
|
catch (Exception me) { |
2593 |
0
|
throw new PolicyParsingException(intS + " for ForbiddenCardinality is not a valid integer", me); |
2594 |
|
} |
2595 |
|
|
2596 |
36
|
if (forbiddenCardinality <=1 ) { |
2597 |
0
|
throw new PolicyParsingException("ForbiddenCardinality =" + forbiddenCardinality + ", it is less then 2, this is not allowed"); |
2598 |
|
} |
2599 |
|
|
2600 |
36
|
Vector mmep_children = t2.getChildren(); |
2601 |
36
|
Vector mmepOperations = new Vector(); |
2602 |
36
|
int operationCount = 0; |
2603 |
|
|
2604 |
132
|
for (int k=0; k<mmep_children.size(); ++k) { |
2605 |
96
|
PolicyXMLNode t3=(PolicyXMLNode) mmep_children.get(k); |
2606 |
96
|
if (t3.getName().equals("Operation") ) { |
2607 |
96
|
String value = (String) t3.getAttributes().get("value"); |
2608 |
96
|
if (actionPolicy.getActionDefinition(value) == null ) { |
2609 |
0
|
throw new PolicyParsingException(value + " does not exist in the Action policy."); |
2610 |
|
} |
2611 |
96
|
String target = (String) t3.getAttributes().get("target"); |
2612 |
96
|
UserAction ua = new UserAction(value, target); |
2613 |
96
|
mmepOperations.add(ua); |
2614 |
96
|
++operationCount; |
2615 |
|
} |
2616 |
|
} |
2617 |
36
|
if ( operationCount < forbiddenCardinality ) { |
2618 |
0
|
throw new PolicyParsingException("Number of operations is less than ForbiddenCardinality " + forbiddenCardinality + ", this is not allowed"); |
2619 |
|
} |
2620 |
36
|
MMEPUnit mmepUnit = |
2621 |
|
new MMEPUnit(forbiddenCardinality, mmepOperations); |
2622 |
36
|
mmep.add(mmepUnit); |
2623 |
|
} |
2624 |
|
|
2625 |
|
} |
2626 |
28
|
issrg.pba.rbac.policies.MSoDRule msodr = |
2627 |
|
new issrg.pba.rbac.policies.MSoDRule(contextName, firstAction, firstTarget, |
2628 |
|
lastAction, lastTarget, mmer, mmep ); |
2629 |
28
|
msodRules.add(msodr); |
2630 |
|
} |
2631 |
|
} |
2632 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2633 |
8
|
public Vector getMSoDRules(){... |
2634 |
8
|
return msodRules; |
2635 |
|
} |
2636 |
|
|
2637 |
|
} |
2638 |
|
|
2639 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
2640 |
18
|
public Vector getMSoDSet(){... |
2641 |
18
|
if (msodPolicySetNode== null) |
2642 |
10
|
return null; |
2643 |
|
else |
2644 |
8
|
return msodPolicySetNode.getMSoDRules(); |
2645 |
|
} |
2646 |
|
|
2647 |
|
|
2648 |
|
@return |
2649 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2650 |
1
|
public issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode[] getEnvAttributes() {... |
2651 |
1
|
return this.targetAccessPolicy.getAllNeededAttributes(); |
2652 |
|
} |
2653 |
|
} |