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 ad22db641dcd61c2e8078f658fa709897b5da375 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Apr 13 15:19:31 2021 +0100 Expand tests to cover escaping of substituted roleBaes values While the UnboundedID LDAP SDK doesn't appear to have a preference some servers (Windows AD, OpenLDAP) do appear to. --- java/org/apache/catalina/realm/JNDIRealm.java | 4 +++- test/org/apache/catalina/realm/TestJNDIRealmIntegration.java | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java index 33895e4..f1354d1 100644 --- a/java/org/apache/catalina/realm/JNDIRealm.java +++ b/java/org/apache/catalina/realm/JNDIRealm.java @@ -1912,7 +1912,9 @@ public class JNDIRealm extends RealmBase { Name name = np.parse(dn); String nameParts[] = new String[name.size()]; for (int i = 0; i < name.size(); i++) { - nameParts[i] = name.get(i); + // May have been returned with \<char> escaping rather than + // \<hex><hex>. Make sure it is \<hex><hex>. + nameParts[i] = convertToHexEscape(name.get(i)); } base = connection.roleBaseFormat.format(nameParts); } else { diff --git a/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java b/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java index d019fc0..cd69267 100644 --- a/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java +++ b/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java @@ -60,7 +60,7 @@ public class TestJNDIRealmIntegration { addUsers(USER_PATTERN, null, null, roleSearch, ROLE_BASE, parameterSets); addUsers(null, USER_SEARCH, USER_BASE, roleSearch, ROLE_BASE, parameterSets); } - parameterSets.add(new Object[] { "cn={0},ou=sub,ou=people,dc=example,dc=com", null, null, ROLE_SEARCH_A, + parameterSets.add(new Object[] { "cn={0},ou=s\\;ub,ou=people,dc=example,dc=com", null, null, ROLE_SEARCH_A, "{3},ou=people,dc=example,dc=com", "testsub", "test", new String[] {"TestGroup4"} }); return parameterSets; } @@ -227,14 +227,14 @@ public class TestJNDIRealmIntegration { Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode()); AddRequest addPeopleSub = new AddRequest( - "dn: ou=sub,ou=people,dc=example,dc=com", + "dn: ou=s\\;ub,ou=people,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit"); result = conn.processOperation(addPeopleSub); Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode()); AddRequest addUserTestSub = new AddRequest( - "dn: cn=testsub,ou=sub,ou=people,dc=example,dc=com", + "dn: cn=testsub,ou=s\\;ub,ou=people,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", @@ -245,11 +245,11 @@ public class TestJNDIRealmIntegration { Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode()); AddRequest addGroupTest4 = new AddRequest( - "dn: cn=TestGroup4,ou=sub,ou=people,dc=example,dc=com", + "dn: cn=TestGroup4,ou=s\\;ub,ou=people,dc=example,dc=com", "objectClass: top", "objectClass: groupOfNames", "cn: TestGroup4", - "member: cn=testsub,ou=sub,ou=people,dc=example,dc=com"); + "member: cn=testsub,ou=s\\;ub,ou=people,dc=example,dc=com"); result = conn.processOperation(addGroupTest4); Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode()); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org