LdapEncoder { public static String filterEncode(String value) { if (value == null) return null; StringBuilder encodedValue = new StringBuilder(value.length() * 2); int length = value.length(); for (int i = 0; i < length; i++) { char c = value.charAt(i); if (c < FILTER_ESCAPE_TABLE.length) { encodedValue.append(FILTER_ESCAPE_TABLE[c]); } else { encodedValue.append(c); } } return encodedValue.toString(); } private  LdapEncoder(); static String filterEncode(String value); static String nameEncode(String value); static String nameDecode(String value); static String printBase64Binary(byte[] val); static byte[] parseBase64Binary(String val);  }
@Test public void testFilterEncode() { String correct = "\\2aa\\2ab\\28c\\29d\\2a\\5c"; assertThat(LdapEncoder.filterEncode("*a*b(c)d*\\")).isEqualTo(correct); }