Package com.isode.dsapi.util
Class LDAPFilter
java.lang.Object
com.isode.dsapi.util.LDAPFilter
LDAP Filter validation, querying and conversion to other formats;
see RFC4515. Accepts 'extensible' matching rules now. Validates
attribute value wildcards and escapes. Doesn't validate attribute
type or OID syntax or options. Doesn't validate attribute values
against attribute type.
In non-strict mode, accepts whitespace in some places when parsing, but when the filter is rewritten with toString(), these will be stripped out. Also removes redundancy from the filter -- if there is an AND or OR operation with a list of just one item, it is substituted with that one item.
A plain-language version of the filter can be fetched with toPlainLangString(). This has less parentheses and uses 'and', 'or' and 'not' between the expressions.
- Author:
- jp
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
Tri-state boolean for filter evaluation.static enum
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLDAPFilter
(String filter_str) Construct an LDAPFilter instance from an LDAP filter string, using strict parsing.LDAPFilter
(String filter_str, boolean strict) Construct an LDAPFilter instance from an LDAP filter string. -
Method Summary
Modifier and TypeMethodDescriptionEvaluate the filter expression on the given Entry.Evaluate the filter expression on the given MapEntry.Output the filter in plain-language format (i.e.toPlainLangString
(boolean mark) Output the filter in plain-language format (i.e.toString()
Reconstruct the filter into an LDAP string, with no excess white space.
-
Field Details
-
operations
-
filter
The LDAP filter top-level Expression
-
-
Constructor Details
-
LDAPFilter
Construct an LDAPFilter instance from an LDAP filter string, using strict parsing.- Parameters:
filter_str
- String to parse- Throws:
ParseException
-
LDAPFilter
Construct an LDAPFilter instance from an LDAP filter string. Excess white space is accepted but stripped out if 'strict' is false.- Parameters:
filter_str
- String to parsestrict
- 'true' to be strict, and complain about spaces where they're not allowed. 'false' to be flexible and to allow certain errors, and to clean them up when toString() is called.- Throws:
ParseException
-
-
Method Details
-
toPlainLangString
Output the filter in plain-language format (i.e. as it might be read in English) -
toPlainLangString
Output the filter in plain-language format (i.e. as it might be read in English), optionally marking some parts as bold. Bold is used for the matching expressions, and normal for everything else.- Parameters:
mark
- Mark text as bold or normal, using NUL ( ) to separate bold and normal parts. Text starts out in normal.
-
toString
Reconstruct the filter into an LDAP string, with no excess white space. -
evaluate
Evaluate the filter expression on the given Entry. There are a number of limitations, which might be removed later on:- Extensible matching is not supported
- Approximate matching is treated the same as an exact match
- Only the exact attributes mentioned will be tested: subtypes are not currently searched for.
- Only string values can be compared, not binary or BER values.
- Case-insensitive substring matching is supported in a slightly backwards way: if the lowercased version of the value compares the same as the uppercased version through DSAPI's comparison code, then it is assumed that it is okay to do a case-insensitive match in Java. The code make no attempt to handle any other folding that might be done by the syntax.
See X.511 section 7.8.1 onwards for evaluation rules.
-
evaluate
Evaluate the filter expression on the given MapEntry. There are a number of limitations, which might be removed later on:- Extensible matching is not supported
- Approximate matching is treated the same as an exact match
- Only the exact attributes mentioned will be tested: subtypes are not currently searched for.
- Only string values can be compared, not binary or BER values.
- Case-insensitive substring matching is supported in a slightly backwards way: if the lowercased version of the value compares the same as the uppercased version through DSAPI's comparison code, then it is assumed that it is okay to do a case-insensitive match in Java. The code make no attempt to handle any other folding that might be done by the syntax.
See X.511 section 7.8.1 onwards for evaluation rules.
-