javax.naming.directory.InvalidSearchFilterException Java Examples

The following examples show how to use javax.naming.directory.InvalidSearchFilterException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Filter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #2
Source File: Filter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #3
Source File: Filter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #4
Source File: Filter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #5
Source File: Filter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #6
Source File: Filter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #7
Source File: Filter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #8
Source File: Filter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #9
Source File: Filter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #10
Source File: Filter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #11
Source File: Filter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #12
Source File: Filter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #13
Source File: Filter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * First convert filter string into byte[].
 * For LDAP v3, the conversion uses Unicode -> UTF8
 * For LDAP v2, the conversion uses Unicode -> ISO 8859 (Latin-1)
 *
 * Then parse the byte[] as a filter, converting \hh to
 * a single byte, and encoding the resulting filter
 * into the supplied BER buffer
 */
static void encodeFilterString(BerEncoder ber, String filterStr,
    boolean isLdapv3) throws IOException, NamingException {

    if ((filterStr == null) || (filterStr.equals(""))) {
        throw new InvalidSearchFilterException("Empty filter");
    }
    byte[] filter;
    int filterLen;
    if (isLdapv3) {
        filter = filterStr.getBytes("UTF8");
    } else {
        filter = filterStr.getBytes("8859_1");
    }
    filterLen = filter.length;
    if (dbg) {
        dbgIndent = 0;
        System.err.println("String filter: " + filterStr);
        System.err.println("size: " + filterLen);
        dprint("original: ", filter, 0, filterLen);
    }

    encodeFilter(ber, filter, 0, filterLen);
}
 
Example #14
Source File: Filter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #15
Source File: Filter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #16
Source File: Filter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #17
Source File: Filter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #18
Source File: Filter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #19
Source File: Filter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #20
Source File: Filter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #21
Source File: Filter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #22
Source File: Filter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #23
Source File: Filter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #24
Source File: Filter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #25
Source File: Filter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #26
Source File: Filter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static int[] findRightParen(byte[] filter, int filtOffset[], int end)
throws IOException, NamingException {

    int balance = 1;
    boolean escape = false;
    int nextOffset = filtOffset[0];

    while (nextOffset < end && balance > 0) {
        if (!escape) {
            if (filter[nextOffset] == '(')
                balance++;
            else if (filter[nextOffset] == ')')
                balance--;
        }
        if (filter[nextOffset] == '\\' && !escape)
            escape = true;
        else
            escape = false;
        if (balance > 0)
            nextOffset++;
    }
    if (balance != 0) {
        throw new InvalidSearchFilterException("Unbalanced parenthesis");
    }

    // String tmp = filter.substring(filtOffset[0], nextOffset);

    int[] tmp = new int[] {filtOffset[0], nextOffset};

    filtOffset[0] = nextOffset + 1;

    return tmp;

}
 
Example #27
Source File: Filter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void encodeFilterList(BerEncoder ber, byte[] filter,
    int filterType, int start, int end) throws IOException, NamingException {

    if (dbg) {
        dprint("encFilterList: ", filter, start, end);
        dbgIndent++;
    }

    int filtOffset[] = new int[1];
    int listNumber = 0;
    for (filtOffset[0] = start; filtOffset[0] < end; filtOffset[0]++) {
        if (Character.isSpaceChar((char)filter[filtOffset[0]]))
            continue;

        if ((filterType == LDAP_FILTER_NOT) && (listNumber > 0)) {
            throw new InvalidSearchFilterException(
                "Filter (!) cannot be followed by more than one filters");
        }

        if (filter[filtOffset[0]] == '(') {
            continue;
        }

        int[] parens = findRightParen(filter, filtOffset, end);

        // add enclosing parens
        int len = parens[1]-parens[0];
        byte[] newfilter = new byte[len+2];
        System.arraycopy(filter, parens[0], newfilter, 1, len);
        newfilter[0] = (byte)'(';
        newfilter[len+1] = (byte)')';
        encodeFilter(ber, newfilter, 0, newfilter.length);

        listNumber++;
    }

    if (dbg) {
        dbgIndent--;
    }

}
 
