Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
17   191   4   1.55
8   49   0.82   11
11     1.27  
1    
 
 
  AttCertVersion       Line # 87 17 4 58.3% 0.5833333
 
  (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 AttCertVersion ASN.1 construct. It has two
84    * predefined integers in it: V1
85    * and V2, but you can always specify your own.
86    */
 
87    public class AttCertVersion implements ASN1Type, Cloneable{
88    public final static BigInteger V1 = new BigInteger("0");
89    public final static BigInteger V2 = new BigInteger("1");
90   
91    public final static BigInteger DEFAULT = V1;
92   
93    protected java.math.BigInteger version = DEFAULT;
94   
95    /**
96    * Returns the version of the AC. By default is set to V1.
97    */
 
98  0 toggle public java.math.BigInteger getVersion(){
99  0 return version;
100    }
101   
102    /**
103    * Sets the version of the AC. Note that the semantics of this setting is
104    * enforced
105    * by the programmer; the version is not checked anywhere in this library.
106    */
 
107  0 toggle public void setVersion(java.math.BigInteger version){
108  0 this.version=version;
109    }
110   
111    /**
112    * This constructor creates an object with the version set to default (V1).
113    */
 
114  5998 toggle public AttCertVersion() { }
115   
116    /**
117    * This constructor creates the AttCertVersion from a given ASN1Object.
118    *
119    * @param ao - the ASN1Object containing an INTEGER with the version; if null,
120    * the default version is assumed (V1)
121    */
 
122  2979 toggle public AttCertVersion(ASN1Object ao) throws CodingException{
123  2979 decode(ao);
124    }
125   
126    /**
127    * This constructor copies AttCertVersion.
128    *
129    * @param acv - the AttCertVersion to copy
130    */
 
131  0 toggle public AttCertVersion(AttCertVersion acv){
132  0 if (acv.version==DEFAULT){
133  0 version = DEFAULT;
134    }else{
135  0 version = new java.math.BigInteger(acv.version.toByteArray());
136    }
137    }
138   
139    /**
140    * This constructor builds a AttCertVersion from a given BigInteger.
141    *
142    * @param version - the BigInteger of the version
143    */
 
144  20 toggle public AttCertVersion(BigInteger version){
145  20 this.version=version;
146    }
147   
148   
149    /**
150    * This method returns the ASN1Object of the version.
151    *
152    * @return INTEGER with the version
153    */
 
154  42 toggle public ASN1Object toASN1Object() throws CodingException{
155    //if (version==DEFAULT){ // who did this?!
156    // return null;
157    //}
158  42 return new iaik.asn1.INTEGER(version);
159    }
160   
161   
162    /**
163    * This method decodes and sets the version from a given ASN1Object.
164    *
165    * @param ao - the ASN1Object with the version; it must be an INTEGER; if
166    * null, the default version is assumed
167    */
 
168  2979 toggle public void decode(ASN1Object ao) throws CodingException{
169  2979 version=DEFAULT;
170  2979 if (ao==null) return;
171   
172  2240 if (!ao.isA(ASN.INTEGER)){
173  0 throw new CodingException("AttCertVersion INTEGER was expected");
174    }
175   
176  2240 version = (BigInteger)((INTEGER)ao).getValue();
177    // casting to INTEGER just to cause ClassCastException in the case it is not INTEGER
178    }
179   
 
180  4 toggle public String toString(){
181  4 return version.toString()+((version==DEFAULT)? " -- DEFAULT --" : "");
182    }
183   
 
184  4 toggle public String toString(String ident){
185  4 return toString();
186    }
187   
 
188  0 toggle public Object clone(){
189  0 return new AttCertVersion(this);
190    }
191    }