-
-public class NodeUserAdmin implements UserAdmin {
- private final static Log log = LogFactory.getLog(NodeUserAdmin.class);
- final static LdapName ROLES_BASE;
- static {
- try {
- ROLES_BASE = new LdapName(AuthConstants.ROLES_BASEDN);
- } catch (InvalidNameException e) {
- throw new UserDirectoryException("Cannot initialize "
- + NodeUserAdmin.class, e);
- }
- }
-
- private UserAdmin nodeRoles = null;
- private Map<LdapName, UserAdmin> userAdmins = new HashMap<LdapName, UserAdmin>();
-
- /** The home base path. */
- private String homeBasePath = "/home";
- private String peopleBasePath = ArgeoJcrConstants.PEOPLE_BASE_PATH;
- private Session adminSession;
-
- public NodeUserAdmin(Session adminSession) {
- this.adminSession = adminSession;
- File osgiInstanceDir = KernelUtils.getOsgiInstanceDir();
- File nodeBaseDir = new File(osgiInstanceDir, "node");
- nodeBaseDir.mkdirs();
-
- String userAdminUri = KernelUtils
- .getFrameworkProp(KernelConstants.USERADMIN_URIS);
- if (userAdminUri == null) {
- String demoBaseDn = "dc=example,dc=com";
- File businessRolesFile = new File(nodeBaseDir, demoBaseDn + ".ldif");
- if (!businessRolesFile.exists())
- try {
- FileUtils.copyInputStreamToFile(getClass()
- .getResourceAsStream(demoBaseDn + ".ldif"),
- businessRolesFile);
- } catch (IOException e) {
- throw new CmsException("Cannot copy demo resource", e);
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Aggregates multiple {@link UserDirectory} and integrates them with system
+ * roles.
+ */
+class NodeUserAdmin extends AggregatingUserAdmin implements ManagedServiceFactory, KernelConstants {
+ private final static CmsLog log = CmsLog.getLog(NodeUserAdmin.class);
+// private final BundleContext bc = FrameworkUtil.getBundle(getClass()).getBundleContext();
+
+ // OSGi
+ private Map<String, LdapName> pidToBaseDn = new HashMap<>();
+// private Map<String, ServiceRegistration<UserDirectory>> pidToServiceRegs = new HashMap<>();
+// private ServiceRegistration<UserAdmin> userAdminReg;
+
+ // JTA
+ private final ServiceTracker<WorkControl, WorkControl> tmTracker;
+ // private final String cacheName = UserDirectory.class.getName();
+
+ // GSS API
+ private Path nodeKeyTab = KernelUtils.getOsgiInstancePath(KernelConstants.NODE_KEY_TAB_PATH);
+ private GSSCredential acceptorCredentials;
+
+ private boolean singleUser = false;
+// private boolean systemRolesAvailable = false;
+
+ CmsUserManagerImpl userManager;
+
+ public NodeUserAdmin(String systemRolesBaseDn, String tokensBaseDn) {
+ super(systemRolesBaseDn, tokensBaseDn);
+ BundleContext bc = Activator.getBundleContext();
+ if (bc != null) {
+ tmTracker = new ServiceTracker<>(bc, WorkControl.class, null) {
+
+ @Override
+ public WorkControl addingService(ServiceReference<WorkControl> reference) {
+ WorkControl workControl = super.addingService(reference);
+ userManager = new CmsUserManagerImpl();
+ userManager.setUserAdmin(NodeUserAdmin.this);
+ // FIXME make it more robust
+ userManager.setUserTransaction((WorkTransaction) workControl);
+ bc.registerService(CmsUserManager.class, userManager, null);
+ return workControl;