@Test public void testSearchFilterEscape() { String testString = ",;hello*\"#+<>)\\=(world*)"; testString = LdapUtils.escapeLdapSearchFilterValue(testString); Assert.assertEquals(",;hello*\"#+<>\\29\\5c=\\28world*\\29", testString); }
public static String escapeLdapSearchFilterValue(String value) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch (c) { case '(': sb.append("\\28"); break; case ')': sb.append("\\29"); break; case '\\': sb.append("\\5c"); break; case '\u0000': sb.append("\\00"); break; default: sb.append(c); } } return sb.toString(); }
LdapUtils { public static String escapeLdapSearchFilterValue(String value) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch (c) { case '(': sb.append("\\28"); break; case ')': sb.append("\\29"); break; case '\\': sb.append("\\5c"); break; case '\u0000': sb.append("\\00"); break; default: sb.append(c); } } return sb.toString(); } }
LdapUtils { public static String escapeLdapSearchFilterValue(String value) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch (c) { case '(': sb.append("\\28"); break; case ')': sb.append("\\29"); break; case '\\': sb.append("\\5c"); break; case '\u0000': sb.append("\\00"); break; default: sb.append(c); } } return sb.toString(); } private  LdapUtils(); }
LdapUtils { public static String escapeLdapSearchFilterValue(String value) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch (c) { case '(': sb.append("\\28"); break; case ')': sb.append("\\29"); break; case '\\': sb.append("\\5c"); break; case '\u0000': sb.append("\\00"); break; default: sb.append(c); } } return sb.toString(); } private  LdapUtils(); static void closeNamingEnumeration(NamingEnumeration<?> enumeration); static String convertToByteFormatString(byte[] bytes); static boolean dnConformsToSearchBaseDefinitions(String dn,
            Collection<LdapSearchBaseDefinition> searchBaseDefs); static String escapeLdapSearchFilterValue(String value); static List<String> getAttributeValues(Attributes attributes, String ldapAttributeName); static ExternalUserVO queryUserByName(String emailOrAlias); static void setSynchronizationFields(ExternalUserVO userVO); static Pair<String, String> splitAfterFirstRdn(String dn); }
LdapUtils { public static String escapeLdapSearchFilterValue(String value) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch (c) { case '(': sb.append("\\28"); break; case ')': sb.append("\\29"); break; case '\\': sb.append("\\5c"); break; case '\u0000': sb.append("\\00"); break; default: sb.append(c); } } return sb.toString(); } private  LdapUtils(); static void closeNamingEnumeration(NamingEnumeration<?> enumeration); static String convertToByteFormatString(byte[] bytes); static boolean dnConformsToSearchBaseDefinitions(String dn,
            Collection<LdapSearchBaseDefinition> searchBaseDefs); static String escapeLdapSearchFilterValue(String value); static List<String> getAttributeValues(Attributes attributes, String ldapAttributeName); static ExternalUserVO queryUserByName(String emailOrAlias); static void setSynchronizationFields(ExternalUserVO userVO); static Pair<String, String> splitAfterFirstRdn(String dn);  }