Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
14   155   3   2.33
4   34   0.57   6
6     1.33  
1    
 
 
  SimpleObligation       Line # 63 14 3 8.3% 0.083333336
 
No Tests
 
1   
2    /*
3    * Copyright (c) 2006, University of Kent
4    * All rights reserved.
5    *
6    * Redistribution and use in source and binary forms, with or without
7    * modification, are permitted provided that the following conditions are met:
8    *
9    * Redistributions of source code must retain the above copyright notice, this
10    * list of conditions and the following disclaimer.
11    *
12    * Redistributions in binary form must reproduce the above copyright notice,
13    * this list of conditions and the following disclaimer in the documentation
14    * and/or other materials provided with the distribution.
15    *
16    * 1. Neither the name of the University of Kent nor the names of its
17    * contributors may be used to endorse or promote products derived from this
18    * software without specific prior written permission.
19    *
20    * 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23    * PURPOSE ARE DISCLAIMED.
24    *
25    * 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32    * POSSIBILITY OF SUCH DAMAGE.
33    *
34    * 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
35    * IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
36    * SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
37    * SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
38    * GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
39    * TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
40    * IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
41    * SERIOUS FAULTS, IN THIS SOFTWARE.
42    *
43    * 5. This license is governed, except to the extent that local laws
44    * necessarily apply, by the laws of England and Wales.
45    *
46    * Author : Gansen Zhao
47    * Email: gz7@kent.ac.uk
48    */
49   
50   
51    package issrg.pba;
52   
53    import issrg.pba.rbac.xmlpolicy.PolicyXMLNode;
54    import issrg.pba.rbac.xmlpolicy.XMLTags;
55    import java.util.Iterator;
56    import java.util.Map;
57   
58    /**
59    * This class implements the Obligation Interface, and provides a way to construct Obligation Object based on
60    * a PolicyXMLNode. For details of the PolicyXMLNode, please refer to the PolicyXMLNode.java and its documents.
61    * @author gansen
62    */
 
63    public class SimpleObligation implements issrg.pba.Obligation{
64   
65    /**
66    * This is the PolicyXMLNode that is to be used to construct the SimpleObligation object.
67    */
68    PolicyXMLNode m_oblgXMLNode;
69   
70    /**
71    *
72    * Create a new instance of SimpleObligation that contains no obligations.
73    */
 
74  0 toggle public SimpleObligation() {
75  0 m_oblgXMLNode=null;
76    }
77   
78   
79    /**
80    * Construct a SimpleObligation object based on
81    * XMLPolicyNode (the ObligationNode parameter).
82    * @param ObligationNode The XMLNode that is used to construct the SimpleObligation object.
83    * This function only remembers the ObligationNode, and does not produce a copy of the node. Thus
84    * all future changes to the ObligatonNode will be reflected in the corresponding SimpleObligation
85    * instances.
86    */
 
87  4 toggle public SimpleObligation(PolicyXMLNode ObligationNode){
88   
89  4 m_oblgXMLNode=ObligationNode;
90   
91    // java.util.Map ObligationAttributes;
92    // ObligationAttributes=new java.util.Hashtable();
93    //
94    // if(ObligationNode!=null){
95    // java.util.Map attributes =ObligationNode.getAttributes();
96    // Iterator entryIter = attributes.entrySet().iterator();
97    // Map.Entry entry=null;
98    // while (entryIter.hasNext()) {
99    // entry = (Map.Entry) entryIter.next();
100    // ObligationAttributes.put(entry.getKey(),entry.getValue());
101    // }
102    // }
103    }
104    /**
105    * getObligationID is a function inherited from the Obligation Interface.
106    *
107    *
108    */
 
109  0 toggle public String getObligationID(){
110   
111  0 if(this.m_oblgXMLNode==null)
112  0 return new String();
113   
114  0 java.util.Map attributes=m_oblgXMLNode.getAttributes();
115   
116  0 String id=(String)attributes.get(XMLTags.OBLIGATION_ID_ATTRIBUTE);
117   
118  0 return id;
119    }
120   
121    /**
122    * Convert the instance to a string representation.
123    */
 
124  0 toggle public String toString(){
125  0 return toXML();
126    }
127   
128    /**
129    * Convert the object to XML representation.
130    */
 
131  0 toggle public String toXML(){
132   
133  0 return m_oblgXMLNode.toXML();
134   
135    }
136   
137    /**
138    * Retrieve the Chronicle attribute's value
139    * @return The value of the Chronicle attribute. The return value may be null if the
140    * Chronicle value is not set in the xml policy.
141    */
 
142  0 toggle public String getChronicle(){
143   
144  0 if(this.m_oblgXMLNode==null)
145  0 return new String();
146   
147  0 java.util.Map attributes=m_oblgXMLNode.getAttributes();
148   
149  0 String chronical=(String)attributes.get(XMLTags.OBLIGATION_CHRONICLE_ATTRIBUTE);
150   
151  0 return chronical;
152    }
153   
154   
155    }