Package javax.naming.directory

Examples of javax.naming.directory.InvalidSearchFilterException


        {
            filterNode = FilterParser.parse( schemaManager, filter );
        }
        catch ( ParseException pe )
        {
            InvalidSearchFilterException isfe = new InvalidSearchFilterException( I18n.err( I18n.ERR_500, filter ) );
            isfe.setRootCause( pe );
            throw isfe;
        }

        AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() );
View Full Code Here


        {
            filterNode = FilterParser.parse( schemaManager, filter );
        }
        catch ( ParseException pe )
        {
            InvalidSearchFilterException isfe = new InvalidSearchFilterException( I18n.err( I18n.ERR_500, filter ) );
            isfe.setRootCause( pe );
            throw isfe;
        }

        AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() );
View Full Code Here

        if (null == subschemasubentry) {
            filterParser = new FilterParser("(objectClass=*)");
            try {
                filter = filterParser.parse();
            } catch (ParseException e) {
                InvalidSearchFilterException ex = new InvalidSearchFilterException(
                        Messages.getString("ldap.29")); //$NON-NLS-1$
                ex.setRootCause(e);
                throw ex;
            }

            searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
            searchControls.setReturningAttributes(new String[] {
                    "namingContexts", "subschemaSubentry", "altServer", });
            search = new SearchOp(name.toString(), searchControls, filter);
            search.setBatchSize(0);
            try {
                client.doOperation(search, requestControls);
            } catch (IOException e) {
                CommunicationException ex = new CommunicationException(e
                        .getMessage());
                ex.setRootCause(e);
                if (search.getSearchResult().isEmpty()) {
                    throw ex;
                }
                search.getSearchResult().setException(ex);
            }

            sre = search.getSearchResult();
            names = sre.getEntries();

            keyset = names.keySet();

            schemaRoot: for (Iterator<String> iterator = keyset.iterator(); iterator
                    .hasNext();) {
                String key = iterator.next();
                Attributes as = names.get(key);
                NamingEnumeration<String> ids = as.getIDs();
                while (ids.hasMore()) {
                    String id = ids.next();
                    if (id.equalsIgnoreCase("subschemasubentry")) {
                        subschemasubentry = (String) as.get(id).get();
                        break schemaRoot;
                    }
                }
            }
        }

        if (null == subschemasubentry) {
            return getSchema(name.getPrefix(name.size() - 1));
        }

        searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
        searchControls.setReturningAttributes(new String[] { "objectclasses",
                "attributetypes", "matchingrules", "ldapsyntaxes" });
        searchControls.setReturningObjFlag(true);
        filterParser = new FilterParser("(objectClass=subschema)");
        try {
            filter = filterParser.parse();
        } catch (ParseException e) {
            InvalidSearchFilterException ex = new InvalidSearchFilterException(
                    Messages.getString("ldap.29")); //$NON-NLS-1$
            ex.setRootCause(e);
            throw ex;
        }
        search = new SearchOp(subschemasubentry, searchControls, filter);
        search.setBatchSize(0);
        try {
            client.doOperation(search, requestControls);
        } catch (IOException e) {
            CommunicationException ex = new CommunicationException(e
                    .getMessage());
            ex.setRootCause(e);
            if (search.getSearchResult().isEmpty()) {
                throw ex;
            }
            search.getSearchResult().setException(ex);
        }
View Full Code Here

            FilterParser commonFilterParser = new FilterParser(filterValue);
            commonFilterParser.setArgs(filterArgs);
            commonFilter = commonFilterParser.parse();
        } catch (ParseException e) {
            // ldap.29=Invalid search filter
            throw new InvalidSearchFilterException(Messages
                    .getString("ldap.29")); //$NON-NLS-1$
        }
    }
View Full Code Here

       
        try {
            return parser.parse();
        } catch (ParseException e) {
            // ldap.29=Invalid search filter
            InvalidSearchFilterException ex = new InvalidSearchFilterException(
                    Messages.getString("ldap.29")); //$NON-NLS-1$
            ex.setRootCause(e);
            throw ex;
        }
    }
View Full Code Here

        {
            ne = new InvalidNameException( t.getLocalizedMessage() );
        }
        else if ( t instanceof LdapInvalidSearchFilterException )
        {
            ne = new InvalidSearchFilterException( t.getLocalizedMessage() );
        }
        else if ( t instanceof LdapLoopDetectedException )
        {
            ne = new NamingException( t.getLocalizedMessage() );
        }
