*/
protected ItemManager getItemManager(Request request, String name)
throws ConfigurationException {
AccessController accessController = null;
ServiceSelector selector = null;
AccessControllerResolver resolver = null;
ItemManager itemManager = null;
try {
selector = (ServiceSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
resolver =
(AccessControllerResolver) selector.select(
AccessControllerResolver.DEFAULT_RESOLVER);
String requestURI = request.getRequestURI();
String context = request.getContextPath();
if (context == null) {
context = "";
}
String url = requestURI.substring(context.length());
accessController = resolver.resolveAccessController(url);
AccreditableManager accreditableManager =
((DefaultAccessController) accessController).getAccreditableManager();
if (name.equals(USER_MANAGER)) {
itemManager = accreditableManager.getUserManager();
} else if (name.equals(GROUP_MANAGER)) {
itemManager = accreditableManager.getGroupManager();
} else if (name.equals(ROLE_MANAGER)) {
itemManager = accreditableManager.getRoleManager();
} else if (name.equals(IP_RANGE_MANAGER)) {
itemManager = accreditableManager.getIPRangeManager();
}
} catch (Exception e) {
throw new ConfigurationException("Obtaining item manager failed: ", e);
} finally {
if (selector != null) {
if (resolver != null) {
if (accessController != null) {
resolver.release(accessController);
}
selector.release(resolver);
}
manager.release(selector);
}