Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
64   297   20   4.27
38   117   0.53   15
15     2.27  
1    
 
 
  V2Form       Line # 85 64 20 53% 0.52991456
 
  (1)
 
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    * Copyright (c) 2000-2005, University of Salford
47    * All rights reserved.
48    *
49    * Redistribution and use in source and binary forms, with or without
50    * modification, are permitted provided that the following conditions are met:
51    *
52    * Redistributions of source code must retain the above copyright notice, this
53    * list of conditions and the following disclaimer.
54    *
55    * Redistributions in binary form must reproduce the above copyright notice,
56    * this list of conditions and the following disclaimer in the documentation
57    * and/or other materials provided with the distribution.
58    *
59    * Neither the name of the University of Salford nor the names of its
60    * contributors may be used to endorse or promote products derived from this
61    * software without specific prior written permission.
62    *
63    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
64    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
67    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
68    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
69    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
70    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
71    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
72    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
73    * POSSIBILITY OF SUCH DAMAGE.
74    */
75   
76    package issrg.ac;
77   
78    import iaik.asn1.*;
79    import iaik.asn1.structures.*;
80   
81    /**
82    * This class represents the V2Form ASN.1 construct.
83    */
84   
 
85    public class V2Form implements ASN1Type, Cloneable{
86    final public static int BASECERTIFICATEID_TAG = 0;
87    final public static int OBJECTDIGESTINFO_TAG = 1;
88   
89   
90    protected GeneralNames issuerName = null; // optional
91   
92    /**
93    * Returns the Issuer Name (GeneralNames) construct of the V2Form. Can be
94    * null, if it is not present.
95    */
 
96  1068 toggle public GeneralNames getIssuerName(){
97  1068 return issuerName;
98    }
99   
100    /**
101    * Sets the Issuer Name construct of the V2Form. Can be null, if it is not
102    * present.
103    */
 
104  0 toggle public void setIssuerName(GeneralNames issuerName){
105  0 this.issuerName=issuerName;
106    }
107   
108    protected IssuerSerial baseCertificateID = null; // optional
109   
110    /**
111    * Returns the Base Certificate ID construct of the V2Form. Can be null, if it
112    * is not present.
113    */
 
114  0 toggle public IssuerSerial getBaseCertificateID(){
115  0 return baseCertificateID;
116    }
117   
118    /**
119    * Sets the Base Certificate ID construct of the V2Form. Can be null, if it is
120    * not present.
121    */
 
122  0 toggle public void setBaseCertificateID(IssuerSerial baseCertificateID){
123  0 this.baseCertificateID=baseCertificateID;
124    }
125   
126    protected ObjectDigestInfo objectDigestInfo = null; // optional
127   
128    /**
129    * Returns the Object Digest Info construct of the V2Form. Can be null, if it
130    * is not present.
131    */
 
132  0 toggle public ObjectDigestInfo getObjectDigestInfo(){
133  0 return objectDigestInfo;
134    }
135   
136    /**
137    * Sets the Object Digest Info construct of the V2Form. Can be null, if it is
138    * not present.
139    */
 
140  20 toggle public void setObjectDigestInfo(ObjectDigestInfo objectDigestInfo){
141  20 this.objectDigestInfo=objectDigestInfo;
142    }
143   
 
144  0 toggle protected V2Form() {
145    }
146   
147    /**
148    * This constructor copies a given V2Form.
149    *
150    * @param v2 - the V2Form to copy.
151    */
 
152  0 toggle public V2Form(V2Form v2) throws CodingException{
153  0 issuerName = null;
154  0 baseCertificateID = null;
155  0 objectDigestInfo = null;
156   
157  0 if (v2.issuerName!=null){
158  0 issuerName = new GeneralNames(v2.issuerName.toASN1Object());
159    }
160   
161  0 if (v2.baseCertificateID!=null){
162  0 baseCertificateID = new IssuerSerial(v2.baseCertificateID);
163    }
164   
165  0 if (v2.objectDigestInfo!=null){
166  0 objectDigestInfo = new ObjectDigestInfo(v2.objectDigestInfo);
167    }
168    }
169   
170    /**
171    * This constructor builds a V2Form from its ASN1Object representation.
172    *
173    * @param ao - the ASN1Object with the contents of V2Form
174    */
 
175  1702 toggle public V2Form(ASN1Object ao) throws CodingException{
176  1702 decode(ao);
177    }
178   
179    /**
180    * This constructor can be used to construct a V2Form object out of its
181    * components. Note that
182    * all of the components are optional and any of them can be null, but there
183    * should be at least one
184    * non-null parameter.
185    *
186    * @param issuerName is a GeneralNames object; can be null if not present
187    * @param baseCertificateID is the IssuerSerial object; can be null if not
188    * present
189    * @param objectDigestInfo is the ObjectDigestInfo object; can be null if not
190    * present
191    */
 
192  20 toggle public V2Form(GeneralNames issuerName, IssuerSerial baseCertificateID, ObjectDigestInfo objectDigestInfo){
193  20 this.issuerName = issuerName;
194  20 this.baseCertificateID = baseCertificateID;
195  20 this.objectDigestInfo = objectDigestInfo;
196    }
197   
198    /**
199    * This method returns the ASN1Object of V2Form.
200    *
201    * @return SEQUENCE of all the present components
202    */
 
203  42 toggle public ASN1Object toASN1Object() throws CodingException{
204  42 ASN1Object result = new SEQUENCE();
205   
206  42 ASN1Object tag;
207   
208  42 if (issuerName!=null){
209  42 result.addComponent(issuerName.toASN1Object());
210    }
211   
212  42 if (baseCertificateID!=null){
213  40 tag = new CON_SPEC(BASECERTIFICATEID_TAG, baseCertificateID.toASN1Object(), AttributeCertificate.USE_IMPLICIT_ENCODING);
214   
215  40 result.addComponent(tag);
216    }
217   
218  42 if (objectDigestInfo!=null){
219  0 tag = new CON_SPEC(OBJECTDIGESTINFO_TAG, objectDigestInfo.toASN1Object(), AttributeCertificate.USE_IMPLICIT_ENCODING);
220   
221  0 result.addComponent(tag);
222    }
223   
224  42 return result;
225    }
226   
227    /**
228    * This method decodes the given ASN1Object and sets the V2Form contents from
229    * it. It must be a SEQUENCE of V2Form elements, all of which are optional,
230    * but at least one must be present.
231    *
232    * @param ao - the ASN1Object to decode
233    */
 
234  1702 toggle public void decode(ASN1Object ao) throws CodingException{
235  1702 if (!ao.isA(ASN.SEQUENCE)){
236  0 throw new CodingException("V2Form SEQUENCE tag was expected");
237    }
238   
239  1702 int i=0;
240  0 if (i>=ao.countComponents()) return;
241   
242  1702 ASN1Object tag=ao.getComponentAt(i++);
243  1702 ASN type = tag.getAsnType();
244   
245  1702 if (type.getTagClass()!=ASN.CONTEXT_SPECIFIC){// issuerName goes
246  1120 issuerName = new GeneralNames(tag);
247   
248  1120 if (i>=ao.countComponents()) return;
249  538 tag = ao.getComponentAt(i++);
250  538 type = tag.getAsnType();
251    }
252   
253   
254  1120 if (type.getTagClass()==ASN.CONTEXT_SPECIFIC && type.getTag()==BASECERTIFICATEID_TAG){
255  538 if (AttributeCertificate.USE_IMPLICIT_ENCODING){
256  538 ((CON_SPEC)tag).forceImplicitlyTagged(ASN.SEQUENCE);
257    }
258  538 baseCertificateID = new IssuerSerial(tag.getComponentAt(0));
259   
260  538 if (i>=ao.countComponents()) return;
261  0 tag = ao.getComponentAt(i++);
262  0 type = tag.getAsnType();
263    }
264   
265  582 if (type.getTagClass()==ASN.CONTEXT_SPECIFIC && type.getTag()==OBJECTDIGESTINFO_TAG){
266  0 if (AttributeCertificate.USE_IMPLICIT_ENCODING){
267  0 ((CON_SPEC)tag).forceImplicitlyTagged(ASN.SEQUENCE);
268    }
269  0 objectDigestInfo = new ObjectDigestInfo(tag.getComponentAt(0));
270   
271  0 if (i>=ao.countComponents()) return;
272    }
273   
274  582 throw new CodingException("Unexpected entry in V2Form: "+Integer.toString(ao.countComponents())+" entries found");
275    }
276   
 
277  4 toggle public String toString(){
278  4 return toString("");
279    }
280   
 
281  4 toggle public String toString(String indent){
282  4 return "SEQUENCE { -- V2Form --\n "+indent+
283  4 "issuerName = "+((issuerName!=null)?issuerName.toString():"[OPTIONAL; omitted]")+",\n "+indent+
284  4 "baseCertificateID = "+((baseCertificateID!=null)?baseCertificateID.toString():"[OPTIONAL; omitted]")+",\n "+indent+
285  4 "objectDigestInfo = "+((objectDigestInfo!=null)?objectDigestInfo.toString():"[OPTIONAL; omitted]")+",\n"+indent+"}";
286    }
287   
 
288  0 toggle public Object clone(){
289  0 try{
290  0 return new V2Form(this);
291    }catch (CodingException ex){
292  0 ex.printStackTrace();
293  0 return null;
294    }
295    }
296   
297    }