1 package org.apache.fulcrum.security;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.avalon.framework.activity.Initializable;
23 import org.apache.avalon.framework.logger.AbstractLogEnabled;
24 import org.apache.avalon.framework.service.ServiceException;
25 import org.apache.avalon.framework.service.ServiceManager;
26 import org.apache.avalon.framework.service.Serviceable;
27 import org.apache.avalon.framework.thread.ThreadSafe;
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class BaseSecurityService extends AbstractLogEnabled implements SecurityService, Initializable, Serviceable, ThreadSafe
42 {
43 private ServiceManager manager = null;
44
45
46
47 String userClassName;
48 String groupClassName;
49 String permissionClassName;
50 String roleClassName;
51 String aclClassName;
52
53 protected UserManager userManager = null;
54
55 protected RoleManager roleManager = null;
56
57 protected GroupManager groupManager = null;
58
59 protected PermissionManager permissionManager = null;
60
61 protected ModelManager modelManager = null;
62
63
64
65
66
67
68 public UserManager getUserManager()
69 {
70 if (userManager == null)
71 {
72 try
73 {
74 userManager = (UserManager) manager.lookup(UserManager.ROLE);
75 }
76 catch (ServiceException ce)
77 {
78 throw new RuntimeException(ce.getMessage(), ce);
79 }
80 }
81 return userManager;
82 }
83
84
85
86
87
88
89 public GroupManager getGroupManager()
90 {
91 if (groupManager == null)
92 {
93 try
94 {
95 groupManager = (GroupManager) manager.lookup(GroupManager.ROLE);
96 }
97 catch (ServiceException ce)
98 {
99 throw new RuntimeException(ce.getMessage(), ce);
100 }
101 }
102 return groupManager;
103 }
104
105
106
107
108
109
110 public RoleManager getRoleManager()
111 {
112 if (roleManager == null)
113 {
114 try
115 {
116 roleManager = (RoleManager) manager.lookup(RoleManager.ROLE);
117 }
118 catch (ServiceException ce)
119 {
120 throw new RuntimeException(ce.getMessage(), ce);
121 }
122 }
123 return roleManager;
124 }
125
126
127
128
129
130
131 public PermissionManager getPermissionManager()
132 {
133 if (permissionManager == null)
134 {
135 try
136 {
137 permissionManager = (PermissionManager) manager.lookup(PermissionManager.ROLE);
138 }
139 catch (ServiceException ce)
140 {
141 throw new RuntimeException(ce.getMessage(), ce);
142 }
143 }
144 return permissionManager;
145 }
146
147
148
149
150
151
152 public ModelManager getModelManager()
153 {
154 if (modelManager == null)
155 {
156 try
157 {
158 modelManager = (ModelManager) manager.lookup(ModelManager.ROLE);
159 }
160 catch (ServiceException ce)
161 {
162 throw new RuntimeException(ce.getMessage(), ce);
163 }
164 }
165 return modelManager;
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179 public void service(ServiceManager manager) throws ServiceException
180 {
181 this.manager = manager;
182 }
183
184
185
186
187
188
189
190
191 public void initialize() throws Exception
192 {
193 userClassName = null;
194 groupClassName = null;
195 permissionClassName = null;
196 roleClassName = null;
197 aclClassName = null;
198 }
199
200
201
202
203 public void dispose()
204 {
205 manager.release(userManager);
206 manager.release(roleManager);
207 manager.release(groupManager);
208 manager.release(permissionManager);
209 manager.release(modelManager);
210 manager = null;
211 }
212 }