Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
64   203   17   7.11
28   109   0.39   9
9     2.78  
1    
 
 
  AuthorityInformationAccess       Line # 69 64 17 2% 0.01980198
 
No Tests
 
1    /*
2    * Copyright (c) 2006, University of Kent
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * Redistributions of source code must retain the above copyright notice, this
9    * list of conditions and the following disclaimer.
10    *
11    * Redistributions in binary form must reproduce the above copyright notice,
12    * this list of conditions and the following disclaimer in the documentation
13    * and/or other materials provided with the distribution.
14    *
15    * 1. Neither the name of the University of Kent nor the names of its
16    * contributors may be used to endorse or promote products derived from this
17    * software without specific prior written permission.
18    *
19    * 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22    * PURPOSE ARE DISCLAIMED.
23    *
24    * 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31    * POSSIBILITY OF SUCH DAMAGE.
32    *
33    * 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
34    * IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
35    * SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
36    * SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
37    * GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
38    * TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
39    * IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
40    * SERIOUS FAULTS, IN THIS SOFTWARE.
41    *
42    * 5. This license is governed, except to the extent that local laws
43    * necessarily apply, by the laws of England and Wales.
44    */
45   
46    /*
47    * AuthorityInformationAccess.java
48    *
49    * Created on 18. juni 2007, 09:57
50    *
51    * @author Rune Bjerk
52    */
53   
54    package issrg.ac.extensions;
55   
56    import iaik.asn1.*;
57    import iaik.asn1.structures.*;
58    import issrg.ac.Extension;
59    import issrg.ac.Holder;
60   
61    import issrg.log.ISSRGLevel;
62    import issrg.utils.EnvironmentalVariables;
63   
64    import java.math.BigInteger;
65    import java.util.*;
66   
67   
68   
 
