X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FUserAdminConf.java;h=7fd9e1895ffc4f9e9fa98734f4b7db356b6af513;hb=cceead8a279e8630f63cc9e8213bdcdca39955a5;hp=3631de40f45a9c26bed050b1f1f7445e73c7fc24;hpb=820bdbaef7c69ad478b780ae4241e19563d771ca;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/osgi/useradmin/UserAdminConf.java b/org.argeo.util/src/org/argeo/osgi/useradmin/UserAdminConf.java index 3631de40f..7fd9e1895 100644 --- a/org.argeo.util/src/org/argeo/osgi/useradmin/UserAdminConf.java +++ b/org.argeo.util/src/org/argeo/osgi/useradmin/UserAdminConf.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import javax.naming.Context; +import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; import org.argeo.util.naming.NamingUtils; @@ -34,6 +35,9 @@ public enum UserAdminConf { /** Relative base DN for users */ groupBase("ou=Groups"), + /** Relative base DN for users */ + systemRoleBase("ou=Roles"), + /** Read-only source */ readOnly(null), @@ -138,7 +142,7 @@ public enum UserAdminConf { 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); } } @@ -178,7 +182,7 @@ public enum UserAdminConf { } 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> query = NamingUtils.queryToMap(u); for (String key : query.keySet()) { UserAdminConf ldapProp = UserAdminConf.valueOf(key); @@ -186,7 +190,7 @@ public enum UserAdminConf { 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); @@ -206,8 +210,8 @@ public enum UserAdminConf { } } 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); } } @@ -236,7 +240,7 @@ public enum UserAdminConf { public static String baseDnHash(Dictionary 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); } }