1 |
|
package issrg.pba.rbac; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
import java.util.Vector; |
5 |
|
|
6 |
|
import iaik.asn1.CodingException; |
7 |
|
import issrg.ac.AttributeCertificate; |
8 |
|
import issrg.ac.Extension; |
9 |
|
import issrg.ac.extensions.*; |
10 |
|
import issrg.pba.rbac.WebDAVRevocable; |
11 |
|
import issrg.utils.ACNotFoundException; |
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
@author |
18 |
|
|
|
|
| 0% |
Uncovered Elements: 61 (61) |
Complexity: 16 |
Complexity Density: 0.59 |
|
19 |
|
public class WebDAVRevocationChecker implements RevocationChecker { |
20 |
|
private boolean shouldRevoke=true; |
21 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
22 |
0
|
public WebDAVRevocationChecker(boolean shouldRevoke){... |
23 |
0
|
this.shouldRevoke = shouldRevoke; |
24 |
|
} |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 13 |
Complexity Density: 0.57 |
|
26 |
0
|
public boolean isRevoked(Object token) throws RevocationNotDecisiveException { ... |
27 |
0
|
if(shouldRevoke){ |
28 |
0
|
try{ |
29 |
0
|
WebDAVRevocable revo = (WebDAVRevocable)token; |
30 |
0
|
if(revo.isRevocable()){ |
31 |
0
|
String revLoc=revo.getRevocationURL(); |
32 |
0
|
String valLoc=revo.getCertificateURL(); |
33 |
|
|
34 |
0
|
if(revLoc!=null && valLoc!=null){ |
35 |
0
|
if(CustomisePERMIS.checkCertificateFirst()){ |
36 |
0
|
if(!checkACLocation(revo)){ |
37 |
0
|
return false; |
38 |
|
}else{ |
39 |
0
|
return true; |
40 |
|
} |
41 |
|
}else{ |
42 |
0
|
if(!checkCRLLocation(revLoc)){ |
43 |
0
|
if(!checkACLocation(revo)){ |
44 |
0
|
return true; |
45 |
|
}else{ |
46 |
0
|
return false; |
47 |
|
} |
48 |
|
}else{ |
49 |
0
|
return true; |
50 |
|
} |
51 |
|
} |
52 |
|
} |
53 |
|
}else{ |
54 |
0
|
return false; |
55 |
|
} |
56 |
|
}catch(ClassCastException cce){ |
57 |
0
|
throw new RevocationNotDecisiveException("Token not WebDAVRevocable"); |
58 |
|
}catch(ACNotFoundException ace){ |
59 |
0
|
if(!ace.getResponseCode().equals("404") && (new Integer(ace.getResponseCode())).intValue()>400){ |
60 |
0
|
throw new RevocationNotDecisiveException("Token not revocable"); |
61 |
|
}else{ |
62 |
0
|
System.out.println("Revocation error code:"+ace.getResponseCode()); |
63 |
0
|
return false; |
64 |
|
} |
65 |
|
} |
66 |
|
} |
67 |
0
|
return false; |
68 |
|
|
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
0
|
private boolean checkACLocation(WebDAVRevocable token) throws ACNotFoundException{... |
72 |
0
|
byte[] webdavAC = issrg.utils.WebdavUtil.getRawAC(token.getCertificateURL()); |
73 |
0
|
return compareACs(token.getOriginalAC(),webdavAC); |
74 |
|
} |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0
|
private boolean checkCRLLocation(String token){... |
76 |
0
|
return issrg.utils.WebdavUtil.doesFileExist(token); |
77 |
|
|
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
80 |
0
|
private boolean compareACs(byte[] acB,byte[] newAC){... |
81 |
|
|
82 |
0
|
if(acB.length!=newAC.length){ |
83 |
0
|
return false; |
84 |
|
} |
85 |
0
|
for(int i=0;i<acB.length;i++){ |
86 |
0
|
if(acB[i]!=newAC[i]){ |
87 |
0
|
return false; |
88 |
|
}else{ |
89 |
0
|
break; |
90 |
|
} |
91 |
|
} |
92 |
0
|
return true; |
93 |
|
} |
94 |
|
|
95 |
|
} |