[tomcat] 03/10: Rename for clarity
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 0a272b00aed57526dbfc8b881ab253c23c61f100 Author: Mark Thomas AuthorDate: Tue Apr 13 11:35:07 2021 +0100 Rename for clarity --- java/org/apache/catalina/realm/JNDIRealm.java | 30 +-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java index 9f43b94..1b74c2b 100644 --- a/java/org/apache/catalina/realm/JNDIRealm.java +++ b/java/org/apache/catalina/realm/JNDIRealm.java @@ -1884,7 +1884,7 @@ public class JNDIRealm extends RealmBase { } // Set up parameters for an appropriate search -String filter = connection.roleFormat.format(new String[] { doRFC2254Encoding(dn), username, userRoleId }); +String filter = connection.roleFormat.format(new String[] { doFilterEscaping(dn), username, userRoleId }); SearchControls controls = new SearchControls(); if (roleSubtree) { controls.setSearchScope(SearchControls.SUBTREE_SCOPE); @@ -1956,7 +1956,7 @@ public class JNDIRealm extends RealmBase { Map newThisRound = new HashMap<>(); // Stores the groups we find in this iteration for (Entry group : newGroups.entrySet()) { -filter = connection.roleFormat.format(new String[] { doRFC2254Encoding(group.getKey()), +filter = connection.roleFormat.format(new String[] { doFilterEscaping(group.getKey()), group.getValue(), group.getValue() }); if (containerLog.isTraceEnabled()) { @@ -2754,10 +2754,36 @@ public class JNDIRealm extends RealmBase { * ) -> \29 * \ -> \5c * \0 -> \00 + * * @param inString string to escape according to RFC 2254 guidelines + * * @return String the escaped/encoded result + * + * @deprecated Will be removed in Tomcat 10.1.x onwards */ +@Deprecated protected String doRFC2254Encoding(String inString) { +return doFilterEscaping(inString); +} + + +/** + * Given an LDAP search string, returns the string with certain characters + * escaped according to RFC 2254 guidelines. + * The character mapping is as follows: + * char -> Replacement + *--- + * * -> \2a + * ( -> \28 + * ) -> \29 + * \ -> \5c + * \0 -> \00 + * + * @param inString string to escape according to RFC 2254 guidelines + * + * @return String the escaped/encoded result + */ +protected String doFilterEscaping(String inString) { StringBuilder buf = new StringBuilder(inString.length()); for (int i = 0; i < inString.length(); i++) { char c = inString.charAt(i); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 03/10: Rename for clarity
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 749f3cc192c68c34f2375509aea087be45fc4434 Author: Mark Thomas AuthorDate: Tue Apr 13 11:35:07 2021 +0100 Rename for clarity --- java/org/apache/catalina/realm/JNDIRealm.java | 30 +-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java index 1e81d89..3bba372 100644 --- a/java/org/apache/catalina/realm/JNDIRealm.java +++ b/java/org/apache/catalina/realm/JNDIRealm.java @@ -1876,7 +1876,7 @@ public class JNDIRealm extends RealmBase { } // Set up parameters for an appropriate search -String filter = connection.roleFormat.format(new String[] { doRFC2254Encoding(dn), username, userRoleId }); +String filter = connection.roleFormat.format(new String[] { doFilterEscaping(dn), username, userRoleId }); SearchControls controls = new SearchControls(); if (roleSubtree) { controls.setSearchScope(SearchControls.SUBTREE_SCOPE); @@ -1948,7 +1948,7 @@ public class JNDIRealm extends RealmBase { Map newThisRound = new HashMap<>(); // Stores the groups we find in this iteration for (Entry group : newGroups.entrySet()) { -filter = connection.roleFormat.format(new String[] { doRFC2254Encoding(group.getKey()), +filter = connection.roleFormat.format(new String[] { doFilterEscaping(group.getKey()), group.getValue(), group.getValue() }); if (containerLog.isTraceEnabled()) { @@ -2739,10 +2739,36 @@ public class JNDIRealm extends RealmBase { * ) -> \29 * \ -> \5c * \0 -> \00 + * * @param inString string to escape according to RFC 2254 guidelines + * * @return String the escaped/encoded result + * + * @deprecated Will be removed in Tomcat 10.1.x onwards */ +@Deprecated protected String doRFC2254Encoding(String inString) { +return doFilterEscaping(inString); +} + + +/** + * Given an LDAP search string, returns the string with certain characters + * escaped according to RFC 2254 guidelines. + * The character mapping is as follows: + * char -> Replacement + *--- + * * -> \2a + * ( -> \28 + * ) -> \29 + * \ -> \5c + * \0 -> \00 + * + * @param inString string to escape according to RFC 2254 guidelines + * + * @return String the escaped/encoded result + */ +protected String doFilterEscaping(String inString) { StringBuilder buf = new StringBuilder(inString.length()); for (int i = 0; i < inString.length(); i++) { char c = inString.charAt(i); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 03/10: Rename for clarity
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 4e61e1d625a4a64d6b775e3a03c77a0b100d56d7 Author: Mark Thomas AuthorDate: Tue Apr 13 11:35:07 2021 +0100 Rename for clarity --- java/org/apache/catalina/realm/JNDIRealm.java | 30 +-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java index dc10675..c16c7b7 100644 --- a/java/org/apache/catalina/realm/JNDIRealm.java +++ b/java/org/apache/catalina/realm/JNDIRealm.java @@ -1876,7 +1876,7 @@ public class JNDIRealm extends RealmBase { } // Set up parameters for an appropriate search -String filter = connection.roleFormat.format(new String[] { doRFC2254Encoding(dn), username, userRoleId }); +String filter = connection.roleFormat.format(new String[] { doFilterEscaping(dn), username, userRoleId }); SearchControls controls = new SearchControls(); if (roleSubtree) { controls.setSearchScope(SearchControls.SUBTREE_SCOPE); @@ -1948,7 +1948,7 @@ public class JNDIRealm extends RealmBase { Map newThisRound = new HashMap<>(); // Stores the groups we find in this iteration for (Entry group : newGroups.entrySet()) { -filter = connection.roleFormat.format(new String[] { doRFC2254Encoding(group.getKey()), +filter = connection.roleFormat.format(new String[] { doFilterEscaping(group.getKey()), group.getValue(), group.getValue() }); if (containerLog.isTraceEnabled()) { @@ -2738,10 +2738,36 @@ public class JNDIRealm extends RealmBase { * ) -> \29 * \ -> \5c * \0 -> \00 + * * @param inString string to escape according to RFC 2254 guidelines + * * @return String the escaped/encoded result + * + * @deprecated Will be removed in Tomcat 10.1.x onwards */ +@Deprecated protected String doRFC2254Encoding(String inString) { +return doFilterEscaping(inString); +} + + +/** + * Given an LDAP search string, returns the string with certain characters + * escaped according to RFC 2254 guidelines. + * The character mapping is as follows: + * char -> Replacement + *--- + * * -> \2a + * ( -> \28 + * ) -> \29 + * \ -> \5c + * \0 -> \00 + * + * @param inString string to escape according to RFC 2254 guidelines + * + * @return String the escaped/encoded result + */ +protected String doFilterEscaping(String inString) { StringBuilder buf = new StringBuilder(inString.length()); for (int i = 0; i < inString.length(); i++) { char c = inString.charAt(i); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org