/** Properties used to configure user admins. */
public enum UserAdminConf {
/** Base DN (cannot be configured externally) */
/** Properties used to configure user admins. */
public enum UserAdminConf {
/** Base DN (cannot be configured externally) */
userObjectClass("inetOrgPerson"),
/** Relative base DN for users */
userObjectClass("inetOrgPerson"),
/** Relative base DN for users */
/** Groups objectClass */
groupObjectClass("groupOfNames"),
/** Relative base DN for users */
/** Groups objectClass */
groupObjectClass("groupOfNames"),
/** Relative base DN for users */
@SuppressWarnings("unchecked")
public <T> T getRawValue(Dictionary<String, ?> properties) {
@SuppressWarnings("unchecked")
public <T> T getRawValue(Dictionary<String, ?> properties) {
- if (key.startsWith(PREFIX) && !key.equals(baseDn.property())
- && !key.equals(uri.property())) {
+ // TODO clarify which keys are relevant (list only the enum?)
+ if (!key.equals("service.factoryPid") && !key.equals("cn") && !key.equals("dn")
+ && !key.equals(Constants.SERVICE_PID) && !key.startsWith("java") && !key.equals(baseDn.name())
+ && !key.equals(uri.name())) {
- return new URI(null, null, bDn != null ? '/' + bDn : null,
- query.length() != 0 ? query.toString() : null, null);
+ return new URI(null, null, bDn != null ? '/' + bDn : null, query.length() != 0 ? query.toString() : null,
+ null);
try {
Hashtable<String, Object> res = new Hashtable<String, Object>();
URI u = new URI(uriStr);
String scheme = u.getScheme();
String path = u.getPath();
try {
Hashtable<String, Object> res = new Hashtable<String, Object>();
URI u = new URI(uriStr);
String scheme = u.getScheme();
String path = u.getPath();
if (bDn.endsWith(".ldif"))
bDn = bDn.substring(0, bDn.length() - ".ldif".length());
if (bDn.endsWith(".ldif"))
bDn = bDn.substring(0, bDn.length() - ".ldif".length());
Map<String, List<String>> query = splitQuery(u.getQuery());
for (String key : query.keySet()) {
UserAdminConf ldapProp = UserAdminConf.valueOf(key);
List<String> values = query.get(key);
if (values.size() == 1) {
Map<String, List<String>> query = splitQuery(u.getQuery());
for (String key : query.keySet()) {
UserAdminConf ldapProp = UserAdminConf.valueOf(key);
List<String> values = query.get(key);
if (values.size() == 1) {
if (scheme != null) {
URI bareUri = new URI(scheme, null, u.getHost(), u.getPort(),
scheme.equals("file") ? u.getPath() : null, null, null);
if (scheme != null) {
URI bareUri = new URI(scheme, null, u.getHost(), u.getPort(),
scheme.equals("file") ? u.getPath() : null, null, null);
- private static Map<String, List<String>> splitQuery(String query)
- throws UnsupportedEncodingException {
+ private static Map<String, List<String>> splitQuery(String query) throws UnsupportedEncodingException {
final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>();
if (query == null)
return query_pairs;
final String[] pairs = query.split("&");
for (String pair : pairs) {
final int idx = pair.indexOf("=");
final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>();
if (query == null)
return query_pairs;
final String[] pairs = query.split("&");
for (String pair : pairs) {
final int idx = pair.indexOf("=");
- final String key = idx > 0 ? URLDecoder.decode(
- pair.substring(0, idx), "UTF-8") : pair;
+ final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair;
if (!query_pairs.containsKey(key)) {
query_pairs.put(key, new LinkedList<String>());
}
if (!query_pairs.containsKey(key)) {
query_pairs.put(key, new LinkedList<String>());
}
- final String value = idx > 0 && pair.length() > idx + 1 ? URLDecoder
- .decode(pair.substring(idx + 1), "UTF-8") : null;
+ final String value = idx > 0 && pair.length() > idx + 1
+ ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : null;
- Dictionary<String, ?> props = uriAsProperties("ldap://"
- + "uid=admin,ou=system:secret@localhost:10389"
- + "/dc=example,dc=com"
- + "?readOnly=false&userObjectClass=person");
+ Dictionary<String, ?> props = uriAsProperties("ldap://" + "uid=admin,ou=system:secret@localhost:10389"
+ + "/dc=example,dc=com" + "?readOnly=false&userObjectClass=person");
- props = uriAsProperties("/dc=example,dc=com.ldif?readOnly=true"
- + "&userBase=ou=CoWorkers,ou=People&groupBase=ou=Roles");
+ props = uriAsProperties(
+ "/dc=example,dc=com.ldif?readOnly=true" + "&userBase=ou=CoWorkers,ou=People&groupBase=ou=Roles");