1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
package issrg.test.emptyDN; |
55 |
|
|
56 |
|
import issrg.pba.PbaException; |
57 |
|
import issrg.pba.Response; |
58 |
|
import issrg.pba.rbac.PermisRBAC; |
59 |
|
import issrg.pba.rbac.LDAPDNPrincipal; |
60 |
|
import issrg.simplePERMIS.SimplePERMISPolicyFinder; |
61 |
|
import issrg.simplePERMIS.SimplePERMISToken; |
62 |
|
import issrg.simplePERMIS.SimplePERMISTokenParser; |
63 |
|
import issrg.pba.Subject; |
64 |
|
import issrg.pba.PbaException; |
65 |
|
import issrg.utils.handler.Config; |
66 |
|
import issrg.utils.handler.ConfigException; |
67 |
|
import issrg.utils.RFC2253ParsingException; |
68 |
|
|
69 |
|
import java.util.*; |
70 |
|
import java.io.*; |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@author |
75 |
|
|
76 |
|
|
|
|
| 62.7% |
Uncovered Elements: 19 (51) |
Complexity: 12 |
Complexity Density: 0.38 |
|
77 |
|
public class PullFromSimplePERMISWithEmptyDN { |
78 |
|
|
79 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
80 |
0
|
public PullFromSimplePERMISWithEmptyDN() {... |
81 |
|
} |
82 |
|
|
83 |
|
private SimplePERMISTokenParser testParserTok = null; |
84 |
|
|
85 |
|
private static PermisRBAC adf = null; |
86 |
|
private static SimplePERMISPolicyFinder ssampf=null; |
87 |
|
private static String policy = null; |
88 |
|
private static Subject subject=null; |
89 |
|
private static PrintStream out = System.out; |
90 |
|
private static InputStream in = null; |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
|
|
| 75% |
Uncovered Elements: 7 (28) |
Complexity: 8 |
Complexity Density: 0.36 |
|
96 |
1
|
public static void main(String[] args) {... |
97 |
|
|
98 |
1
|
System.setProperty("line.separator", "\r\n"); |
99 |
|
|
100 |
1
|
if (args.length==2){ |
101 |
1
|
Config config = new Config(); |
102 |
1
|
try{ |
103 |
1
|
in = new FileInputStream(config.getURL(args[0])); |
104 |
1
|
out = new PrintStream(new FileOutputStream(args[1])); |
105 |
|
|
106 |
1
|
Properties props = new Properties(); |
107 |
1
|
props.load(in); |
108 |
1
|
policy = props.getProperty("policy"); |
109 |
1
|
in.close(); |
110 |
|
} catch(IOException ioe){ |
111 |
0
|
out.println("This shouldn't have happened! "+ioe.getMessage()); |
112 |
|
} catch(ConfigException ce){ |
113 |
0
|
out.println("This shouldn't have happened! "+ce.getMessage()); |
114 |
|
} |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
1
|
if (loadPolicy(policy)) out.println("policy is loaded"); |
126 |
1
|
if (constructADF()) out.println("CVS is created"); |
127 |
1
|
try { |
128 |
1
|
subject = adf.getCreds(new LDAPDNPrincipal("")); |
129 |
1
|
out.println(subject.exportCreds().toString()); |
130 |
|
} catch (PbaException pe) { |
131 |
0
|
out.println("error: "+pe); |
132 |
|
} catch (RFC2253ParsingException re) { |
133 |
0
|
out.println("error: "+re); |
134 |
|
} |
135 |
1
|
out.close(); |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@param |
142 |
|
|
143 |
|
|
|
|
| 35.7% |
Uncovered Elements: 9 (14) |
Complexity: 4 |
Complexity Density: 0.33 |
|
144 |
1
|
public static boolean loadPolicy(String pathNameofPolicy){... |
145 |
1
|
try{ |
146 |
1
|
ssampf = new SimplePERMISPolicyFinder(pathNameofPolicy); |
147 |
|
}catch (Exception e){ |
148 |
0
|
out.println("Exception was thrown in loading policy!"); |
149 |
0
|
out.println(e.getMessage()); |
150 |
0
|
ssampf=null; |
151 |
|
}catch(Throwable th){ |
152 |
0
|
out.println("Throwable was thrown in loading policy!"); |
153 |
0
|
out.println(th.getMessage()); |
154 |
0
|
ssampf=null; |
155 |
|
} |
156 |
|
|
157 |
1
|
if (ssampf == null){ |
158 |
0
|
out.println("Null PolicyFinder was returned!"); |
159 |
0
|
return false; |
160 |
|
} |
161 |
1
|
return true; |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
@return |
167 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
168 |
1
|
public static boolean constructADF(){... |
169 |
|
|
170 |
1
|
try{ |
171 |
1
|
adf = new PermisRBAC(ssampf); |
172 |
|
} catch(PbaException pe){ |
173 |
0
|
out.println(pe.getMessage()); |
174 |
0
|
return false; |
175 |
|
} |
176 |
|
|
177 |
1
|
return true; |
178 |
|
} |
179 |
|
} |