Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
12   197   2   1.2
0   40   0.92   10
10     1.1  
1    
 
 
  AttributeValue       Line # 102 12 2 50% 0.5
 
  (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 a default AttributeValue object used in the Attribute construct. You
83    * can derive from this
84    * class and register your own AttributeValue decoders using
85    * Attribute.registerAttribute method, so they will be used
86    * automatically when
87    * an AC is decoded.
88    *
89    * <p>When you create a subclass, don't forget to override isDecoded method, or
90    * derive your class
91    * from the DistinctAttribute class (which simply overrides that method to
92    * return true). Alternatively,
93    * your code can go through the vector of attribute values and replace the
94    * default AttributeValue objects
95    * with descendants of this class that are aware of their semantics (and can
96    * represent the ASN1Object
97    * of the value in a programmer-friendly way).
98    *
99    * @see Attribute#registerAttribute
100    */
101   
 
102    public class AttributeValue implements ASN1Type, Cloneable{
103   
104    /**
105    * This is the data as an ASN1Object that represents the value of the
106    * attribute.
107    */
108    protected ASN1Object data = null;
109   
110    /**
111    * Returns the raw ASN1Object of the attribute, if it has been taken from
112    * the BER-encoded AC. You
113    * don't need to set it, so there is no method for that.
114    *
115    * <p>This value may not be meaningful in some subclasses of AttributeValue.
116    */
 
117  1902 toggle public ASN1Object getRawAttribute(){
118  1902 return data;
119    }
120   
121    /**
122    * This method tells whether the value has been truly decoded, or it is some
123    * kind of placeholder and the actual value must be decoded by other means.
124    *
125    * <p>This method should be overridden by the user-defined classes to return
126    * true, so when the
127    * content of the set of attribute values is examined, the code would know if
128    * the class is aware
129    * of its semantics.
130    *
131    * @return true, if the value has been decoded and semantically evaluated by
132    * the subclass; false otherwise; by default returns false, so override
133    * this method
134    */
 
135  0 toggle public boolean isDecoded(){ // this method should be implemented to return true for all other descendants
136    // it just reflects the fact, that this is not yet an AttributeValue, but an ANY, waiting to be distinguished
137  0 return false;
138    }
139   
 
140  3067 toggle protected AttributeValue() {
141    }
142   
143    /**
144    * This constructor builds an AttributeValue from ASN1Object of the single
145    * value.
146    *
147    * @param data - the ASN1Object of this value
148    */
 
149  840 toggle public AttributeValue(ASN1Object data) throws CodingException{
150  840 decode(data);
151    }
152   
153    /**
154    * This method copies the given AttributeValue.
155    *
156    * @param av - the AttributeValue to copy
157    */
 
158  0 toggle public AttributeValue(AttributeValue av) throws CodingException{
159  0 data = iaik.asn1.DerCoder.decode(iaik.asn1.DerCoder.encode(av.data)); // create a copy of av.data
160    }
161   
162    /**
163    * This method returns the ASN1Object of this value.
164    */
 
165  2 toggle public ASN1Object toASN1Object() throws CodingException{
166  2 return data;
167    }
168   
169    /**
170    * This method decodes the single value of an Attribute. By default simply
171    * keeps the raw encoding, so you need to override this method in subclasses.
172    *
173    * @param ao - the ASN1Object of the single Attribute value
174    */
 
175  3869 toggle public void decode(ASN1Object ao) throws CodingException{
176  3869 data = ao;
177    }
178   
 
179  0 toggle public String toString(){
180  0 return toString("");
181    }
182   
 
183  4 toggle public String toString(String ident){
184  4 return data.toString();
185    }
186   
187   
 
188  0 toggle public Object clone(){
189  0 try{
190  0 return new AttributeValue(this);
191    }catch (CodingException ex){
192  0 ex.printStackTrace();
193  0 return null;
194    }
195    }
196    }
197