Skip to content

Commit

Permalink
Rename for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Apr 13, 2021
1 parent f4d9bde commit 4e61e1d
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions java/org/apache/catalina/realm/JNDIRealm.java
Expand Up @@ -1876,7 +1876,7 @@ protected List<String> getRoles(JNDIConnection connection, User user) throws Nam
}

// 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);
Expand Down Expand Up @@ -1948,7 +1948,7 @@ protected List<String> getRoles(JNDIConnection connection, User user) throws Nam
Map<String, String> newThisRound = new HashMap<>(); // Stores the groups we find in this iteration

for (Entry<String, String> 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()) {
Expand Down Expand Up @@ -2738,10 +2738,36 @@ protected String[] parseUserPatternString(String userPatternString) {
* ) -&gt; \29
* \ -&gt; \5c
* \0 -&gt; \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 -&gt; Replacement
* ---------------------------
* * -&gt; \2a
* ( -&gt; \28
* ) -&gt; \29
* \ -&gt; \5c
* \0 -&gt; \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);
Expand Down

0 comments on commit 4e61e1d

Please sign in to comment.