import java.util.Map;
import javax.naming.Context;
+import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName;
-import org.argeo.naming.NamingUtils;
+import org.argeo.util.naming.NamingUtils;
/** Properties used to configure user admins. */
public enum UserAdminConf {
/** Relative base DN for users */
groupBase("ou=Groups"),
+ /** Relative base DN for users */
+ systemRoleBase("ou=Roles"),
+
/** Read-only source */
readOnly(null),
disabled(null),
/** Authentication realm */
- realm(null);
+ realm(null),
+
+ /** Override all passwords with this value (typically for testing purposes) */
+ forcedPassword(null);
public final static String FACTORY_PID = "org.argeo.osgi.useradmin.config";
return new URI(null, null, bDn != null ? '/' + bDn : null, query.length() != 0 ? query.toString() : null,
null);
} catch (URISyntaxException e) {
- throw new UserDirectoryException("Cannot create URI from properties", e);
+ throw new IllegalArgumentException("Cannot create URI from properties", e);
}
}
} else if (scheme.equals(SCHEME_IPA)) {
} else if (scheme.equals(SCHEME_OS)) {
} else
- throw new UserDirectoryException("Unsupported scheme " + scheme);
+ throw new IllegalArgumentException("Unsupported scheme " + scheme);
Map<String, List<String>> query = NamingUtils.queryToMap(u);
for (String key : query.keySet()) {
UserAdminConf ldapProp = UserAdminConf.valueOf(key);
if (values.size() == 1) {
res.put(ldapProp.name(), values.get(0));
} else {
- throw new UserDirectoryException("Only single values are supported");
+ throw new IllegalArgumentException("Only single values are supported");
}
}
res.put(baseDn.name(), bDn);
}
}
return res;
- } catch (Exception e) {
- throw new UserDirectoryException("Cannot convert " + uri + " to properties", e);
+ } catch (URISyntaxException | InvalidNameException e) {
+ throw new IllegalArgumentException("Cannot convert " + uri + " to properties", e);
}
}
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);
+ throw new IllegalStateException("No baseDn in " + properties);
return DigestUtils.sha1str(bDn);
}
}