From 79811e7a2c59f9e4b237043466b736b5ece294dc Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Wed, 08 Jun 2016 14:37:08 +0000
Subject: [PATCH] OPENDJ-3067 Use curly brace notation in all templates for consistency
---
opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json | 18 +++++++++---------
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java | 10 +++++++---
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json b/opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json
index d1b9bbc..e0d9e0d 100644
--- a/opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json
+++ b/opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json
@@ -103,10 +103,10 @@
// If missing, "bind" factory will be used.
"ldapConnectionFactory": "bind",
- // The Bind DN Template containing a single %s which will be replaced by the authenticating
- // user's name. (i.e: uid=%s,ou=People,dc=example,dc=com)
- // If missing, "%s" is used.
- "bindDNTemplate": "uid=%s,ou=People,dc=example,dc=com"
+ // The Bind DN Template containing a single {username} which will be replaced by the authenticating
+ // user's name. (i.e: uid={username},ou=People,dc=example,dc=com)
+ // If missing, "{username}" is used.
+ "bindDNTemplate": "uid={username},ou=People,dc=example,dc=com"
},
// Bind to the LDAP server using a SASL Plain request
@@ -115,9 +115,9 @@
// If missing, "bind" factory will be used.
"ldapConnectionFactory": "bind",
- // Authentication identity template containing a single %s which will be replaced by the authenticating
- // user's name. (i.e: u:%s)
- "authzIdTemplate": "u:%s"
+ // Authentication identity template containing a single {username} which will be replaced by the authenticating
+ // user's name. (i.e: u:{username})
+ "authzIdTemplate": "u:{username}"
},
// Bind to the LDAP server using the resulting DN of a search request.
@@ -130,11 +130,11 @@
// If missing, "bind" factory will be used.
"bindLDAPConnectionFactory": "bind",
- // The %s filter format parameters will be substituted with the client-provided username,
+ // The {username} filter format parameters will be substituted with the client-provided username,
// using LDAP filter string character escaping.
"baseDN" : "ou=people,dc=example,dc=com",
"scope" : "sub", // Or "one".
- "filterTemplate" : "(&(uid=%s)(objectClass=inetOrgPerson))"
+ "filterTemplate" : "(&(uid={username})(objectClass=inetOrgPerson))"
}
// TODO: support for HTTP sessions?
},
diff --git a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java
index 7b65de3..0c53d23 100644
--- a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java
+++ b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java
@@ -387,14 +387,14 @@
private AuthenticationStrategy buildSimpleBindStrategy(final JsonValue config) {
return newSimpleBindStrategy(getConnectionFactory(config.get("ldapConnectionFactory")
.defaultTo(DEFAULT_BIND_FACTORY).asString()),
- config.get("bindDNTemplate").defaultTo("%s").asString(),
+ parseUserNameTemplate(config.get("bindDNTemplate").defaultTo("%s")),
schema);
}
private AuthenticationStrategy buildSASLBindStrategy(JsonValue config) {
return newSASLPlainStrategy(
getConnectionFactory(config.get("ldapConnectionFactory").defaultTo(DEFAULT_BIND_FACTORY).asString()),
- schema, config.get(AUTHZID_TEMPLATE).defaultTo("u:%s").asString());
+ schema, parseUserNameTemplate(config.get(AUTHZID_TEMPLATE).defaultTo("u:%s")));
}
private AuthenticationStrategy buildSearchThenBindStrategy(JsonValue config) {
@@ -405,6 +405,10 @@
config.get("bindLDAPConnectionFactory").defaultTo(DEFAULT_BIND_FACTORY).asString()),
DN.valueOf(config.get("baseDN").required().asString(), schema),
SearchScope.valueOf(config.get("scope").required().asString().toLowerCase()),
- config.get("filterTemplate").required().asString());
+ parseUserNameTemplate(config.get("filterTemplate").required()));
+ }
+
+ private String parseUserNameTemplate(final JsonValue template) {
+ return template.asString().replace("{username}", "%s");
}
}
--
Gitblit v1.10.0