- 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);
- }
- userAdminUri = businessRolesFile.toURI().toString();
- }
-
- String[] uris = userAdminUri.split(" ");
- for (String uri : uris) {
- URI u;
- try {
- u = new URI(uri);
- if (u.getPath() == null)
- throw new CmsException("URI " + uri
- + " must have a path in order to determine base DN");
- if (u.getScheme() == null) {
- if (uri.startsWith("/") || uri.startsWith("./")
- || uri.startsWith("../"))
- u = new File(uri).getCanonicalFile().toURI();
- else if (!uri.contains("/"))
- u = new File(nodeBaseDir, uri).getCanonicalFile()
- .toURI();
- else
- throw new CmsException("Cannot interpret " + uri
- + " as an uri");
- } else if (u.getScheme().equals("file")) {
- u = new File(u).getCanonicalFile().toURI();
- }
- } catch (Exception e) {
- throw new CmsException(
- "Cannot interpret " + uri + " as an uri", e);
- }
- Dictionary<String, ?> properties = UserAdminConf.uriAsProperties(u
- .toString());
- UserDirectory businessRoles;
- if (u.getScheme().startsWith("ldap")) {
- businessRoles = new LdapUserAdmin(properties);