Example #28
Source File: Filter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static byte[] unescapeFilterValue(byte[] orig, int start, int end)
    throws NamingException {
    boolean escape = false, escStart = false;
    int ival;
    byte ch;

    if (dbg) {
        dprint("unescape: " , orig, start, end);
    }

    int len = end - start;
    byte tbuf[] = new byte[len];
    int j = 0;
    for (int i = start; i < end; i++) {
        ch = orig[i];
        if (escape) {
            // Try LDAP V3 escape (\xx)
            if ((ival = hexchar2int(ch)) < 0) {

                /**
                 * If there is no hex char following a '\' when
                 * parsing a LDAP v3 filter (illegal by v3 way)
                 * we fallback to the way we unescape in v2.
                 */
                if (escStart) {
                    // V2: \* \( \)
                    escape = false;
                    tbuf[j++] = ch;
                } else {
                    // escaping already started but we can't find 2nd hex
                    throw new InvalidSearchFilterException("invalid escape sequence: " + orig);
                }
            } else {
                if (escStart) {
                    tbuf[j] = (byte)(ival<<4);
                    escStart = false;
                } else {
                    tbuf[j++] |= (byte)ival;
                    escape = false;
                }
            }
        } else if (ch != '\\') {
            tbuf[j++] = ch;
            escape = false;
        } else {
            escStart = escape = true;
        }
    }
    byte[] answer = new byte[j];
    System.arraycopy(tbuf, 0, answer, 0, j);
    if (dbg) {
        Ber.dumpBER(System.err, "", answer, 0, j);
    }
    return answer;
}
 
Example #29
Source File: Filter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static byte[] unescapeFilterValue(byte[] orig, int start, int end)
    throws NamingException {
    boolean escape = false, escStart = false;
    int ival;
    byte ch;

    if (dbg) {
        dprint("unescape: " , orig, start, end);
    }

    int len = end - start;
    byte tbuf[] = new byte[len];
    int j = 0;
    for (int i = start; i < end; i++) {
        ch = orig[i];
        if (escape) {
            // Try LDAP V3 escape (\xx)
            if ((ival = hexchar2int(ch)) < 0) {

                /**
                 * If there is no hex char following a '\' when
                 * parsing a LDAP v3 filter (illegal by v3 way)
                 * we fallback to the way we unescape in v2.
                 */
                if (escStart) {
                    // V2: \* \( \)
                    escape = false;
                    tbuf[j++] = ch;
                } else {
                    // escaping already started but we can't find 2nd hex
                    throw new InvalidSearchFilterException("invalid escape sequence: " + orig);
                }
            } else {
                if (escStart) {
                    tbuf[j] = (byte)(ival<<4);
                    escStart = false;
                } else {
                    tbuf[j++] |= (byte)ival;
                    escape = false;
                }
            }
        } else if (ch != '\\') {
            tbuf[j++] = ch;
            escape = false;
        } else {
            escStart = escape = true;
        }
    }
    byte[] answer = new byte[j];
    System.arraycopy(tbuf, 0, answer, 0, j);
    if (dbg) {
        Ber.dumpBER(System.err, "", answer, 0, j);
    }
    return answer;
}
 
Example #30
Source File: Filter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void encodeFilterList(BerEncoder ber, byte[] filter,
    int filterType, int start, int end) throws IOException, NamingException {

    if (dbg) {
        dprint("encFilterList: ", filter, start, end);
        dbgIndent++;
    }

    int filtOffset[] = new int[1];
    int listNumber = 0;
    for (filtOffset[0] = start; filtOffset[0] < end; filtOffset[0]++) {
        if (Character.isSpaceChar((char)filter[filtOffset[0]]))
            continue;

        if ((filterType == LDAP_FILTER_NOT) && (listNumber > 0)) {
            throw new InvalidSearchFilterException(
                "Filter (!) cannot be followed by more than one filters");
        }

        if (filter[filtOffset[0]] == '(') {
            continue;
        }

        int[] parens = findRightParen(filter, filtOffset, end);

        // add enclosing parens
        int len = parens[1]-parens[0];
        byte[] newfilter = new byte[len+2];
        System.arraycopy(filter, parens[0], newfilter, 1, len);
        newfilter[0] = (byte)'(';
        newfilter[len+1] = (byte)')';
        encodeFilter(ber, newfilter, 0, newfilter.length);

        listNumber++;
    }

    if (dbg) {
        dbgIndent--;
    }

}