Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
57   238   10   6.33
18   112   0.32   1.8
9     2  
5    
 
 
  Record       Line # 68 4 1 100% 1.0
  StartupRecord       Line # 86 12 4 80% 0.8
  ShutDownRecord       Line # 118 3 1 0% 0.0
  AccessGrantRecord       Line # 133 19 4 100% 1.0
  AccessDenyRecord       Line # 187 19 4 100% 1.0
 
No Tests
 
1    /*
2    * Copyright (c) 2006-7, 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    * Record.java
45    *
46    * Created on 08 February 2007, 16:56
47    *
48    * To change this template, choose Tools | Template Manager
49    * and open the template in the editor.
50    */
51   
52    package issrg.pba.rbac;
53   
54    import issrg.pba.PbaException;
55    import issrg.pba.rbac.SAWSLogLevelConstant;
56    import iaik.asn1.*;
57    import iaik.asn1.structures.AlgorithmID;
58    import iaik.utils.Util;
59    import java.util.Iterator;
60    import java.util.Set;
61   
62    /**
63    * This is an abstract class for Permis-specific SAWS records
64    * @author bn29
65    */
66   
67    //permis-specific log record for SAWS
 
68    public abstract class Record {
69   
70   
71    String type;
72    public abstract byte[] toBytes();
73    /**returns the record as an array of bytes, to be implemented by each recod type class
74    */
 
75  47 toggle protected byte[] toBytes(String result){
76  47 SEQUENCE ASN1Seq = new SEQUENCE();
77  47 ASN1Seq.addComponent(new IA5String(result));
78  47 byte[] arrayASN = DerCoder.encode(ASN1Seq);
79  47 return arrayASN;
80    }
81   
82    }
83   
84    /**startup log record for saws
85    **/
 
86    class StartupRecord extends Record {
87    String soa;
88    String policyOID;
89    String filePath;
90   
 
91  4 toggle public StartupRecord(String soa, String policyOID, String filePath) {
92  4 type=SAWSLogLevelConstant.PermisStartingType;
93  4 this.soa=soa;
94  4 this.policyOID=policyOID;
95  4 this.filePath=filePath;
96    }
97   
98    /**returns the record as an array of bytes
99    */
 
100  4 toggle public byte[] toBytes() {
101  4 String result="Type: "+type+ "\n";
102  4 if(soa!=null)
103  4 result=result + "SOA: "+soa + "\n";
104  4 if(policyOID!=null)
105  4 result=result+"policyOID: "+policyOID;
106  4 if(filePath!=null)
107  0 result=result+ "filePath: "+filePath;
108    //System.out.println(result);
109  4 return toBytes(result);
110    }
111    }
112   
113   
114   
115   
116    /**shutdown log record for saws
117    */
 
118    class ShutDownRecord extends Record {
 
119  0 toggle public ShutDownRecord(){
120  0 type=SAWSLogLevelConstant.PermisShutDownType;
121    }
122   
123    /**returns the record as an array of bytes
124    */
 
125  0 toggle public byte[] toBytes(){
126  0 String result="Type: "+type;
127  0 return toBytes(result);
128    }
129    }
130   
131    /**access grant log record for saws
132    */
 
133    class AccessGrantRecord extends Record {
134    issrg.pba.Subject S;
135    issrg.pba.Action A;
136    issrg.pba.Target T;
137    java.util.Map Application_Context;
138    String creds;
139   
 
140  18 toggle public AccessGrantRecord(issrg.pba.Subject S, issrg.pba.Action A, issrg.pba.Target T,java.util.Map Application_Context){
141  18 type=SAWSLogLevelConstant.PermisAccessGrantType;
142  18 this.S=S;
143  18 this.A=A;
144  18 this.T=T;
145  18 this.Application_Context=Application_Context;
146  18 this.creds= ((issrg.pba.Credentials)S.exportCreds()).toString();
147    }
148   
149    /**returns the record as an array of bytes
150    */
 
151  18 toggle public byte[] toBytes(){
152   
153    //have to concatenate the subject action target and environment parameters and return as a string to make getbytes
154  18 String result="Type: "+type+ "\n";
155  18 result=result+ S.getHolder().getName()+"\n"+A.getActionName()+"\n"+((PermisTarget) T).getName()+"\n" + creds+ "\n";
156    //java.util.Map tt=new java.util.Map();
157   
158  18 Set keys = Application_Context.keySet(); // The set of keys in the map.
159  18 Iterator keyIter = keys.iterator();
160   
161  72 while (keyIter.hasNext()) {
162  54 Object key = keyIter.next(); // Get the next key.
163  54 Object value = Application_Context.get(key); // Get the value for that key.
164   
165  54 if(key=="Subject")
166  18 result=result+"Environment parameters: Subject= "+((issrg.pba.Subject)value).getHolder().getName()+"\n";
167    //subj=(issrg.pba.Subject)Application_Context.get("Subject");
168  36 else if(key=="ContextInstance")
169  18 result=result+"Environment parameters: ContextInstance= "+value+ " ";
170    else
171  18 result=result+"Environment parameters:" + key+ ": " +value+ " ";
172   
173    //if(key=="time")
174    // result=result+"Environment parameters: Time= "+ ((SystemClock)value).getTime();
175   
176    }
177   
178   
179   
180  18 return toBytes(result);
181    }
182    }
183   
184   
185    /**access deny log record for saws
186    */
 
187    class AccessDenyRecord extends Record {
188    issrg.pba.Subject S;
189    issrg.pba.Action A;
190    issrg.pba.Target T;
191    java.util.Map Application_Context;
192    String creds;
193   
 
194  17 toggle public AccessDenyRecord(issrg.pba.Subject S, issrg.pba.Action A, issrg.pba.Target T,java.util.Map Application_Context){
195  17 this.S=S;
196  17 this.A=A;
197  17 this.T=T;
198  17 this.Application_Context=Application_Context;
199  17 type=SAWSLogLevelConstant.PermisAccessDenyType;
200  17 this.creds= ((issrg.pba.Credentials)S.exportCreds()).toString();
201    }
202   
203    /**returns the record as an array of bytes
204    */
 
205  17 toggle public byte[] toBytes(){
206   
207    //have to concatenate the subject action target and environment parameters and return as a string to make getbytes
208  17 String result="Type: "+type+ "\n";
209  17 result=result+S.getHolder().getName()+"\n"+A.getActionName()+"\n"+((PermisTarget) T).getName()+"\n" + creds+"\n";
210    //java.util.Map tt=new java.util.Map();
211   
212    // System.out.println( "here are the context values "+Application_Context);
213   
214   
215  17 Set keys = Application_Context.keySet(); // The set of keys in the map.
216  17 Iterator keyIter = keys.iterator();
217   
218  68 while (keyIter.hasNext()) {
219  51 Object key = keyIter.next(); // Get the next key.
220  51 Object value = Application_Context.get(key); // Get the value for that key.
221   
222  51 if(key=="Subject")
223  17 result=result+"Environment parameters: Subject= "+((issrg.pba.Subject)value).getHolder().getName()+"\n";
224    //subj=(issrg.pba.Subject)Application_Context.get("Subject");
225  34 else if(key=="ContextInstance")
226  17 result=result+"Environment parameters: ContextInstance= "+value+ " ";
227    else
228  17 result=result+"Environment parameters:" + key+ ": " +value+ " ";
229   
230    }
231   
232   
233  17 return toBytes(result);
234    }
235    }
236   
237   
238