Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
45   174   13   4.09
18   91   0.51   11
11     2.09  
1    
 
 
  WebdavRevocation       Line # 68 45 13 2.7% 0.027027028
 
No Tests
 
1   
2   
3   
4    /*
5    * Copyright (c) 2006, University of Kent
6    * All rights reserved.
7    *
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions are met:
10    *
11    * Redistributions of source code must retain the above copyright notice, this
12    * list of conditions and the following disclaimer.
13    *
14    * Redistributions in binary form must reproduce the above copyright notice,
15    * this list of conditions and the following disclaimer in the documentation
16    * and/or other materials provided with the distribution.
17    *
18    * 1. Neither the name of the University of Kent nor the names of its
19    * contributors may be used to endorse or promote products derived from this
20    * software without specific prior written permission.
21    *
22    * 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25    * PURPOSE ARE DISCLAIMED.
26    *
27    * 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34    * POSSIBILITY OF SUCH DAMAGE.
35    *
36    * 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
37    * IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
38    * SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
39    * SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
40    * GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
41    * TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
42    * IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
43    * SERIOUS FAULTS, IN THIS SOFTWARE.
44    *
45    * 5. This license is governed, except to the extent that local laws
46    * necessarily apply, by the laws of England and Wales.
47    */
48   
49   
50    /*
51    * WebdavRevocation.java
52    *
53    * Created on 18. juni 2007, 11:52
54    *
55    *@author Rune Bjerk
56    */
57   
58    package issrg.ac.extensions;
59   
60    import iaik.asn1.*;
61    import iaik.asn1.structures.*;
62    import issrg.pba.PbaException;
63    import issrg.utils.WebDAV_DIT;
64   
65    import java.math.BigInteger;
66    import java.util.*;
67   
 
68    public class WebdavRevocation extends issrg.ac.Extension {
69   
70    public static final String WEBDAV_REVOCATION_METHOD_OID = "1.2.826.0.1.3344810.10.3";
71   
72    private String rev_loc;
73    /** Creates a new instance of WebdavRevocation */
 
74  0 toggle public WebdavRevocation(ASN1Object ao)throws CodingException{
75  0 super(ao);
76    }
77   
 
78  0 toggle public WebdavRevocation(String location,String subjectDN, BigInteger serial) {
79  0 super(WEBDAV_REVOCATION_METHOD_OID,false);
80  0 rev_loc= getProperLocation(location,subjectDN, serial);
81    }
82   
 
83  0 toggle public String getExtensionOID() {
84  0 return WEBDAV_REVOCATION_METHOD_OID;
85    }
86   
 
87  0 toggle public String getLocation(){
88  0 return rev_loc;
89    }
90   
 
91  0 toggle public void setLocation(String location){
92  0 rev_loc=location;
93    }
94   
 
95  0 toggle public ASN1Object encodeValue() throws CodingException{
96    //String [] urls=getLocations();
97  0 SEQUENCE extnV = new SEQUENCE();
98   
99  0 if (rev_loc!=null){
100  0 GeneralName name = new GeneralName(GeneralName.uniformResourceIdentifier, rev_loc);
101   
102  0 SEQUENCE revocation = new SEQUENCE();
103  0 revocation.addComponent(new ObjectID(WEBDAV_REVOCATION_METHOD_OID), 0);
104  0 revocation.addComponent(name.toASN1Object(), 1);
105  0 extnV.addComponent(revocation);
106    }
107   
108   
109  0 return extnV;
110    }
111   
 
112  0 toggle public void decode(ASN1Object ao)throws CodingException{
113  0 super.decode(ao);
114    }
115   
 
116  0 toggle public void decodeValue(ASN1Object ao )throws CodingException{
117    // we may want to check that ao is a SEQUENCE first
118  0 int j = ao.countComponents();
119  0 for (int i=0; i<j; i++) {
120  0 ASN1Object accessDescription = ao.getComponentAt(i);
121  0 try{
122  0 if ((accessDescription instanceof SEQUENCE)) { //SEQUENCE is expected
123  0 ASN1Object oid = (ASN1Object) accessDescription.getComponentAt(0);
124  0 if ((oid instanceof ObjectID)) { //The first object of the SEQUENCE should be ObjectID
125   
126  0 String id = (String) ((ObjectID) oid).getValue();
127  0 if (id.equals(WEBDAV_REVOCATION_METHOD_OID)) { //only webdav objectIdentifier is supported by now
128  0 ASN1Object generalName = (ASN1Object) accessDescription.getComponentAt(1);
129  0 if ((generalName instanceof CON_SPEC)) {
130  0 GeneralName gn = new GeneralName(generalName);
131  0 if (gn.getType()!=GeneralName.uniformResourceIdentifier){
132  0 continue; // skip the General Names that are not URLs
133    }
134  0 setLocation((String)gn.getName()); //If everything is ok then set the location
135    }
136   
137   
138    }
139    }
140    }
141    }catch(CodingException ce){
142  0 if(isCritical()!=false){
143  0 throw new CodingException("Not possible to decode the ASN1Object values");
144    }
145    }
146    }
147   
148    }
149   
 
150  19 toggle public static void registerMe() {
151  19 issrg.ac.Extensions.registerExtension(WEBDAV_REVOCATION_METHOD_OID, WebdavRevocation.class);
152    }
 
153  0 toggle public String extensionValueToString(String indent){
154  0 String result="";
155  0 result =result.concat(indent+"Extension ID: "+extnID+"\n"+indent); //On the same line
156  0 result =result.concat(indent+"Location: "+getLocation()+"\n"+indent);
157  0 return result;
158    }
159   
 
160  0 toggle private String getProperLocation(String loc, String holderDN, BigInteger serial){
161  0 String holderURL;
162  0 try{
163  0 holderURL= issrg.utils.WebdavUtil.convertDN2URI(holderDN);
164    }catch(PbaException pba){
165  0 return "";
166    }
167  0 if(loc.endsWith("/") && holderURL.startsWith("/")){ //That would mean: issrg-beta.cs.kent.ac.uk//c=gb/o=Permis
168  0 holderURL = holderURL.substring(1);
169    }
170  0 String location = loc+holderURL+"/cn=CRLs/"+"serialNumber="+serial+"WebDAV_DIT.crl";
171  0 return location;
172    }
173   
174    }