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;
import org.argeo.naming.DnsBrowser;
import org.argeo.naming.NamingUtils;
import org.osgi.framework.Constants;
/** Read-only source */
readOnly(null),
+ /** Disabled source */
+ disabled(null),
+
/** Authentication realm */
realm(null);
public final static String FACTORY_PID = "org.argeo.osgi.useradmin.config";
- private final static Log log = LogFactory.getLog(UserAdminConf.class);
public final static String SCHEME_LDAP = "ldap";
public final static String SCHEME_FILE = "file";
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)
}
URI convertedUri = new URI(
SCHEME_LDAP + "://" + ldapHostsStr + "/" + IpaUtils.domainToUserDirectoryConfigPath(kerberosRealm));
- if (log.isDebugEnabled())
- log.debug("Converted " + uri + " to " + convertedUri);
return convertedUri;
} catch (NamingException | IOException | URISyntaxException e) {
throw new UserDirectoryException("cannot convert IPA uri " + uri, e);
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
- log.warn("Using localhost as hostname", e);
hostname = "localhost.localdomain";
}
int dotIdx = hostname.indexOf('.');
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<String, Object> properties) {
+ String bDn = (String) properties.get(baseDn.name());
+ if (bDn == null)
+ throw new UserDirectoryException("No baseDn in " + properties);
+ return DigestUtils.sha1str(bDn);
+ }
}