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 |
|
package issrg.pba.rbac; |
34 |
|
|
35 |
|
import issrg.pba.AuthzTokenParser; |
36 |
|
import java.lang.reflect.Method; |
37 |
|
import issrg.pba.PbaException; |
38 |
|
import issrg.pba.repository.UserEntry; |
39 |
|
import issrg.pba.repository.AuthzTokenRepository; |
40 |
|
|
41 |
|
import org.apache.log4j.*; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@author |
62 |
|
@version |
63 |
|
|
64 |
|
|
|
|
| 58.7% |
Uncovered Elements: 38 (92) |
Complexity: 16 |
Complexity Density: 0.64 |
|
65 |
|
public class CustomisePERMIS { |
66 |
|
|
67 |
|
private static Logger logger = Logger.getLogger("issrg.pba.rbac.CustomisePERMIS"); |
68 |
|
private static boolean multipleParser = false; |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@see |
74 |
|
|
75 |
|
private static String ACPermisParserClass = "issrg.pba.rbac.x509.RoleBasedACParser"; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
public static Clock systemClock = new SystemClock(); |
81 |
|
|
82 |
|
|
83 |
|
protected static Class revocationChecker = issrg.pba.rbac.WebDAVRevocationChecker.class; |
84 |
|
|
85 |
|
protected static boolean certFirst=true; |
86 |
|
|
87 |
|
protected static int rev_time = 4; |
88 |
|
|
89 |
|
protected static boolean shouldRevoke = true; |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
protected static Class authTokenParser = issrg.simplePERMIS.SimplePERMISTokenParser.class; |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
private static String ATTRIBUTE_CERTIFICATE_ID = "attributeCertificateAttribute;binary"; |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
112
|
public static Clock getSystemClock(){... |
120 |
112
|
return systemClock; |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 0.5 |
|
127 |
39
|
public static AuthzTokenParser getAuthTokenParser(){... |
128 |
39
|
try{ |
129 |
39
|
AuthzTokenParser parser = (AuthzTokenParser)authTokenParser.newInstance(); |
130 |
39
|
logger.debug("Auth Token Parser : "+parser.getClass().getName()+" is used"); |
131 |
39
|
return parser; |
132 |
|
}catch (IllegalAccessException ile){ |
133 |
0
|
throw new IllegalArgumentException("Default constructor is unavailable for class "+authTokenParser.getName()+": "+ile.getMessage()); |
134 |
|
}catch (InstantiationException e){ |
135 |
0
|
throw new IllegalArgumentException("Can't instantiate abstract class "+authTokenParser.getName()+": "+e.getMessage()); |
136 |
|
} |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
@return |
147 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
148 |
0
|
public static boolean checkCertificateFirst(){... |
149 |
0
|
return certFirst; |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0
|
public static void setCheckCRLRevocationFirst(boolean shouldCRLbeCheckedFirst){... |
153 |
0
|
certFirst = !shouldCRLbeCheckedFirst; |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
@return |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
160 |
0
|
public static int getRevocationTimeOut(){... |
161 |
0
|
return rev_time; |
162 |
|
} |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
163 |
0
|
public static int getRevocationCount(){... |
164 |
0
|
return 3; |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
@return |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0
|
public static RevocationChecker getRevocationChecker(){... |
173 |
0
|
return new WebDAVRevocationChecker(shouldRevoke); |
174 |
|
} |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
175 |
0
|
public static void setRevocationCheckerRevoking(boolean revoke){... |
176 |
0
|
shouldRevoke=revoke; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
@param |
185 |
|
|
186 |
|
@see |
187 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
188 |
22
|
public static void setAuthTokenParser(String className) throws ClassNotFoundException {... |
189 |
22
|
logger.debug("Auth Token Parser is set to "+className); |
190 |
22
|
authTokenParser = Class.forName(className); |
191 |
22
|
if (!AuthzTokenParser.class.isAssignableFrom(authTokenParser)){ |
192 |
0
|
throw new ClassCastException(className+" does not implement "+AuthzTokenParser.class.getName()); |
193 |
|
} |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
@param |
201 |
|
@see |
202 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
203 |
0
|
public static void setRevocationChecker(String className) throws ClassNotFoundException {... |
204 |
0
|
revocationChecker = Class.forName(className); |
205 |
0
|
if (!AuthzTokenParser.class.isAssignableFrom(revocationChecker)){ |
206 |
0
|
throw new ClassCastException(className+" does not implement "+RevocationChecker.class.getName()); |
207 |
|
} |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
@param |
217 |
|
|
218 |
|
@see |
219 |
|
|
|
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 4 |
Complexity Density: 0.57 |
|
220 |
9
|
public static void setSystemClock(String className) throws ClassNotFoundException {... |
221 |
9
|
Class clazz = Class.forName(className); |
222 |
9
|
if (!Clock.class.isAssignableFrom(clazz)){ |
223 |
0
|
throw new ClassCastException(className+" does not extend "+Clock.class.getName()); |
224 |
|
} |
225 |
|
|
226 |
9
|
try{ |
227 |
9
|
systemClock = (Clock)clazz.newInstance(); |
228 |
|
}catch (IllegalAccessException ile){ |
229 |
0
|
throw new IllegalArgumentException("Default constructor is unavailable for class "+className+": "+ile.getMessage()); |
230 |
|
}catch (InstantiationException e){ |
231 |
0
|
throw new IllegalArgumentException("Can't instantiate abstract class "+className+": "+e.getMessage()); |
232 |
|
} |
233 |
|
} |
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
@param |
242 |
|
|
243 |
|
@see |
244 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 3 |
Complexity Density: 0.6 |
|
245 |
1
|
public static void addURLHandler(String className) throws ClassNotFoundException {... |
246 |
1
|
Class uh = Class.forName(className); |
247 |
1
|
try{ |
248 |
1
|
URLHandler.addProtocol((URLHandler)uh.newInstance()); |
249 |
|
}catch (IllegalAccessException ile){ |
250 |
0
|
throw new IllegalArgumentException("Default constructor is unavailable for class "+className+": "+ile.getMessage()); |
251 |
|
}catch (InstantiationException ie){ |
252 |
0
|
throw new IllegalArgumentException("Can't instantiate abstract class "+className+": "+ie.getMessage()); |
253 |
|
} |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
263 |
16
|
public static void configureX509Flavour() throws PbaException {... |
264 |
16
|
try{ |
265 |
16
|
setAuthTokenParser(ACPermisParserClass); |
266 |
16
|
registerACExtensions(); |
267 |
|
}catch(Throwable th){ |
268 |
0
|
throw new PbaException("Could not set up X.509 flavour of PERMIS: "+th.getMessage(), th); |
269 |
|
} |
270 |
|
} |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
276 |
1423
|
public static String getAttributeCertificateAttribute(){... |
277 |
1423
|
return ATTRIBUTE_CERTIFICATE_ID; |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
284 |
9
|
public static void setAttributeCertificateAttribute(String id){... |
285 |
9
|
ATTRIBUTE_CERTIFICATE_ID=id; |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
292 |
9
|
public static String getUserCertificateAttribute(){... |
293 |
9
|
return issrg.security.PKCRepository.USER_PKC_ATTRIBUTE; |
294 |
|
} |
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
300 |
4
|
public static void setUserCertificateAttribute(String id){... |
301 |
4
|
issrg.security.PKCRepository.USER_PKC_ATTRIBUTE=id; |
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
@see |
310 |
|
|
311 |
|
private final static String[] extensions = { |
312 |
|
"issrg.ac.attributes.BasicAttConstraint", |
313 |
|
"issrg.ac.attributes.NoAssertion", |
314 |
|
"issrg.ac.attributes.IndirectIssuer", |
315 |
|
"issrg.ac.attributes.IssuedOnBehalfOf", |
316 |
|
"issrg.ac.attributes.AuthorityAttributeIdentifier", |
317 |
|
"issrg.ac.extensions.AttributeAuthorityInformationAccess", |
318 |
|
"issrg.ac.extensions.AuthorityInformationAccess", |
319 |
|
"issrg.ac.extensions.WebdavCertificate", |
320 |
|
"issrg.ac.extensions.WebdavRevocation"}; |
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
326 |
19
|
public static void registerACExtensions() throws issrg.pba.PbaException {... |
327 |
19
|
registerACExtensions(extensions); |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
334 |
19
|
public static void registerACExtensions(String [] exts) throws issrg.pba.PbaException {... |
335 |
19
|
int len = exts.length; |
336 |
19
|
String line; |
337 |
19
|
try { |
338 |
190
|
for (int i = 0; i < len; i++) { |
339 |
171
|
line = exts[i]; |
340 |
171
|
Class extensionClass = Class.forName(line); |
341 |
171
|
Method method = extensionClass.getMethod("registerMe",null); |
342 |
171
|
method.invoke(null, null); |
343 |
|
} |
344 |
|
} catch (Exception e) { |
345 |
0
|
throw new issrg.pba.PbaException("Failed to register AC Extensions: "+e.getMessage(), e); |
346 |
|
} |
347 |
|
} |
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
@see |
355 |
|
|
356 |
|
public static Class comparator = issrg.pba.rbac.xmlpolicy.DefaultRuleComparator.class; |
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
@see |
363 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 3 |
Complexity Density: 0.75 |
|
364 |
26
|
public static RuleComparator getComparator() {... |
365 |
26
|
try { |
366 |
26
|
return (RuleComparator) comparator.newInstance(); |
367 |
|
} catch (InstantiationException ie) { |
368 |
0
|
throw new IllegalArgumentException("Can't instantiate abstract class " + comparator.getName()+": " + ie.getMessage()); |
369 |
|
} catch (IllegalAccessException ile){ |
370 |
0
|
throw new IllegalArgumentException("Default constructor is unavailable for class " + comparator.getName()+": "+ile.getMessage()); |
371 |
|
} |
372 |
|
} |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
@see |
380 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
381 |
0
|
public static void setComparator(String className) throws ClassNotFoundException {... |
382 |
0
|
comparator = Class.forName(className); |
383 |
0
|
if (!RuleComparator.class.isAssignableFrom(comparator)) { |
384 |
0
|
throw new ClassCastException(className + "does not implement " + RuleComparator.class.getName()); |
385 |
|
} |
386 |
|
} |
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
391 |
2
|
public static void setMultiParser(boolean mp) {... |
392 |
2
|
multipleParser = mp; |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
398 |
3931
|
public static boolean isMultiParserUsed() {... |
399 |
3931
|
return multipleParser; |
400 |
|
} |
401 |
|
} |