36 * @author Xuelei Fan
37 * @author Vincent Ryan
38 * @author Jagane Sundar
39 * @author Rosanna Lee
40 */
41
42 final class Filter {
43
44 /**
45 * First convert filter string into byte[].
46 * For LDAP v3, the conversion uses Unicode -> UTF8
47 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
48 *
49 * Then parse the byte[] as a filter, converting \hh to
50 * a single byte, and encoding the resulting filter
51 * into the supplied BER buffer
52 */
53 static void encodeFilterString(BerEncoder ber, String filterStr,
54 boolean isLdapv3) throws IOException, NamingException {
55
56 if ((filterStr == null) || (filterStr.equals(""))) {
57 throw new InvalidSearchFilterException("Empty filter");
58 }
59 byte[] filter;
60 int filterLen;
61 if (isLdapv3) {
62 filter = filterStr.getBytes("UTF8");
63 } else {
64 filter = filterStr.getBytes("8859_1");
65 }
66 filterLen = filter.length;
67 if (dbg) {
68 dbgIndent = 0;
69 System.err.println("String filter: " + filterStr);
70 System.err.println("size: " + filterLen);
71 dprint("original: ", filter, 0, filterLen);
72 }
73
74 encodeFilter(ber, filter, 0, filterLen);
75 }
76
|
36 * @author Xuelei Fan
37 * @author Vincent Ryan
38 * @author Jagane Sundar
39 * @author Rosanna Lee
40 */
41
42 final class Filter {
43
44 /**
45 * First convert filter string into byte[].
46 * For LDAP v3, the conversion uses Unicode -> UTF8
47 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
48 *
49 * Then parse the byte[] as a filter, converting \hh to
50 * a single byte, and encoding the resulting filter
51 * into the supplied BER buffer
52 */
53 static void encodeFilterString(BerEncoder ber, String filterStr,
54 boolean isLdapv3) throws IOException, NamingException {
55
56 if ((filterStr == null) || (filterStr.isEmpty())) {
57 throw new InvalidSearchFilterException("Empty filter");
58 }
59 byte[] filter;
60 int filterLen;
61 if (isLdapv3) {
62 filter = filterStr.getBytes("UTF8");
63 } else {
64 filter = filterStr.getBytes("8859_1");
65 }
66 filterLen = filter.length;
67 if (dbg) {
68 dbgIndent = 0;
69 System.err.println("String filter: " + filterStr);
70 System.err.println("size: " + filterLen);
71 dprint("original: ", filter, 0, filterLen);
72 }
73
74 encodeFilter(ber, filter, 0, filterLen);
75 }
76
|