X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.enterprise%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FUserAdminConf.java;h=37d6339208486d3d5ec07b428262ac6442a826f3;hb=1bf049da92fa6cb0dde838a952a63866de313898;hp=b3ead140c7b5aa641418d5ec54ca204ed853f585;hpb=54e74b900b1c0f7b1de0def771de35e50a8d4071;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.enterprise/src/org/argeo/osgi/useradmin/UserAdminConf.java b/org.argeo.enterprise/src/org/argeo/osgi/useradmin/UserAdminConf.java index b3ead140c..37d633920 100644 --- a/org.argeo.enterprise/src/org/argeo/osgi/useradmin/UserAdminConf.java +++ b/org.argeo.enterprise/src/org/argeo/osgi/useradmin/UserAdminConf.java @@ -13,6 +13,7 @@ import java.util.Map; import javax.naming.Context; import javax.naming.NamingException; +import javax.naming.ldap.LdapName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,6 +44,9 @@ public enum UserAdminConf { /** Read-only source */ readOnly(null), + /** Disabled source */ + disabled(null), + /** Authentication realm */ realm(null); @@ -144,6 +148,9 @@ public enum UserAdminConf { if (bDn.endsWith(".ldif")) bDn = bDn.substring(0, bDn.length() - ".ldif".length()); + // Normalize base DN as LDAP name + bDn = new LdapName(bDn).toString(); + String principal = null; String credentials = null; if (scheme != null) @@ -254,4 +261,15 @@ public enum UserAdminConf { return "dc=" + hostname; } } + + /** + * Hash the base DN in order to have a deterministic string to be used as a cn + * for the underlying user directory. + */ + public static String baseDnHash(Dictionary properties) { + String bDn = (String) properties.get(baseDn.name()); + if (bDn == null) + throw new UserDirectoryException("No baseDn in " + properties); + return DigestUtils.sha1str(bDn); + } }