Fix issue 1531: Improper filter allowed in targattrfilters argument.
| | |
| | | MSGID_ACI_SYNTAX_INVALID_TARGATTRFILTERS_FILTER_LISTS_FILTER, |
| | | "The provided Access Control Instruction (ACI) " + |
| | | "targattrfilters expression value " + |
| | | "%s is invalid because the one or more of the specified" + |
| | | "%s is invalid because one or more of the specified " + |
| | | "filters are invalid for the following reason: " + |
| | | "%s"); |
| | | |
| | |
| | | MSGID_ACI_SYNTAX_INVALID_TARGATTRFILTERS_FILTER_LISTS_ATTR_FILTER, |
| | | "The provided Access Control Instruction (ACI) " + |
| | | "targattrfilters expression value " + |
| | | "%s is invalid because the one or more of the specified" + |
| | | "%s is invalid because one or more of the specified " + |
| | | "filters are invalid because of non-matching attribute" + |
| | | "type names in the filter"); |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if a NOT filter does not |
| | | * contain exactly one filter component. This takes three arguments, which |
| | | * are the filter string and the start and end position of the NOT filter. |
| | | */ |
| | | public static final int MSGID_SEARCH_FILTER_NOT_EXACTLY_ONE = |
| | | CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_MILD_ERROR | 602; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Associates a set of generic messages with the message IDs defined |
| | | * in this class. |
| | | */ |
| | |
| | | "because the extensible match component starting at " + |
| | | "position %d did not have a colon to denote the end of " + |
| | | "the attribute type name"); |
| | | registerMessage(MSGID_SEARCH_FILTER_NOT_EXACTLY_ONE, |
| | | "The provided search filter \"%s\" could not be decoded " + |
| | | "because the NOT filter between positions %d and %d " + |
| | | "did not contain exactly one filter component"); |
| | | registerMessage(MSGID_SEARCH_FILTER_INVALID_FILTER_TYPE, |
| | | "Unable to determine whether entry \"%s\" matches filter " + |
| | | "\"%s\" because it contained an unknown filter type %s"); |
| | |
| | | public static final int MSGID_LDAPS_CONNHANDLER_DESCRIPTION_ENABLE = |
| | | CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_INFORMATIONAL | 404; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The message ID for the message that will be used if a NOT filter does not |
| | | * contain exactly one filter component. This takes three arguments, which |
| | | * are the filter string and the start and end position of the NOT filter. |
| | | */ |
| | | public static final int MSGID_LDAP_FILTER_NOT_EXACTLY_ONE = |
| | | CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_MILD_ERROR | 405; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Associates a set of generic messages with the message IDs defined in this |
| | | * class. |
| | |
| | | "because the extensible match component starting at " + |
| | | "position %d did not have a colon to denote the end of " + |
| | | "the attribute type name"); |
| | | registerMessage(MSGID_LDAP_FILTER_NOT_EXACTLY_ONE, |
| | | "The provided search filter \"%s\" could not be decoded " + |
| | | "because the NOT filter between positions %d and %d " + |
| | | "did not contain exactly one filter component"); |
| | | |
| | | |
| | | registerMessage(MSGID_LDAP_CLIENT_SEND_RESPONSE_NO_RESULT_CODE, |
| | |
| | | } |
| | | else if (c == '!') |
| | | { |
| | | LDAPFilter notComponent = decode(filterString, startPos+1, endPos); |
| | | return new LDAPFilter(FilterType.NOT, null, notComponent, null, null, |
| | | null, null, null, null, false); |
| | | return decodeCompoundFilter(FilterType.NOT, filterString, startPos+1, |
| | | endPos); |
| | | } |
| | | |
| | | |
| | |
| | | * indicated range. |
| | | * |
| | | * @param filterType The filter type for this compound filter. It must be |
| | | * either an AND or an OR filter. |
| | | * an AND, OR or NOT filter. |
| | | * @param filterString The string containing the filter information to |
| | | * decode. |
| | | * @param startPos The position of the first character in the set of |
| | |
| | | |
| | | |
| | | // If the end pos is equal to the start pos, then there are no components. |
| | | // This is valid and will be treated as a TRUE/FALSE filter. |
| | | if (startPos == endPos) |
| | | { |
| | | if (filterType == FilterType.NOT) |
| | | { |
| | | int msgID = MSGID_LDAP_FILTER_NOT_EXACTLY_ONE; |
| | | String message = getMessage(msgID, filterString, startPos, endPos); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | } |
| | | else |
| | | { |
| | | // This is valid and will be treated as a TRUE/FALSE filter. |
| | | return new LDAPFilter(filterType, filterComponents, null, null, null, |
| | | null, null, null, null, false); |
| | | } |
| | | } |
| | | |
| | | |
| | | // The first and last characters must be parentheses. If not, then that's |
| | |
| | | |
| | | |
| | | // We should have everything we need, so return the list. |
| | | return new LDAPFilter(filterType, filterComponents, null, null, null, null, |
| | | null, null, null, false); |
| | | if (filterType == FilterType.NOT) |
| | | { |
| | | if (filterComponents.size() != 1) |
| | | { |
| | | int msgID = MSGID_LDAP_FILTER_NOT_EXACTLY_ONE; |
| | | String message = getMessage(msgID, filterString, startPos, endPos); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | } |
| | | RawFilter notComponent = filterComponents.get(0); |
| | | return new LDAPFilter(filterType, null, notComponent, null, null, |
| | | null, null, null, null, false); |
| | | } |
| | | else |
| | | { |
| | | return new LDAPFilter(filterType, filterComponents, null, null, null, |
| | | null, null, null, null, false); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | else if (c == '!') |
| | | { |
| | | SearchFilter notComponent = createFilterFromString(filterString, |
| | | return decodeCompoundFilter(FilterType.NOT, filterString, |
| | | startPos+1, endPos); |
| | | return new SearchFilter(FilterType.NOT, null, notComponent, |
| | | null, null, null, null, null, null, |
| | | null, false); |
| | | } |
| | | |
| | | |
| | |
| | | * the indicated range. |
| | | * |
| | | * @param filterType The filter type for this compound filter. |
| | | * It must be either an AND or an OR filter. |
| | | * It must be an AND, OR or NOT filter. |
| | | * @param filterString The string containing the filter |
| | | * information to decode. |
| | | * @param startPos The position of the first character in the |
| | |
| | | |
| | | |
| | | // If the end pos is equal to the start pos, then there are no |
| | | // components. This is valid and will be treated as a TRUE/FALSE |
| | | // filter. |
| | | // components. |
| | | if (startPos == endPos) |
| | | { |
| | | if (filterType == FilterType.NOT) |
| | | { |
| | | int msgID = MSGID_SEARCH_FILTER_NOT_EXACTLY_ONE; |
| | | String message = getMessage(msgID, filterString, startPos, |
| | | endPos); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | message, msgID); |
| | | } |
| | | else |
| | | { |
| | | // This is valid and will be treated as a TRUE/FALSE filter. |
| | | return new SearchFilter(filterType, filterComponents, null, |
| | | null, null, null, null, null, null, |
| | | null, false); |
| | | } |
| | | } |
| | | |
| | | |
| | | // The first and last characters must be parentheses. If not, |
| | |
| | | |
| | | |
| | | // We should have everything we need, so return the list. |
| | | return new SearchFilter(filterType, filterComponents, null, null, |
| | | if (filterType == FilterType.NOT) |
| | | { |
| | | if (filterComponents.size() != 1) |
| | | { |
| | | int msgID = MSGID_SEARCH_FILTER_NOT_EXACTLY_ONE; |
| | | String message = getMessage(msgID, filterString, startPos, |
| | | endPos); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | message, msgID); |
| | | } |
| | | SearchFilter notComponent = filterComponents.get(0); |
| | | return new SearchFilter(filterType, null, notComponent, null, |
| | | null, null, null, null, null, null, |
| | | false); |
| | | } |
| | | |
| | | else |
| | | { |
| | | return new SearchFilter(filterType, filterComponents, null, |
| | | null, null, null, null, null, null, |
| | | null, false); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | { "(&(givenname=bob)|(sn=pep)dob=12))", null }, |
| | | { "(:=bob)", null }, |
| | | { "(=sally)", null }, |
| | | { "(cn=billy bob", null } |
| | | { "(cn=billy bob", null }, |
| | | { "(|(!(title=sweep*)(l=Paris*)))", null }, |
| | | { "(|(!))", null }, |
| | | |
| | | }; |
| | | } |
| | |
| | | {"(!(sn=test)"}, |
| | | {"(&(sn=test)))"}, |
| | | {"(|(sn=test)))"}, |
| | | // TODO: open a bug for this. |
| | | // {"(!(sn=test)))"}, |
| | | {"(!(sn=test)))"}, |
| | | {"(sn=\\A)"}, |
| | | {"(sn=\\1H)"}, |
| | | {"(sn=\\H1)"}, |
| | | {"(!(sn=test)(cn=test))"}, |
| | | {"(!)"}, |
| | | }; |
| | | } |
| | | |