Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
64   305   19   4.27
34   129   0.52   15
15     2.2  
1    
 
 
  Holder       Line # 85 64 19 45.1% 0.45132744
 
  (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 is the class for the Holder ASN.1 construct.
83    */
84   
 
85    public class Holder implements iaik.asn1.ASN1Type, java.lang.Cloneable {
86    public final static int BASECERTIFICATEID_TAG = 0;
87    public final static int ENTITYNAME_TAG = 1;
88    public final static int OBJECTDIGESTINFO_TAG = 2;
89   
90    protected IssuerSerial baseCertificateID = null; // optional
91   
92    /**
93    * Returns the Base Certificate ID construct of the Holder. Can be null,
94    * if it is not present.
95    */
 
96  3558 toggle public IssuerSerial getBaseCertificateID(){
97  3558 return baseCertificateID;
98    }
99   
100    /**
101    * Sets the Base Certificate ID construct of the Holder. Can be null,
102    * if it is not present.
103    */
 
104  0 toggle public void setBaseCertificateID(IssuerSerial baseCertificateID){
105  0 this.baseCertificateID=baseCertificateID;
106    }
107   
108    protected GeneralNames entityName = null; // optional
109   
110    /**
111    * Returns the Entity Name (GeneralNames) construct of the Holder. Can be
112    * null, if it is not present.
113    */
 
114  3647 toggle public GeneralNames getEntityName(){
115  3647 return entityName;
116    }
117   
118    /**
119    * Sets the Entity Name construct of the Holder. Can be null, if it is not
120    * present.
121    */
 
122  0 toggle public void setEntityName(GeneralNames entityName){
123  0 this.entityName=entityName;
124    }
125   
126    protected ObjectDigestInfo objectDigestInfo = null; // optional
127   
128    /**
129    * Returns the Object Digest Info construct of the Holder. 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 Holder. Can be null, if it is
138    * not present.
139    */
 
140  0 toggle public void setObjectDigestInfo(ObjectDigestInfo objectDigestInfo){
141  0 this.objectDigestInfo=objectDigestInfo;
142    }
143   
 
144  5998 toggle protected Holder() { }
145   
146    /**
147    * This constructo builds a Holder from ASN1Object.
148    *
149    * @param ao - the ASN1Object representing the Holder
150    */
 
151  2979 toggle public Holder(ASN1Object ao) throws CodingException{
152  2979 decode(ao);
153    }
154   
155    /**
156    * This constructor builds an object out of its components. You can pass some
157    * or all of the
158    * values. Missing values will be omitted in the encoding (all of them are
159    * optional), but at least
160    * one must be present; otherwise a CodingException will be thrown.
161    */
 
162  20 toggle public Holder(IssuerSerial baseCertificateID, GeneralNames entityName, ObjectDigestInfo objectDigestInfo){
163  20 this.baseCertificateID = baseCertificateID;
164  20 this.entityName = entityName;
165  20 this.objectDigestInfo = objectDigestInfo;
166    }
167   
168    /**
169    * This constructor creates a copy of a given Holder.
170    *
171    * @param h - the Holder to copy
172    */
 
173  0 toggle public Holder(Holder h) throws CodingException{
174  0 baseCertificateID = new IssuerSerial(h.baseCertificateID);
175  0 entityName = new GeneralNames(h.entityName.toASN1Object());
176  0 objectDigestInfo = new ObjectDigestInfo(h.objectDigestInfo);
177    }
178   
179    /**
180    * This method returns the ASN1Object of Holder.
181    *
182    * @return SEQUENCE of all present components
183    */
 
184  42 toggle public ASN1Object toASN1Object() throws CodingException{
185  42 ASN1Object result = new SEQUENCE();
186   
187  42 ASN1Object tag;
188   
189  42 if (baseCertificateID!=null){
190  0 tag = new CON_SPEC(BASECERTIFICATEID_TAG,
191    baseCertificateID.toASN1Object(),
192    AttributeCertificate.USE_IMPLICIT_ENCODING);
193   
194  0 result.addComponent(tag);
195    }
196   
197  42 if (entityName!=null){
198  42 tag = new CON_SPEC(ENTITYNAME_TAG,
199    entityName.toASN1Object(),
200    AttributeCertificate.USE_IMPLICIT_ENCODING);
201   
202  42 result.addComponent(tag);
203    }
204   
205  42 if (objectDigestInfo!=null){
206  0 tag = new CON_SPEC(OBJECTDIGESTINFO_TAG,
207    objectDigestInfo.toASN1Object(),
208    AttributeCertificate.USE_IMPLICIT_ENCODING);
209   
210  0 result.addComponent(tag);
211    }
212   
213  42 return result;
214    }
215   
216    /**
217    * This method decodes the given ASN1Object and sets the contents of the
218    * Holder to the contents of ASN1Object.
219    *
220    * @param ao - the ASN1Object to decode; it must be a SEQUENCE, where each
221    * element represents the elements of Holder
222    */
 
223  2979 toggle public void decode(ASN1Object ao) throws CodingException {
224  2979 int i=0;
225   
226  2979 baseCertificateID=null; // resetting optional values to Non-present state
227  2979 entityName=null;
228  2979 objectDigestInfo=null;
229   
230  2979 if (!ao.isA(ASN.SEQUENCE)){
231  0 throw new CodingException("Holder SEQUENCE tag was expected");
232    }
233   
234  2979 if (i>=ao.countComponents()){
235  0 return;
236    }
237   
238  2979 ASN1Object tag = ao.getComponentAt(i++);
239  2979 ASN type = tag.getAsnType();
240   
241  2979 if (type.getTag()==BASECERTIFICATEID_TAG && type.getTagClass()==ASN.CONTEXT_SPECIFIC){
242  0 if (AttributeCertificate.USE_IMPLICIT_ENCODING){
243  0 ((CON_SPEC)tag).forceImplicitlyTagged(ASN.SEQUENCE);
244    }
245   
246  0 baseCertificateID = new IssuerSerial(tag.getComponentAt(0));
247   
248  0 if (i>=ao.countComponents()){
249  0 return;
250    }
251  0 tag = ao.getComponentAt(i++);
252  0 type = tag.getAsnType();
253    }
254   
255  2979 if (type.getTag()==ENTITYNAME_TAG && type.getTagClass()==ASN.CONTEXT_SPECIFIC){
256  2979 if (AttributeCertificate.USE_IMPLICIT_ENCODING){
257  1120 ((CON_SPEC)tag).forceImplicitlyTagged(ASN.SEQUENCE);
258    }
259  2979 entityName = new GeneralNames(tag.getComponentAt(0));
260   
261  2979 if (i>=ao.countComponents()){
262  2979 return;
263    }
264  0 tag = ao.getComponentAt(i++);
265  0 type = tag.getAsnType();
266    }
267   
268  0 if (type.getTag()==OBJECTDIGESTINFO_TAG && type.getTagClass()==ASN.CONTEXT_SPECIFIC){
269  0 if (AttributeCertificate.USE_IMPLICIT_ENCODING){
270  0 ((CON_SPEC)tag).forceImplicitlyTagged(ASN.SEQUENCE);
271    }
272  0 objectDigestInfo = new ObjectDigestInfo(tag.getComponentAt(0));
273   
274  0 if (i>=ao.countComponents()){
275  0 return;
276    }
277    }
278   
279    //if (i<ao.countComponents()){ // there were "i" legal tags read
280  0 throw new CodingException ("Illegal number of components in Holder tag: "+Integer.toString(ao.countComponents()));
281    //}
282    }
283   
 
284  0 toggle public String toString(){
285  0 return toString("");
286    }
287   
 
288  4 toggle public String toString(String ident){
289  4 return "SEQUENCE { -- Holder --\n "+ident+
290  4 "baseCertificateID = "+((baseCertificateID!=null)?baseCertificateID.toString(ident+" "):"[OPTIONAL; omitted]")+",\n "+ident+
291  4 "entityname = "+((entityName!=null)?entityName.toString():"[OPTIONAL; omitted]")+",\n "+ident+
292  4 "objectDigestInfo = "+((objectDigestInfo!=null)?objectDigestInfo.toString(ident+" "):"[OPTIONAL; omitted]")+"\n"+ident+"}";
293    }
294   
 
295  0 toggle public Object clone(){
296  0 try{
297  0 return new Holder(this);
298    }catch (CodingException ex){
299  0 ex.printStackTrace();
300  0 return null;
301    }
302    }
303    }
304   
305