Merge pull request #4470 from pkadej/KEYCLOAK-5453
KEYCLOAK-5453 - Empty RDNs makes Keycloak unstable
This commit is contained in:
commit
685acb786a
2 changed files with 24 additions and 1 deletions
|
@ -50,7 +50,11 @@ public class LDAPDn {
|
|||
String[] rdns = dnString.split("(?<!\\\\),");
|
||||
for (String entryStr : rdns) {
|
||||
String[] rdn = entryStr.split("(?<!\\\\)=");
|
||||
if (rdn.length >1) {
|
||||
dn.addLast(rdn[0].trim(), rdn[1].trim());
|
||||
} else {
|
||||
dn.addLast(rdn[0].trim(), "");
|
||||
}
|
||||
}
|
||||
|
||||
return dn;
|
||||
|
|
|
@ -47,6 +47,25 @@ public class LDAPDnTest {
|
|||
Assert.assertEquals("Johny,Depp+Pepp\\Foo", dn.getFirstRdnAttrValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyRDN() throws Exception {
|
||||
LDAPDn dn = LDAPDn.fromString("dc=keycloak, dc=org");
|
||||
dn.addFirst("ou", "");
|
||||
|
||||
Assert.assertEquals("ou", dn.getFirstRdnAttrName());
|
||||
Assert.assertEquals("", dn.getFirstRdnAttrValue());
|
||||
|
||||
Assert.assertEquals("ou=,dc=keycloak,dc=org", dn.toString());
|
||||
|
||||
dn.addFirst("uid", "Johny,Depp+Pepp\\Foo");
|
||||
Assert.assertEquals("uid=Johny\\,Depp\\+Pepp\\\\Foo,ou=,dc=keycloak,dc=org", dn.toString());
|
||||
|
||||
dn = LDAPDn.fromString("uid=Johny\\,Depp\\+Pepp\\\\Foo,ou=,O=keycloak,C=org");
|
||||
Assert.assertTrue(dn.isDescendantOf(LDAPDn.fromString("ou=, O=keycloak,C=org")));
|
||||
Assert.assertTrue(dn.isDescendantOf(LDAPDn.fromString("OU=, o=keycloak,c=org")));
|
||||
Assert.assertFalse(dn.isDescendantOf(LDAPDn.fromString("ou=People, O=keycloak,C=org")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorrectEscape() throws Exception {
|
||||
LDAPDn dn = LDAPDn.fromString("dc=keycloak, dc=org");
|
||||
|
|
Loading…
Reference in a new issue