Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
13   192   2   1.08
2   45   1   12
12     1.08  
1    
 
 
  PMIXMLPolicy       Line # 88 13 2 29.6% 0.2962963
 
No Tests
 
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    /*
47    * Copyright (c) 2000-2005, University of Salford
48    * All rights reserved.
49    *
50    * Redistribution and use in source and binary forms, with or without
51    * modification, are permitted provided that the following conditions are met:
52    *
53    * Redistributions of source code must retain the above copyright notice, this
54    * list of conditions and the following disclaimer.
55    *
56    * Redistributions in binary form must reproduce the above copyright notice,
57    * this list of conditions and the following disclaimer in the documentation
58    * and/or other materials provided with the distribution.
59    *
60    * Neither the name of the University of Salford nor the names of its
61    * contributors may be used to endorse or promote products derived from this
62    * software without specific prior written permission.
63    *
64    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
65    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
68    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
69    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
70    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
71    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
72    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
73    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
74    * POSSIBILITY OF SUCH DAMAGE.
75    */
76   
77    package issrg.ac.attributes;
78   
79    import iaik.asn1.*;
80    import iaik.asn1.structures.*;
81    import issrg.ac.DistinctAttribute;
82   
83   
84    /**
85    * This is the class for the PMI XML Policy attribute.
86    */
87   
 
88    public class PMIXMLPolicy extends DistinctAttribute {
89    /**
90    * This is the OID of the Attribute
91    */
92    public final static String PMI_XML_POLICY_ATTRIBUTE_OID = "1.2.826.0.1.3344810.1.1.13";
93   
94    /**
95    * This method registers this class with the Attribute class, so it will
96    * automatically pick up the
97    * class for parsing PMI XML Policies.
98    */
 
99  0 toggle public static void registerMe(){
100  0 issrg.ac.Attribute.registerAttribute(PMI_XML_POLICY_ATTRIBUTE_OID, PMIXMLPolicy.class);
101    }
102   
103   
104    protected String policy = "";
105   
106    /**
107    * Returns the XML of the Policy as a String.
108    */
 
109  14 toggle public String getPolicy(){
110  14 return policy;
111    }
112   
113    /**
114    * Sets the XML of the Policy as a String.
115    */
 
116  0 toggle public void setPolicy(String policy){
117  0 this.policy=policy;
118    }
119   
 
120  0 toggle protected PMIXMLPolicy() {}
121   
122    /**
123    * This constructor builds a PMIXMLPolicy given ASN1Object of its value.
124    *
125    * @param ao - ASN1Object of the value of the PMIXMLPolicy attribute
126    */
 
127  0 toggle public PMIXMLPolicy(ASN1Object ao)throws CodingException{
128  0 decode(ao);
129    }
130   
131   
132    /**
133    * This constructor builds a PMIXMLPolicy given a parsed AttributeValue.
134    *
135    * @param av - AttributeValue of the PMIXMLPolicy attribute
136    */
 
137  14 toggle public PMIXMLPolicy(issrg.ac.AttributeValue av) throws CodingException{
138  14 decode(av.getRawAttribute());
139    }
140   
141    /**
142    * This constructor creates a copy of a given PMIXMLPolicy.
143    *
144    * @param p - the PMIXMLPolicy to copy
145    */
 
146  0 toggle public PMIXMLPolicy(PMIXMLPolicy p){
147  0 policy = p.policy;
148    }
149   
150    /**
151    * This constructor creates a PMIXMLPolicy given a Policy XML as a String.
152    *
153    * @param p - the XML of the Policy
154    */
 
155  0 toggle public PMIXMLPolicy(String p){
156  0 policy = p;
157    }
158   
159   
160    /**
161    * This method returns the ASN1Object of the PMIXMLPolicy attribute value.
162    *
163    * @return PrintableString containing the Policy XML as its value.
164    */
 
165  0 toggle public ASN1Object toASN1Object(){
166  0 return new PrintableString(policy);
167    }
168   
169    /**
170    * This method decodes a given ASN1Object and sets the policy XML as the
171    * value of this ASN1Object.
172    *
173    * @param ao - the ASN1Object; must be a PrintableString whose value is the
174    * policy XML
175    */
 
176  14 toggle public void decode(ASN1Object ao) throws CodingException{
177  14 if (!ao.isA(ASN.PrintableString)){
178  0 throw new CodingException("PMIXMLPolicy PrintableString was expected");
179    }
180   
181  14 policy = (String)ao.getValue();
182    }
183   
 
184  0 toggle public String toString(int indent){
185  0 return "pMIXMLPolicy = "+policy;
186    }
187   
 
188  0 toggle public Object clone(){
189  0 return new PMIXMLPolicy(this);
190    }
191    }
192