Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
37   140   12   18.5
18   55   0.35   2
2     6.5  
1    
 
 
  PullFromLDAPWithEmptyDN       Line # 67 37 12 78.9% 0.7894737
 
No Tests
 
1    /*
2    * SimpleTestingObject.java
3    *
4    * Created on 30 July 2007, 14:44
5    *
6    * Copyright (c) 2006, University of Kent
7    * All rights reserved.
8    *
9    * Redistribution and use in source and binary forms, with or without
10    * modification, are permitted provided that the following conditions are met:
11    *
12    * Redistributions of source code must retain the above copyright notice, this
13    * list of conditions and the following disclaimer.
14    *
15    * Redistributions in binary form must reproduce the above copyright notice,
16    * this list of conditions and the following disclaimer in the documentation
17    * and/or other materials provided with the distribution.
18    *
19    * 1. Neither the name of the University of Kent nor the names of its
20    * contributors may be used to endorse or promote products derived from this
21    * software without specific prior written permission.
22    *
23    * 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26    * PURPOSE ARE DISCLAIMED.
27    *
28    * 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35    * POSSIBILITY OF SUCH DAMAGE.
36    *
37    * 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
38    * IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
39    * SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
40    * SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
41    * GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
42    * TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
43    * IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
44    * SERIOUS FAULTS, IN THIS SOFTWARE.
45    *
46    * 5. This license is governed, except to the extent that local laws
47    * necessarily apply, by the laws of England and Wales.
48    *
49    * Author : Linying Su
50    *
51    */
52   
53   
54    package issrg.test.emptyDN;
55   
56    import issrg.utils.handler.Handler;
57   
58    import org.w3c.dom.*;
59   
60    import java.io.*;
61   
62    /**
63    * This test suite is designed to test whether or not a decision making can work when a subject DN is empty.
64    */
65   
66   
 
67    public class PullFromLDAPWithEmptyDN {
68   
69    /**
70    * Creates a new instance of SimpleTesting
71    */
 
72  0 toggle public PullFromLDAPWithEmptyDN() {
73    }
74   
75    private static PrintStream out = System.out;
76   
77    /**
78    * This method is used to test Permis PDP with an empty subject DN.
79    * In pull model, from LDAP, it should return an empty set.
80    */
81   
 
82  1 toggle public static void main(String [] args){
83   
84  1 System.setProperty("line.separator", "\r\n");
85   
86  1 if (args.length==2){
87  1 try{
88  1 out = new PrintStream(new FileOutputStream(args[1]));
89    }catch(IOException ioe){
90  0 out.println("This shouldn't have happened! "+ioe.getMessage());
91    }
92    }
93   
94  1 try{
95  1 Handler test = new Handler();
96   
97    //test.initialise("/home/pip/init.pip",1);
98    //out = new PrintStream(new FileOutputStream("EmptyDNPullLDAP.out"));
99   
100  1 test.initialise(args[0],1);
101   
102    //System.out.println(new EncodeXML().encode(test.getCreds("","Subject"),0));
103   
104  1 out.println("pull from LDAP");
105  1 Element response = test.getCreds("","Subject");
106  1 NodeList list = response.getChildNodes();
107  2 for (int i=0; i<list.getLength(); i++) {
108  1 Node node = list.item(i);
109  0 if (Text.class.isAssignableFrom(node.getClass())) continue;
110  1 out.println(node.getNodeName());
111  1 NodeList list1 = node.getChildNodes();
112  2 for (int j=0; j<list1.getLength(); j++) {
113  1 Node node1 = list1.item(j);
114  0 if (Text.class.isAssignableFrom(node1.getClass())) continue;
115  1 out.println(node1.getNodeName());
116  1 NodeList list2= node1.getChildNodes();
117  2 for (int k=0; k<list2.getLength(); k++) {
118  1 Node node2 = list2.item(k);
119  0 if (Text.class.isAssignableFrom(node2.getClass())) continue;
120  1 out.println(node2.getNodeName());
121  1 NodeList list3 = node2.getChildNodes();
122  2 for (int l=0; l<list3.getLength(); l++) {
123  1 Node node3 = list3.item(l);
124  1 if (Text.class.isAssignableFrom(node3.getClass())) {
125  1 String result = node3.getNodeValue();
126  1 out.println("["+result.trim()+"]");
127    }
128    }
129    }
130    }
131    }
132    } catch (Exception pe) {
133  0 out.println("error:"+pe);
134  0 out.close();
135    } finally {
136  1 out.close(); // flush and close the output stream
137    }
138    }
139   
140    }