FIX DN escape 'Equal sign': (#201)
https://ldapwiki.com/wiki/DN%20Escape%20Values
| | |
| | | } else { |
| | | if ((c == ' ' && si == length - 1) |
| | | || (c == '"' || c == '+' || c == ',' || c == ';' || c == '<' |
| | | || c == '>' || c == '\\' || c == '\u0000')) { |
| | | || c == '>' || c == '\\' || c == '\u0000' || c == '=')) { |
| | | builder.append('\\'); |
| | | } |
| | | builder.append(c); |
| | |
| | | public Entry readEntry() throws DecodeException, IOException { |
| | | if (hasNext()) { |
| | | final Map<String,List<Map<String,String>>> entry=mapper.readValue(parser,new TypeReference<Map<String,List<Map<String,String>>>>() {}); |
| | | final Entry res=new LinkedHashMapEntry(entry.keySet().iterator().next()); |
| | | for (Map<String,String> attrs : entry.get(res.getName().toString())) { |
| | | final String key=entry.keySet().iterator().next(); |
| | | final Entry res=new LinkedHashMapEntry(key); |
| | | List<Map<String,String>> attrsArray=entry.get(res.getName().toString()); |
| | | if (attrsArray==null) { |
| | | attrsArray=entry.get(key); |
| | | } |
| | | for (Map<String,String> attrs : attrsArray) { |
| | | for (java.util.Map.Entry<String,String> attr : attrs.entrySet()) { |
| | | res.addAttribute(attr.getKey(), attr.getValue()); |
| | | } |
| | |
| | | { "givenName=John+cn=Doe,ou=People,dc=example,dc=com", |
| | | "cn=doe+givenname=john,ou=people,dc=example,dc=com", |
| | | "givenName=John+cn=Doe,ou=People,dc=example,dc=com" }, |
| | | { "givenName=John\\+cn=Doe,ou=People,dc=example,dc=com", |
| | | "givenname=john\\+cn=doe,ou=people,dc=example,dc=com", |
| | | "givenName=John\\+cn=Doe,ou=People,dc=example,dc=com" }, |
| | | { "givenName=John\\+cn\\=Doe,ou=People,dc=example,dc=com", |
| | | "givenname=john\\+cn\\=doe,ou=people,dc=example,dc=com", |
| | | "givenName=John\\+cn\\=Doe,ou=People,dc=example,dc=com" }, |
| | | { "cn=Doe\\, John,ou=People,dc=example,dc=com", |
| | | "cn=doe\\, john,ou=people,dc=example,dc=com", |
| | | "cn=Doe\\, John,ou=People,dc=example,dc=com" }, |
| | |
| | | DN actual = DN.format("uid=%s,dc=test", "#cn=foo+sn=bar"); |
| | | DN expected = DN.valueOf("dc=test").child("uid", "#cn=foo+sn=bar"); |
| | | assertEquals(actual, expected); |
| | | assertEquals(actual.toString(), "uid=\\#cn=foo\\+sn=bar,dc=test"); |
| | | assertEquals(actual.toString(), "uid=\\#cn\\=foo\\+sn\\=bar,dc=test"); |
| | | } |
| | | |
| | | /** Tests the {@link DN#escapeAttributeValue(Object)} method. */ |
| | | @Test |
| | | public void testEscapeAttributeValue() { |
| | | String actual = DN.escapeAttributeValue("#cn=foo+sn=bar"); |
| | | assertEquals(actual, "\\#cn=foo\\+sn=bar"); |
| | | assertEquals(actual, "\\#cn\\=foo\\+sn\\=bar"); |
| | | } |
| | | |
| | | /** Tests the {@link DN#toNormalizedByteString()} method. */ |
| | |
| | | { |
| | | // Should perform DN quoting. |
| | | "dn:uid={uid},ou={realm},dc=example,dc=com", |
| | | "uid=test.user,ou=test\\+cn=quoting,dc=example,dc=com", |
| | | "uid=test.user,ou=test\\+cn\\=quoting,dc=example,dc=com", |
| | | map("uid", "test.user", "realm", "test+cn=quoting") |
| | | }, |
| | | { |