1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.security.impl;
19
20 import java.security.CodeSource;
21 import java.security.Permission;
22 import java.security.PermissionCollection;
23 import java.security.Policy;
24 import java.security.ProtectionDomain;
25
26 /***
27 * <p>
28 * Provide coordination between the default policy and Jetspeed custom policy.
29 * </p>
30 */
31 public class JaasPolicyCoordinator extends Policy
32 {
33 private final Policy defaultPolicy;
34
35 private final Policy j2Policy;
36
37 /***
38 * <p>
39 * Constructor for coordinating the policies.
40 * </p>
41 *
42 * @param defaultPolicy The default policy.
43 * @param j2Policy Jetspeed policy.
44 */
45 public JaasPolicyCoordinator(Policy defaultPolicy, Policy j2Policy)
46 {
47 this.defaultPolicy = defaultPolicy;
48 this.j2Policy = j2Policy;
49 }
50
51 /***
52 * @see java.security.Policy#getPermissions(java.security.CodeSource)
53 */
54 public PermissionCollection getPermissions(CodeSource codeSource)
55 {
56 return defaultPolicy.getPermissions(codeSource);
57 }
58
59 /***
60 * @see java.security.Policy#refresh()
61 */
62 public void refresh()
63 {
64 defaultPolicy.refresh();
65 j2Policy.refresh();
66 }
67
68 /***
69 * @see java.security.Policy#implies(java.security.ProtectionDomain, java.security.Permission)
70 */
71 public boolean implies(ProtectionDomain domain, Permission permission)
72 {
73 if (permission.getClass().getName().startsWith("java"))
74 {
75 return defaultPolicy.implies(domain, permission);
76 }
77 else
78 {
79 return j2Policy.implies(domain, permission);
80 }
81 }
82 }