Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
34   95   16   6.8
22   77   0.59   5
5     4  
1    
 
 
  WebDAVRevocationChecker       Line # 19 34 16 0% 0.0
 
No Tests
 
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 Rune Bjerk 10.07.2007
18    */
 
19    public class WebDAVRevocationChecker implements RevocationChecker {
20    private boolean shouldRevoke=true;
21   
 
22  0 toggle public WebDAVRevocationChecker(boolean shouldRevoke){
23  0 this.shouldRevoke = shouldRevoke;
24    }
25   
 
26  0 toggle public boolean isRevoked(Object token) throws RevocationNotDecisiveException { //return true if the attribute certificate is revoked
27  0 if(shouldRevoke){
28  0 try{
29  0 WebDAVRevocable revo = (WebDAVRevocable)token;
30  0 if(revo.isRevocable()){
31  0 String revLoc=revo.getRevocationURL(); //Retrieve the two URLs
32  0 String valLoc=revo.getCertificateURL();
33   
34  0 if(revLoc!=null && valLoc!=null){
35  0 if(CustomisePERMIS.checkCertificateFirst()){ //The RP has defined this when building PERMIS, default is true
36  0 if(!checkACLocation(revo)){
37  0 return false;//The AC exist at the location, it has not been revoked.
38    }else{
39  0 return true; //No AC was found so its not valid, in other words revoked
40    }
41    }else{
42  0 if(!checkCRLLocation(revLoc)){ //Simplified version, only checks for the file exists. Change the checkCRLLocation for complex scenarios.
43  0 if(!checkACLocation(revo)){
44  0 return true; //The AC at the location was identical to the original AC, not revoked
45    }else{
46  0 return false; //The AC was not found at location, the AC never existed.
47    }
48    }else{
49  0 return true; //If the code found and CRL at the location, revoked
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; //If the RP defined the RevocationChecker not to do a check then "not revoked" is returned.
68   
69    }
70   
 
71  0 toggle 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    }
 
75  0 toggle private boolean checkCRLLocation(String token){
76  0 return issrg.utils.WebdavUtil.doesFileExist(token);
77   
78    }
79   
 
80  0 toggle 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    }