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 |
|
|
35 |
|
|
36 |
|
import java.security.Principal; |
37 |
|
|
38 |
|
import issrg.pba.MultiAuthzTokenParser; |
39 |
|
import issrg.pba.PolicyParser; |
40 |
|
import issrg.pba.ParsedToken; |
41 |
|
import issrg.pba.RiskAssessment; |
42 |
|
import issrg.pba.Subject; |
43 |
|
import issrg.pba.Target; |
44 |
|
import issrg.pba.Action; |
45 |
|
import issrg.pba.Credentials; |
46 |
|
import issrg.pba.PbaException; |
47 |
|
import issrg.pba.DecisionWithObligationException; |
48 |
|
import issrg.pba.CredentialsService; |
49 |
|
import issrg.pba.Response; |
50 |
|
import issrg.pba.rbac.CustomisePERMIS; |
51 |
|
import issrg.pba.rbac.PolicyFinder; |
52 |
|
import issrg.pba.rbac.policies.AssignmentRule; |
53 |
|
import issrg.utils.ACNotFoundException; |
54 |
|
import issrg.utils.repository.Entry; |
55 |
|
import issrg.pba.rbac.xmlpolicy.XMLPolicyParser; |
56 |
|
import issrg.pba.AuthzTokenParser; |
57 |
|
import issrg.utils.repository.VirtualRepository; |
58 |
|
import issrg.pba.repository.AuthzTokenRepository; |
59 |
|
|
60 |
|
import issrg.pba.repository.UserEntry; |
61 |
|
import issrg.utils.repository.AttributeRepository; |
62 |
|
import issrg.utils.repository.MultiRepository; |
63 |
|
import java.io.BufferedReader; |
64 |
|
import java.io.ByteArrayInputStream; |
65 |
|
import java.io.DataInputStream; |
66 |
|
import java.io.InputStream; |
67 |
|
import java.io.FileNotFoundException; |
68 |
|
import java.io.FileReader; |
69 |
|
import java.io.IOException; |
70 |
|
import java.lang.reflect.InvocationTargetException; |
71 |
|
import java.lang.reflect.Method; |
72 |
|
import java.util.Date; |
73 |
|
import java.util.Map; |
74 |
|
import javax.naming.directory.Attribute; |
75 |
|
import java.util.Vector; |
76 |
|
|
77 |
|
import issrg.SAWS.*; |
78 |
|
import org.apache.log4j.*; |
79 |
|
|
80 |
|
|
81 |
|
import issrg.pba.rbac.SAWSLogLevelConstant; |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
@link |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@author |
146 |
|
@author |
147 |
|
@author |
148 |
|
@version |
149 |
|
|
150 |
|
|
|
|
| 62.4% |
Uncovered Elements: 109 (290) |
Complexity: 68 |
Complexity Density: 0.53 |
|
151 |
|
public class PermisRBAC implements issrg.pba.PBAAPI{ |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
public final String TIME_VARIABLE="time"; |
167 |
|
|
168 |
|
private Clock clock; |
169 |
|
private AuthzTokenRepository Repository; |
170 |
|
private AuthzTokenParser authParser; |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
protected int TIMEOUT = 0; |
175 |
|
|
176 |
|
private PolicyFinder policyFinder; |
177 |
|
|
178 |
|
|
179 |
|
private int sawsLogLevel=0; |
180 |
|
private SAWSServer sawsServer=null; |
181 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
182 |
0
|
protected PermisRBAC(){}... |
183 |
|
Logger logger = Logger.getLogger("issrg.pba.PermisRBAC"); |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
@param |
189 |
|
@param |
190 |
|
@param |
191 |
|
@param |
192 |
|
|
193 |
|
@return |
194 |
|
@throws |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
|
|
| 43.5% |
Uncovered Elements: 13 (23) |
Complexity: 7 |
Complexity Density: 0.54 |
|
199 |
928
|
public boolean decision(Subject S, Action A, Target T,... |
200 |
|
java.util.Map Application_Context) throws PbaException{ |
201 |
0
|
if (logger.isDebugEnabled())logger.debug("Decision Called"); |
202 |
0
|
if (logger.isDebugEnabled())logger.debug("Creating a response"); |
203 |
928
|
Response r = authzDecision(S, A, T, Application_Context); |
204 |
0
|
if (logger.isDebugEnabled())logger.debug("Response Created"); |
205 |
|
|
206 |
794
|
if (r.getObligations()!=null) { |
207 |
0
|
DecisionWithObligationException ex=new DecisionWithObligationException("Cannot make a decision: some obligations must be enforced", r); |
208 |
0
|
if((sawsLogLevel>SAWSLogLevelConstant.POLICY_CHANGE)&& (sawsServer!=null)) |
209 |
0
|
sawsServer.sendLogRecord(new ExceptionSAWSRecord((PbaException)ex).toBytes()); |
210 |
0
|
throw ex; |
211 |
|
} |
212 |
|
|
213 |
794
|
return r.isAuthorised(); |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
@param |
222 |
|
@param |
223 |
|
@param |
224 |
|
@param |
225 |
|
|
226 |
|
|
|
|
| 67.3% |
Uncovered Elements: 16 (49) |
Complexity: 16 |
Complexity Density: 0.52 |
|
227 |
1558
|
public Response authzDecision(Subject S, Action A, Target T,... |
228 |
|
java.util.Map Application_Context) throws PbaException{ |
229 |
1558
|
long start = System.nanoTime(); |
230 |
1558
|
if (S==null || A==null || T==null){ |
231 |
199
|
PbaException exp=new PbaException("Subject, Action and Target should not be null"); |
232 |
199
|
if((sawsLogLevel>SAWSLogLevelConstant.POLICY_CHANGE)&& (sawsServer!=null)) |
233 |
0
|
sawsServer.sendLogRecord(new ExceptionSAWSRecord((PbaException)exp).toBytes()); |
234 |
199
|
throw exp; |
235 |
|
} |
236 |
|
|
237 |
1359
|
if (S.getOwner()!=this){ |
238 |
0
|
PbaException exx=new PbaException("Cannot use the subject: created by a different object"); |
239 |
0
|
if((sawsLogLevel>SAWSLogLevelConstant.POLICY_CHANGE)&& (sawsServer!=null)) |
240 |
0
|
sawsServer.sendLogRecord(new ExceptionSAWSRecord((PbaException)exx).toBytes()); |
241 |
0
|
throw exx; |
242 |
|
} |
243 |
|
|
244 |
1359
|
issrg.pba.CredentialsService cs = S.getService(); |
245 |
1359
|
if (cs!=null){ |
246 |
0
|
cs.service(S,T,A); |
247 |
|
} |
248 |
1359
|
if(cs instanceof RiskAssessment){ |
249 |
0
|
if(!((RiskAssessment)cs).assessRisk(S, T, A)){ |
250 |
0
|
throw new PbaException("There was a problem with the risk assesment"); |
251 |
|
} |
252 |
|
} |
253 |
|
|
254 |
1359
|
Application_Context=initEnv(Application_Context); |
255 |
|
|
256 |
|
|
257 |
1359
|
Application_Context.put("Subject", S); |
258 |
|
|
259 |
1359
|
((Clock)Application_Context.get(TIME_VARIABLE)).latch(); |
260 |
1359
|
clock.latch(); |
261 |
|
|
262 |
1359
|
Response response=policyFinder.getAccessPolicy().response((issrg.pba.Credentials)S.exportCreds(), A, T, Application_Context); |
263 |
|
|
264 |
|
|
265 |
1058
|
if((!response.isAuthorised())&& (sawsLogLevel >SAWSLogLevelConstant.POLICY_CHANGE)){ |
266 |
|
|
267 |
|
|
268 |
17
|
AccessDenyRecord rec2=new AccessDenyRecord(S,A,T,Application_Context); |
269 |
17
|
sawsServer.sendLogRecord(rec2.toBytes()); |
270 |
|
|
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
1058
|
if((response.isAuthorised())&& (sawsLogLevel >SAWSLogLevelConstant.DENY_EXCEPT)) { |
275 |
|
|
276 |
|
|
277 |
18
|
AccessGrantRecord rec=new AccessGrantRecord(S,A,T,Application_Context); |
278 |
18
|
sawsServer.sendLogRecord(rec.toBytes()); |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
} |
283 |
1058
|
long end = System.nanoTime(); |
284 |
1058
|
end = end - start; |
285 |
1058
|
return response; |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
@param |
294 |
|
|
295 |
|
@return |
296 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
297 |
150
|
public Subject getCreds(Principal subjectDN) throws PbaException{... |
298 |
150
|
return getCreds(subjectDN, (CredentialsService)null); |
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
@param |
312 |
|
|
313 |
|
@return |
314 |
|
|
315 |
|
@see |
316 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
317 |
870
|
public Subject getCreds(Principal subjectDN,... |
318 |
|
CredentialsService service |
319 |
|
) throws PbaException{ |
320 |
870
|
return getCreds(subjectDN, null, service); |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
@param |
332 |
|
@param |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
@return |
338 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
339 |
643
|
public Subject getCreds(Principal subjectDN,... |
340 |
|
Object [] creds |
341 |
|
) throws PbaException{ |
342 |
643
|
return getCreds(subjectDN, creds, null); |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
@param |
355 |
|
@param |
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
@param |
360 |
|
|
361 |
|
@return |
362 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
363 |
1548
|
public Subject getCreds(Principal subjectDN,... |
364 |
|
Object [] creds, |
365 |
|
CredentialsService service) throws PbaException{ |
366 |
1548
|
return getCreds(new UserEntry(subjectDN), creds, policyFinder.getRepository(), service); |
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
@param |
381 |
|
@param |
382 |
|
|
383 |
|
|
384 |
|
@param |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
@return |
389 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
390 |
0
|
public Subject getCreds(Principal subject, String [] urls, issrg.pba.AuthzTokenParser authParser) throws PbaException {... |
391 |
0
|
issrg.pba.repository.AuthzTokenRepository repository; |
392 |
0
|
repository = new issrg.simplePERMIS.SimplePERMISAuthzTokenRepository(this.getRepositories(urls),authParser); |
393 |
|
|
394 |
0
|
return getCreds(new UserEntry(subject), |
395 |
|
null, |
396 |
|
repository, |
397 |
|
null |
398 |
|
); |
399 |
|
} |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
@param |
407 |
|
|
408 |
|
|
409 |
|
@param |
410 |
|
|
411 |
|
|
412 |
|
@param |
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
@param |
418 |
|
|
419 |
|
|
420 |
|
|
|
|
| 54.8% |
Uncovered Elements: 28 (62) |
Complexity: 18 |
Complexity Density: 0.5 |
|
421 |
1548
|
protected Subject getCreds(UserEntry subjectDN, ... |
422 |
|
Object [] creds, |
423 |
|
issrg.pba.repository.AuthzTokenRepository repository, |
424 |
|
CredentialsService service) throws PbaException{ |
425 |
1548
|
if (logger.isDebugEnabled()){ |
426 |
0
|
logger.debug("getCreds received: "); |
427 |
0
|
logger.debug("SubjectDN: " +subjectDN.getEntryName().getName()); |
428 |
|
} |
429 |
1548
|
if (logger.isDebugEnabled()){ |
430 |
0
|
if (creds == null){ |
431 |
0
|
if (logger.isDebugEnabled())logger.debug("Creds is empty" ); |
432 |
|
}else{ |
433 |
0
|
if (logger.isDebugEnabled())logger.debug("Creds: " + creds); |
434 |
|
} |
435 |
|
} |
436 |
1548
|
try{ |
437 |
1548
|
String AttributeName=""; |
438 |
1548
|
if (repository==null) repository = this.Repository; |
439 |
|
|
440 |
1548
|
if (creds!=null){ |
441 |
678
|
issrg.utils.repository.VirtualRepository vRepository = new issrg.utils.repository.VirtualRepository(); |
442 |
678
|
repository = new issrg.simplePERMIS.SimplePERMISAuthzTokenRepository(vRepository, authParser); |
443 |
|
|
444 |
1359
|
for (int i=0; i<creds.length; i++){ |
445 |
681
|
issrg.pba.ParsedToken token = null; |
446 |
|
|
447 |
681
|
try{ |
448 |
681
|
token = authParser.decode(creds[i]); |
449 |
681
|
if (logger.isDebugEnabled()){ |
450 |
0
|
logger.debug("[" +token.getHolder().getEntryName().getName()+ token.toString() +"] " + token.getCredentials().toString()); |
451 |
|
} |
452 |
|
|
453 |
|
}catch(PbaException e){ |
454 |
0
|
if((sawsLogLevel>SAWSLogLevelConstant.POLICY_CHANGE)&& (sawsServer!=null)) |
455 |
0
|
sawsServer.sendLogRecord(new ExceptionSAWSRecord((PbaException)e).toBytes()); |
456 |
0
|
token=null; |
457 |
|
} |
458 |
|
|
459 |
681
|
if(token!=null) |
460 |
681
|
vRepository.populate(subjectDN.getEntryName().getName(), CustomisePERMIS.getAttributeCertificateAttribute(), token); |
461 |
|
} |
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
|
469 |
1548
|
if (logger.isDebugEnabled()){ |
470 |
0
|
logger.debug("creating new PermisSubject "); |
471 |
|
} |
472 |
|
|
473 |
1548
|
String oid =policyFinder.getPolicyOID(); |
474 |
1548
|
Credentials creds2=policyFinder.getAllocationPolicy().getCredentials(subjectDN, repository); |
475 |
1349
|
return new issrg.pba.rbac.PermisSubject(this, |
476 |
|
subjectDN.getEntryName(), |
477 |
|
service, |
478 |
|
oid,creds2 |
479 |
|
); |
480 |
|
}catch (Throwable th){ |
481 |
|
|
482 |
199
|
PbaException excp=new PbaException("Failed to get credentials: "+th.getMessage(), th); |
483 |
|
|
484 |
199
|
if((sawsLogLevel>SAWSLogLevelConstant.POLICY_CHANGE)&& (sawsServer!=null)) |
485 |
0
|
sawsServer.sendLogRecord(new ExceptionSAWSRecord(excp).toBytes()); |
486 |
199
|
throw excp; |
487 |
|
} |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
@return |
493 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
494 |
1
|
public issrg.pba.rbac.xmlpolicy.ifstatement.EnvironmentNode[] getEnvAttributes() {... |
495 |
1
|
if (logger.isDebugEnabled()){ |
496 |
0
|
logger.debug("get the array of environment nodes"); |
497 |
|
} |
498 |
1
|
XMLPolicyParser xpp = (XMLPolicyParser)this.getPolicyFinder().getParsedPolicy(); |
499 |
1
|
return xpp.getEnvAttributes(); |
500 |
|
} |
501 |
|
|
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
506 |
1359
|
protected java.util.Map initEnv(java.util.Map env){... |
507 |
1359
|
if (env==null){ |
508 |
454
|
env=new java.util.Hashtable(); |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
1359
|
if (env.get(TIME_VARIABLE)==null){ |
513 |
500
|
env.put(TIME_VARIABLE, this.clock); |
514 |
|
} |
515 |
|
|
516 |
1359
|
return env; |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
|
|
| 33.3% |
Uncovered Elements: 4 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
524 |
17
|
protected void finalize(){... |
525 |
|
|
526 |
|
|
527 |
17
|
if((sawsLogLevel>SAWSLogLevelConstant.NO_INFO)&& (sawsServer!=null)){ |
528 |
|
|
529 |
0
|
ShutDownRecord rec=new ShutDownRecord(); |
530 |
0
|
sawsServer.sendLogRecord(rec.toBytes()); |
531 |
0
|
this.SAWSCloseLog(); |
532 |
|
} |
533 |
|
|
534 |
|
} |
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
@param |
550 |
|
|
551 |
|
|
552 |
|
@see |
553 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
554 |
7
|
public PermisRBAC(PolicyFinder pf) throws PbaException {... |
555 |
7
|
this(pf, (String[])null, null); |
556 |
|
} |
557 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
558 |
4
|
public void SAWSCloseLog(){... |
559 |
|
|
560 |
4
|
if(sawsServer!=null) |
561 |
|
{ |
562 |
4
|
System.out.println("Closing autdit trail logging"); |
563 |
4
|
sawsServer.closeLog(); |
564 |
4
|
sawsServer=null; |
565 |
|
} |
566 |
|
} |
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
@param |
582 |
|
@param |
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
@param |
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
@see |
592 |
|
@see |
593 |
|
@see |
594 |
|
@see |
595 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
596 |
0
|
public PermisRBAC(PolicyFinder pf, String url, issrg.pba.AuthzTokenParser authParser) throws PbaException {... |
597 |
0
|
this(pf, url==null?(String[])null:new String[]{url}, authParser); |
598 |
|
} |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
@param |
610 |
|
@param |
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
@param |
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
@see |
620 |
|
@see |
621 |
|
@see |
622 |
|
@see |
623 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
624 |
7
|
public PermisRBAC(PolicyFinder pf, String[] urls, issrg.pba.AuthzTokenParser authParser) throws PbaException {... |
625 |
7
|
this(pf, getRepositories(urls), authParser); |
626 |
|
} |
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
|
632 |
|
|
633 |
|
@param |
634 |
|
|
635 |
|
@param |
636 |
|
|
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
@param |
641 |
|
|
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
@see |
646 |
|
@see |
647 |
|
@see |
648 |
|
@see |
649 |
|
|
|
|
| 74.2% |
Uncovered Elements: 17 (66) |
Complexity: 17 |
Complexity Density: 0.45 |
|
650 |
25
|
public PermisRBAC(PolicyFinder pf, AttributeRepository ar, issrg.pba.AuthzTokenParser authParser) throws PbaException {... |
651 |
|
|
652 |
|
|
653 |
|
|
654 |
25
|
if (logger.isDebugEnabled()){ |
655 |
0
|
logger.debug("logging enabled"); |
656 |
|
} |
657 |
0
|
if (pf==null) throw new PbaException("Initialisation failed: no PolicyFinder was specified"); |
658 |
|
|
659 |
|
|
660 |
25
|
policyFinder=pf; |
661 |
|
|
662 |
|
|
663 |
25
|
this.sawsLogLevel=policyFinder.getSATLevel(); |
664 |
25
|
sawsServer=policyFinder.getSAWSServer(); |
665 |
|
|
666 |
|
|
667 |
25
|
if((sawsLogLevel>SAWSLogLevelConstant.NO_INFO)&& (sawsServer!=null)){ |
668 |
4
|
StartupRecord rec=new StartupRecord(policyFinder.getSOA(),policyFinder.getPolicyOID(),policyFinder.getfilepath()); |
669 |
4
|
sawsServer.sendLogRecord(rec.toBytes()); |
670 |
|
|
671 |
|
} |
672 |
|
|
673 |
|
|
674 |
25
|
if (logger.isDebugEnabled()){ |
675 |
0
|
logger.debug("PolicyFinder loaded"); |
676 |
|
} |
677 |
25
|
clock = CustomisePERMIS.getSystemClock(); |
678 |
25
|
if (logger.isDebugEnabled()){ |
679 |
0
|
logger.debug("clock set"); |
680 |
|
} |
681 |
25
|
if (authParser==null){ |
682 |
22
|
if (logger.isDebugEnabled()){ |
683 |
0
|
logger.debug("Setting up Token Parser"); |
684 |
|
} |
685 |
22
|
authParser = CustomisePERMIS.getAuthTokenParser(); |
686 |
22
|
authParser.setAuthTokenParsingRules(pf.getParsedPolicy().getAuthTokenParsingRules()); |
687 |
22
|
authParser.setSignatureVerifier(pf.getSV()); |
688 |
22
|
if (logger.isDebugEnabled()){ |
689 |
0
|
logger.debug(authParser.getClass().getName()+" is the authz token parser"); |
690 |
0
|
logger.debug("Token Parser Configured"); |
691 |
|
} |
692 |
|
} |
693 |
|
|
694 |
|
|
695 |
25
|
if (MultiAuthzTokenParser.class.isAssignableFrom(authParser.getClass())) CustomisePERMIS.setMultiParser(true); |
696 |
|
|
697 |
25
|
AttributeRepository ar1=getRepositories(pf.getParsedPolicy().getRepositoryURLs()); |
698 |
25
|
if (ar!=null || ar1!=null) ar=new MultiRepository(new AttributeRepository[]{ar, ar1}); |
699 |
25
|
if (logger.isDebugEnabled()){ |
700 |
0
|
logger.debug("Configuring repository"); |
701 |
|
} |
702 |
25
|
this.Repository = ar==null?null:new issrg.simplePERMIS.SimplePERMISAuthzTokenRepository(ar, authParser); |
703 |
25
|
if (logger.isDebugEnabled()){ |
704 |
0
|
logger.debug("Repository configured"); |
705 |
|
} |
706 |
25
|
this.authParser = authParser; |
707 |
|
|
708 |
|
|
709 |
25
|
if((sawsLogLevel>SAWSLogLevelConstant.NO_INFO)&& (sawsServer!=null)){ |
710 |
|
|
711 |
4
|
StartedRecord rec2=new StartedRecord(); |
712 |
4
|
sawsServer.sendLogRecord(rec2.toBytes()); |
713 |
|
|
714 |
|
} |
715 |
|
} |
716 |
|
|
717 |
|
|
718 |
|
|
719 |
|
|
720 |
|
|
721 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
722 |
0
|
public int getTimeOut(){... |
723 |
0
|
return TIMEOUT; |
724 |
|
} |
725 |
|
|
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
@param |
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
@return |
738 |
|
|
739 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
740 |
32
|
public static issrg.utils.repository.MultiRepository getRepositories(String [] urls) {... |
741 |
32
|
if (urls==null) return null; |
742 |
2
|
issrg.utils.repository.AttributeRepository [] reps = new issrg.utils.repository.AttributeRepository [urls.length]; |
743 |
|
|
744 |
|
|
745 |
6
|
for (int i=0; i<reps.length; i++){ |
746 |
4
|
reps[i]=null; |
747 |
4
|
try{ |
748 |
4
|
reps[i]= URLHandler.getRepositoryByURL(urls[i]); |
749 |
|
}catch(BadURLException bue){ |
750 |
|
|
751 |
|
} |
752 |
|
} |
753 |
|
|
754 |
|
|
755 |
2
|
return new issrg.utils.repository.MultiRepository(reps); |
756 |
|
} |
757 |
|
|
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
@param |
769 |
|
@param |
770 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
771 |
0
|
protected static issrg.utils.repository.MultiRepository getRepositories(String [] urls, String [] urls2) {... |
772 |
0
|
String [] u = null; |
773 |
0
|
if (urls!=null || urls2!=null){ |
774 |
0
|
u = new String[urls.length+urls2.length]; |
775 |
0
|
if (urls==null) urls=new String[0]; |
776 |
0
|
if (urls2==null) urls2=new String[0]; |
777 |
0
|
System.arraycopy(urls, 0, u, 0, urls.length); |
778 |
0
|
System.arraycopy(urls2, 0, u, urls.length, urls2.length); |
779 |
|
} |
780 |
|
|
781 |
|
|
782 |
0
|
return getRepositories(u); |
783 |
|
} |
784 |
|
|
785 |
|
|
786 |
|
|
787 |
|
|
788 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
789 |
1
|
public PolicyFinder getPolicyFinder(){... |
790 |
1
|
return policyFinder; |
791 |
|
} |
792 |
|
|
793 |
|
|
794 |
|
} |