X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fkernel%2FNodeUserAdmin.java;h=31295ae89fac8f58b04fe3ba0ed78247a229c086;hb=ea63d7d123a50ff10657946ce3d928a57944621d;hp=7ead081510e7ba3088f7b03786edc998154b5e24;hpb=48a1e034607afb28d84480463b57f74a80a29929;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeUserAdmin.java b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeUserAdmin.java index 7ead08151..31295ae89 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeUserAdmin.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeUserAdmin.java @@ -3,7 +3,6 @@ package org.argeo.cms.internal.kernel; import java.io.File; import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; import java.util.Dictionary; @@ -23,10 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.cms.CmsException; import org.argeo.cms.KernelHeader; -import org.argeo.osgi.useradmin.UserDirectory; -import org.argeo.osgi.useradmin.UserAdminProps; import org.argeo.osgi.useradmin.LdapUserAdmin; import org.argeo.osgi.useradmin.LdifUserAdmin; +import org.argeo.osgi.useradmin.UserAdminConf; +import org.argeo.osgi.useradmin.UserDirectory; import org.argeo.osgi.useradmin.UserDirectoryException; import org.osgi.framework.InvalidSyntaxException; import org.osgi.service.useradmin.Authorization; @@ -75,21 +74,27 @@ public class NodeUserAdmin implements UserAdmin { 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("/")) - u = new File(uri).getAbsoluteFile().toURI(); + if (uri.startsWith("/") || uri.startsWith("./") + || uri.startsWith("../")) + u = new File(uri).getCanonicalFile().toURI(); else if (!uri.contains("/")) - u = new File(nodeBaseDir, uri).getAbsoluteFile() + 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 (URISyntaxException e) { + } catch (Exception e) { throw new CmsException( "Cannot interpret " + uri + " as an uri", e); } - Dictionary properties = UserAdminProps.uriAsProperties(u + Dictionary properties = UserAdminConf.uriAsProperties(u .toString()); UserDirectory businessRoles; if (u.getScheme().startsWith("ldap")) { @@ -120,10 +125,10 @@ public class NodeUserAdmin implements UserAdmin { nodeRolesUri = nodeRolesFile.toURI().toString(); } - Dictionary nodeRolesProperties = UserAdminProps + Dictionary nodeRolesProperties = UserAdminConf .uriAsProperties(nodeRolesUri); - if (!nodeRolesProperties.get(UserAdminProps.baseDn.getFullName()) - .equals(baseNodeRoleDn)) { + if (!nodeRolesProperties.get(UserAdminConf.baseDn.property()).equals( + baseNodeRoleDn)) { throw new CmsException("Invalid base dn for node roles"); // TODO deal with "mounted" roles with a different baseDN } @@ -135,7 +140,7 @@ public class NodeUserAdmin implements UserAdmin { } nodeRoles.setExternalRoles(this); nodeRoles.init(); - addUserAdmin(baseNodeRoleDn, (UserAdmin)nodeRoles); + addUserAdmin(baseNodeRoleDn, (UserAdmin) nodeRoles); if (log.isTraceEnabled()) log.trace("Node roles enabled."); } @@ -147,7 +152,7 @@ public class NodeUserAdmin implements UserAdmin { if (userAdmins.get(name) instanceof UserDirectory) { UserDirectory userDirectory = (UserDirectory) userAdmins .get(name); - String uri = UserAdminProps.propertiesAsUri( + String uri = UserAdminConf.propertiesAsUri( userDirectory.getProperties()).toString(); res.put(uri, ""); } else { @@ -175,7 +180,9 @@ public class NodeUserAdmin implements UserAdmin { @Override public boolean removeRole(String name) { - return findUserAdmin(name).removeRole(name); + boolean actuallyDeleted = findUserAdmin(name).removeRole(name); + nodeRoles.removeRole(name); + return actuallyDeleted; } @Override