69    public class AuthorityInformationAccess extends issrg.ac.Extension{ //Maybe this should extend Extensions instead of Extension
70   
71    ArrayList extensions;
72    private static String id_pe_authorityInfoAccess = "1.3.6.1.5.5.7"; //The 1.3.6.1.5.5.7.1.1 is the correct one
 
73  0 toggle public AuthorityInformationAccess(){
74   
75    }
 
76  0 toggle public AuthorityInformationAccess(ASN1Object ao)throws CodingException{
77  0 super(ao);
78   
79    }
80   
 
81  0 toggle public ArrayList getValues(){
82  0 return extensions;
83    }
84   
85   
 
86  0 toggle public AuthorityInformationAccess(Map env, String subjectDN, String holderDN, BigInteger serial){
87  0 extnID= id_pe_authorityInfoAccess;
88  0 extensions = new ArrayList();
89   
90    //Creating a new AAIA extension
91  0 String useAAIA = (String) env.get(EnvironmentalVariables.AAIA_LOCATION);
92  0 if ((useAAIA != null) && (!useAAIA.equals(""))) { //If AAIA LOCATION = 1 is not set in the ACM config file this code should be skipped
93  0 String location = (String) env.get(EnvironmentalVariables.HOLDER_EDITOR_UTILITY_SERVER);//The location in the config file given by LDAPSavingUtility.ProviderURI=(ldap adress)
94  0 String aaiaLocation = issrg.utils.CreateAAIALocation.createLocation(location, subjectDN); //Returns a properly formatet String of location with the DN
95   
96  0 if (aaiaLocation != null) {
97  0 AttributeAuthorityInformationAccess
98    ext = new AttributeAuthorityInformationAccess(new String[] {aaiaLocation}); //create a new AttributeAthorityInformationAccess object with one location
99  0 extensions.add(ext); //Add the extension to the array of extensions
100    }
101    }
102    //Finished creating the AAIA extension
103   
104    //Creating a WebdavCertification extension
105  0 String cert_loc = (String)env.get(EnvironmentalVariables.WEBDAV_CERTIFICATE_LOCATION);
106  0 WebdavCertificate cert = new WebdavCertificate(cert_loc,holderDN,serial);
107  0 extensions.add(cert);
108   
109    //Finished creating the AAIA extension
110   
111    //Creating a WebdavRevocation extension
112  0 String rev_location = (String)env.get(EnvironmentalVariables.WEBDAV_REVOCATION_LOCATION);
113  0 WebdavRevocation rev =new WebdavRevocation(rev_location,holderDN,serial);
114  0 extensions.add(rev);
115   
116    }
117   
118   
119   
 
120  0 toggle public ASN1Object encodeValue() throws CodingException{
121  0 SEQUENCE seq = new SEQUENCE();
122  0 SEQUENCE content =new SEQUENCE();
123  0 content.addComponent(new ObjectID(id_pe_authorityInfoAccess));//add the oid for the AIA itself
124   
125  0 for(int i=0 ; i<extensions.size();i++){
126  0 System.out.println("Encoding extension number:"+(i+1));
127  0 Extension ext = (Extension)extensions.get(i); //get the different extensions within AIA
128  0 content.addComponent(ext.toASN1Object()); //The actuall encoding of the extensions may vary between the sub-extensions
129    }
130  0 seq.addComponent(content);
131  0 return seq;
132    }
133   
134   
 
135  0 toggle public void decode(ASN1Object ao) throws CodingException {
136  0 super.decode(ao);
137  0 if (isCritical()) throw new CodingException("AuthorityInformationAccess extension MUST be non-critical");
138    }
139   
 
140  0 toggle public void decodeValue(ASN1Object ao) throws CodingException {
141   
142  0 ASN1Object accessDescription = ao.getComponentAt(0);
143  0 extensions = new ArrayList();
144  0 if ((accessDescription instanceof SEQUENCE)){ //SEQUENCE is expected
145  0 try{
146  0 ASN1Object oid = (ASN1Object) accessDescription.getComponentAt(0);
147  0 if ((oid instanceof ObjectID)){ //The first object of the SEQUENCE should be ObjectID
148  0 String id = (String) ((ObjectID) oid).getValue();
149  0 if (id.equals(id_pe_authorityInfoAccess)) { //We want only to decode AuthorisationInformationAccess extensions
150  0 int numberOfExtensions = accessDescription.countComponents();
151  0 int i=1;
152  0 while(i<numberOfExtensions){ //Loop through the extensions to decode themselves
153  0 ASN1Object ext = (ASN1Object) accessDescription.getComponentAt(i);
154  0 if ((ext instanceof SEQUENCE)) {
155  0 ASN1Object sequence = ext.getComponentAt(0);
156  0 String objectID= (String)sequence.getValue();
157   
158  0 if(objectID.equals(WebdavRevocation.WEBDAV_REVOCATION_METHOD_OID)){
159  0 WebdavRevocation webdavRev =new WebdavRevocation(ext);
160  0 extensions.add(webdavRev);
161  0 }if(objectID.equals(WebdavCertificate.WEBDAV_CERTIFICATE_METHOD_OID)){
162  0 WebdavCertificate webdavCert =new WebdavCertificate(ext);
163  0 extensions.add(webdavCert);
164  0 }if(objectID.equals(AttributeAuthorityInformationAccess.ATTRIBUTE_AUTHORITY_INFORMATION_ACCESS)){
165  0 AttributeAuthorityInformationAccess aaia =new AttributeAuthorityInformationAccess(ext);
166  0 extensions.add(aaia);
167    }
168   
169    }
170  0 i++;
171    }
172    }
173    }
174    }catch(Exception ce){
175  0 ce.printStackTrace();
176    // the extension is not critical - ignore the errors
177    }
178   
179   
180    }
181    }
182   
 
183  0 toggle public String extensionValueToString(String indent){
184   
185  0 String extension ="\n";
186  0 if(extensions!=null){
187  0 for(int i=0;i<extensions.size();i++){
188  0 String res =((Extension)extensions.get(i)).extensionValueToString(indent);
189  0 extension =extension.concat(res+indent);
190  0 extension =extension.concat("\n");
191    }
192   
193    }else{
194  0 System.out.println("Extension was null");
195    }
196  0 return extension;
197    }
198   
 
199  19 toggle public static void registerMe() {
200  19 issrg.ac.Extensions.registerExtension(id_pe_authorityInfoAccess, AuthorityInformationAccess.class);
201    }
202   
203    }