View Full Code Here

        if (null == subschemasubentry) {
            filterParser = new FilterParser("(objectClass=*)");
            try {
                filter = filterParser.parse();
            } catch (ParseException e) {
                InvalidSearchFilterException ex = new InvalidSearchFilterException(
                        Messages.getString("ldap.29")); //$NON-NLS-1$
                ex.setRootCause(e);
                throw ex;
            }

            searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
            searchControls.setReturningAttributes(new String[] {
                    "namingContexts", "subschemaSubentry", "altServer", });
            search = new SearchOp(name.toString(), searchControls, filter);

            try {
                client.doOperation(search, requestControls);
            } catch (IOException e) {
                CommunicationException ex = new CommunicationException(e
                        .getMessage());
                ex.setRootCause(e);
                if (search.getSearchResult().isEmpty()) {
                    throw ex;
                }
                search.getSearchResult().setException(ex);
            }

            sre = search.getSearchResult();
            names = sre.getEntries();

            keyset = names.keySet();

            schemaRoot: for (Iterator<String> iterator = keyset.iterator(); iterator
                    .hasNext();) {
                String key = iterator.next();
                Attributes as = names.get(key);
                NamingEnumeration<String> ids = as.getIDs();
                while (ids.hasMore()) {
                    String id = ids.next();
                    if (id.equalsIgnoreCase("subschemasubentry")) {
                        subschemasubentry = (String) as.get(id).get();
                        break schemaRoot;
                    }
                }
            }
        }

        if (null == subschemasubentry) {
            return getSchema(name.getPrefix(name.size() - 1));
        }

        searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
        searchControls.setReturningAttributes(new String[] { "objectclasses",
                "attributetypes", "matchingrules", "ldapsyntaxes" });
        searchControls.setReturningObjFlag(true);
        filterParser = new FilterParser("(objectClass=subschema)");
        try {
            filter = filterParser.parse();
        } catch (ParseException e) {
            InvalidSearchFilterException ex = new InvalidSearchFilterException(
                    Messages.getString("ldap.29")); //$NON-NLS-1$
            ex.setRootCause(e);
            throw ex;
        }
        search = new SearchOp(subschemasubentry, searchControls, filter);

        try {
            client.doOperation(search, requestControls);
        } catch (IOException e) {
            CommunicationException ex = new CommunicationException(e
                    .getMessage());
            ex.setRootCause(e);
            if (search.getSearchResult().isEmpty()) {
                throw ex;
            }
            search.getSearchResult().setException(ex);
        }
View Full Code Here

                filterNode = parser.parse( filter );
            }
            catch ( ParseException pe )
            {
                InvalidSearchFilterException isfe =
                    new InvalidSearchFilterException (
                    "Encountered parse exception while parsing the filter: '"
                    + filter + "'" );

                isfe.setRootCause( pe );

                throw isfe;
            }
            catch ( IOException ioe )
            {
View Full Code Here

     */
    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");
View Full Code Here

            dprint("encFilter: ",  filter, filterStart, filterEnd);
            dbgIndent++;
        }

        if ((filterEnd - filterStart) <= 0) {
            throw new InvalidSearchFilterException("Empty filter");
        }

        int nextOffset;
        int parens, balance;
        boolean escape;

        parens = 0;

        int filtOffset[] = new int[1];

        for (filtOffset[0] = filterStart; filtOffset[0] < filterEnd;) {
            switch (filter[filtOffset[0]]) {
            case '(':
                filtOffset[0]++;
                parens++;
                switch (filter[filtOffset[0]]) {
                case '&':
                    encodeComplexFilter(ber, filter,
                        LDAP_FILTER_AND, filtOffset, filterEnd);
                    // filtOffset[0] has pointed to char after right paren
                    parens--;
                    break;

                case '|':
                    encodeComplexFilter(ber, filter,
                        LDAP_FILTER_OR, filtOffset, filterEnd);
                    // filtOffset[0] has pointed to char after right paren
                    parens--;
                    break;

                case '!':
                    encodeComplexFilter(ber, filter,
                        LDAP_FILTER_NOT, filtOffset, filterEnd);
                    // filtOffset[0] has pointed to char after right paren
                    parens--;
                    break;

                default:
                    balance = 1;
                    escape = false;
                    nextOffset = filtOffset[0];
                    while (nextOffset < filterEnd && 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");

                    encodeSimpleFilter(ber, filter, filtOffset[0], nextOffset);

                    // points to the char after right paren.
                    filtOffset[0] = nextOffset + 1;

                    parens--;
                    break;

                }
                break;

            case ')':
                //
                // End of sequence
                //
                ber.endSeq();
                filtOffset[0]++;
                parens--;
                break;

            case ' ':
                filtOffset[0]++;
                break;

            default:    // assume simple type=value filter
                encodeSimpleFilter(ber, filter, filtOffset[0], filterEnd);
                filtOffset[0] = filterEnd; // force break from outer
                break;
            }

            if (parens < 0) {
                throw new InvalidSearchFilterException(
                                                "Unbalanced parenthesis");
            }
        }

        if (parens != 0) {
            throw new InvalidSearchFilterException("Unbalanced parenthesis");
        }

        if (dbg) {
            dbgIndent--;
        }
View Full Code Here

TOP

Related Classes of javax.naming.directory.InvalidSearchFilterException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.