Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
42   256   9   2.8
16   92   0.55   15
15     1.53  
1    
 
 
  IssuerSerial       Line # 86 42 9 35.6% 0.3561644
 
  (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    import java.math.BigInteger;
81   
82    /**
83    * This class represents the IssuerSerial ASN.1 construct.
84    */
85   
 
86    public class IssuerSerial implements ASN1Type, Cloneable{
87   
88    protected GeneralNames issuer = new GeneralNames();
89   
90    /**
91    * Returns the Issuer (GeneralNames) construct of the IssuerSerial.
92    */
 
93  0 toggle public GeneralNames getIssuer(){
94  0 return issuer;
95    }
96   
97    /**
98    * Sets the Issuer (GeneralNames) construct of the IssuerSerial.
99    */
 
100  0 toggle public void setIssuer(GeneralNames issuer){
101  0 this.issuer=issuer;
102    }
103   
104    protected BigInteger serial = new BigInteger("0");
105   
106    /**
107    * Returns the Serial Number of the IssuerSerial.
108    */
 
109  0 toggle public BigInteger getSerial(){
110  0 return serial;
111    }
112   
113    /**
114    * Sets the Serial Number of the IssuerSerial.
115    */
 
116  0 toggle public void setSerial(BigInteger serial){
117  0 this.serial=serial;
118    }
119   
120    public BIT_STRING issuerUID = null; // optional
121   
122    /**
123    * Returns the IssuerUID bit string of the IssuerSerial. Can be null, if not
124    * present.
125    */
 
126  0 toggle public BIT_STRING getIssuerUID(){
127  0 return issuerUID;
128    }
129   
130    /**
131    * Sets the IssuerUID bit string of the IssuerSerial. Can be null, if not
132    * present.
133    */
 
134  0 toggle public void setIssuerUID(BIT_STRING issuerUID){
135  0 this.issuerUID=issuerUID;
136    }
137   
138   
 
139  0 toggle protected IssuerSerial() {}
140   
141    /**
142    * This constructor builds an IssuerSerial from a given ASN1Object.
143    *
144    * @param ao - the ASN1Object representing IssuerSerial
145    */
 
146  1076 toggle public IssuerSerial(ASN1Object ao) throws CodingException{
147  1076 decode(ao);
148    }
149   
150    /**
151    * This constructor copies a given IssuerSerial.
152    *
153    * @param is - the IssuerSerial to copy
154    */
 
155  0 toggle public IssuerSerial(IssuerSerial is) throws CodingException{
156  0 issuer = new GeneralNames(is.issuer.toASN1Object());
157  0 serial = new BigInteger(is.serial.toByteArray());
158   
159  0 if (is.issuerUID!=null){
160  0 issuerUID = new BIT_STRING(is.issuerUID.getBinaryString());
161    }
162    }
163   
164    /**
165    * This constructor builds an IssuerSerial object out of its components.
166    *
167    * @param issuer - the GeneralNames of the issuer
168    * @param serial - the BigInteger of the serial number of the PKC issued by
169    * the issuer
170    * @param issuerUID - the BIT_STRING of issuer unique identifier of the PKC
171    * issued by the issuer; can be null, if not present
172    */
 
173  2 toggle public IssuerSerial(GeneralNames issuer, BigInteger serial, BIT_STRING issuerUID){
174  2 this.issuer = issuer;
175  2 this.serial = serial;
176  2 this.issuerUID = issuerUID;
177    }
178   
179    /**
180    * This method returns the ASN1Object of IssuerSerial.
181    *
182    * @return SEQUENCE of the present components
183    */
 
184  80 toggle public ASN1Object toASN1Object() throws CodingException{
185  80 ASN1Object result = new SEQUENCE();
186   
187  80 result.addComponent(issuer.toASN1Object());
188  80 result.addComponent(new INTEGER(serial));
189   
190  80 if (issuerUID!=null){
191  0 result.addComponent(issuerUID);
192    }
193   
194  80 return result;
195    }
196   
197    /**
198    * This method decodes a given ASN1Object and sets IssuerSerial to its
199    * contents. It must be a SEQUENCE of elements present in IssuerSerial
200    *
201    * @param ao - the ASN1Object to be decoded
202    */
 
203  1076 toggle public void decode(ASN1Object ao) throws CodingException{
204  1076 if (!ao.isA(ASN.SEQUENCE)){
205  0 throw new CodingException("IssuerSerial SEQUENCE tag was expected");
206    }
207   
208  1076 if (ao.countComponents()<2){
209  0 throw new CodingException("Mandatory entries are omitted in IssuerSerial tag");
210    }
211   
212  1076 issuer = new GeneralNames(ao.getComponentAt(0));
213  1076 serial = (BigInteger) ((INTEGER)ao.getComponentAt(1)).getValue();
214  1076 issuerUID = null;
215   
216  1076 int i=2;
217   
218  1076 if (ao.countComponents()>2){
219  0 ASN1Object o = ao.getComponentAt(2);
220   
221  0 if (!(o instanceof BIT_STRING)){
222  0 throw new CodingException("BIT_STRING was expected in IssuerSerial tag");
223    }
224  0 issuerUID = (BIT_STRING)o;
225   
226  0 i++;
227    }
228   
229  1076 if (ao.countComponents()>i){
230  0 throw new CodingException("Too many entries in IssuerSerial tag: "+Integer.toString(ao.countComponents()));
231    }
232    }
233   
 
234  0 toggle public String toString(){
235  0 return toString("");
236    }
237   
 
238  0 toggle public String toString (String indent){
239  0 return "SEQUENCE { -- IssuerSerial --\n "+indent+
240    "issuer = "+issuer.toString()+",\n "+indent+
241    "serial = "+serial.toString()+",\n "+indent+
242  0 "issuerUID = "+((issuerUID!=null)?issuerUID.getBinaryString():"[OPTIONAL; omitted]")+"\n"+indent+"}";
243    }
244   
245   
 
246  0 toggle public Object clone(){
247  0 try{
248  0 return new IssuerSerial(this);
249    }catch (CodingException ex){
250  0 ex.printStackTrace();
251  0 return null;
252    }
253    }
254   
255    }
256