public final class FilterParser extends Object
| Modifier | Constructor and Description |
|---|---|
private |
FilterParser() |
| Modifier and Type | Method and Description |
|---|---|
static ExprNode |
parse(byte[] filter) |
static ExprNode |
parse(SchemaManager schemaManager,
byte[] filter) |
private static ExprNode |
parse(SchemaManager schemaManager,
byte[] filter,
boolean relaxed) |
static ExprNode |
parse(SchemaManager schemaManager,
String filter) |
static ExprNode |
parse(SchemaManager schemaManager,
String filter,
org.apache.directory.api.util.Position pos) |
static ExprNode |
parse(String filter)
Parses a search filter from it's string representation to an expression node object.
|
static ExprNode |
parse(String filter,
boolean relaxed)
Parses a search filter from it's string representation to an expression node object.
|
private static Value<?> |
parseAssertionValue(SchemaManager schemaManager,
byte[] filter,
org.apache.directory.api.util.Position pos)
An assertion value :
assertionvalue = valueencoding
valueencoding = 0*(normal / escaped)
normal = UTF1SUBSET / UTFMB
escaped = '\' HEX HEX
HEX = '0'-'9' / 'A'-'F' / 'a'-'f'
UTF1SUBSET = %x01-27 / %x2B-5B / %x5D-7F (Everything but '\0', '*', '(', ')' and '\')
UTFMB = UTF2 / UTF3 / UTF4
UTF0 = %x80-BF
UTF2 = %xC2-DF UTF0
UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC UTF0 UTF0 / %xED %x80-9F UTF0 / %xEE-EF UTF0 UTF0
UTF4 = %xF0 %x90-BF UTF0 UTF0 / %xF1-F3 UTF0 UTF0 UTF0 / %xF4 %x80-8F UTF0 UTF0
With the specific constraints (RFC 4515):
"The
|
private static Value<?> |
parseAssertionValue(SchemaManager schemaManager,
String attribute,
byte[] filter,
org.apache.directory.api.util.Position pos)
An assertion value :
assertionvalue = valueencoding
valueencoding = 0*(normal / escaped)
normal = UTF1SUBSET / UTFMB
escaped = '\' HEX HEX
HEX = '0'-'9' / 'A'-'F' / 'a'-'f'
UTF1SUBSET = %x01-27 / %x2B-5B / %x5D-7F (Everything but '\0', '*', '(', ')' and '\')
UTFMB = UTF2 / UTF3 / UTF4
UTF0 = %x80-BF
UTF2 = %xC2-DF UTF0
UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC UTF0 UTF0 / %xED %x80-9F UTF0 / %xEE-EF UTF0 UTF0
UTF4 = %xF0 %x90-BF UTF0 UTF0 / %xF1-F3 UTF0 UTF0 UTF0 / %xF4 %x80-8F UTF0 UTF0
With the specific constraints (RFC 4515):
"The
|
private static ExprNode |
parseBranchNode(SchemaManager schemaManager,
ExprNode node,
byte[] filter,
org.apache.directory.api.util.Position pos,
boolean relaxed)
Parse AND, OR and NOT nodes :
and = '&' filterlist
or = '|' filterlist
not = '!' filter
filterlist = 1*filter
|
private static ExprNode |
parseExtensible(SchemaManager schemaManager,
String attribute,
byte[] filter,
org.apache.directory.api.util.Position pos,
boolean relaxed)
Parse an extensible
extensible = ( attr [":dn"] [':' oid] ":=" assertionvalue )
/ ( [":dn"] ':' oid ":=" assertionvalue )
matchingrule = ":" oid
|
private static ExprNode |
parseFilterComp(SchemaManager schemaManager,
byte[] filter,
org.apache.directory.api.util.Position pos,
boolean relaxed)
filtercomp = and / or / not / item
and = '&' WSP* filterlist
or = '|' WSP* filterlist
not = '!' WSP* filter
item = simple / present / substring / extensible
simple = attr WSP* filtertype WSP* assertionvalue
present = attr WSP* EQUALS ASTERISK
substring = attr WSP* EQUALS WSP* [initial] any [final]
extensible = ( attr [dnattrs]
[matchingrule] COLON EQUALS assertionvalue )
/ ( [dnattrs]
matchingrule COLON EQUALS assertionvalue )
|
private static ExprNode |
parseFilterInternal(SchemaManager schemaManager,
byte[] filter,
org.apache.directory.api.util.Position pos,
boolean relaxed)
Parse the grammar rule :
filter ::= WSP* '(' WSP* filterComp WSP* ')' WSP*
|
private static ExprNode |
parseItem(SchemaManager schemaManager,
byte[] filter,
org.apache.directory.api.util.Position pos,
byte b,
boolean relaxed)
Parse the following grammar :
item = simple / present / substring / extensible
simple = attr WSP* filtertype assertionvalue
filtertype = '=' / '~=' / '>=' / '<='
present = attr WSP* '=' '*'
substring = attr WSP* '=' [initial] any [final]
extensible = ( attr [":dn"] [':' oid] ":=" assertionvalue )
/ ( [":dn"] ':' oid ":=" assertionvalue )
matchingrule = ":" oid
An item starts with an attribute or a colon.
|
private static ExprNode |
parsePresenceEqOrSubstring(SchemaManager schemaManager,
String attribute,
byte[] filter,
org.apache.directory.api.util.Position pos)
Here is the grammar to parse :
simple ::= '=' assertionValue
present ::= '=' '*'
substring ::= '=' [initial] any [final]
initial ::= assertionValue
any ::= '*' ( assertionValue '*')*
As we can see, there is an ambiguity in the grammar : attr=* can be
seen as a present or as a substring.
|
private static ExprNode |
parseSubstring(SchemaManager schemaManager,
String attribute,
Value<?> initial,
byte[] filter,
org.apache.directory.api.util.Position pos)
Parse a substring
|
private static void |
skipWhiteSpaces(byte[] filter,
org.apache.directory.api.util.Position pos)
Skip teh white spaces (0x20, 0x09, 0x0a and 0x0d)
|
private static ExprNode parseExtensible(SchemaManager schemaManager, String attribute, byte[] filter, org.apache.directory.api.util.Position pos, boolean relaxed) throws LdapException, ParseException
LdapExceptionParseExceptionprivate static Value<?> parseAssertionValue(SchemaManager schemaManager, String attribute, byte[] filter, org.apache.directory.api.util.Position pos) throws ParseException
LdapInvalidAttributeValueExceptionParseExceptionprivate static Value<?> parseAssertionValue(SchemaManager schemaManager, byte[] filter, org.apache.directory.api.util.Position pos) throws ParseException
ParseExceptionprivate static ExprNode parseSubstring(SchemaManager schemaManager, String attribute, Value<?> initial, byte[] filter, org.apache.directory.api.util.Position pos) throws ParseException, LdapException
ParseExceptionLdapExceptionprivate static ExprNode parsePresenceEqOrSubstring(SchemaManager schemaManager, String attribute, byte[] filter, org.apache.directory.api.util.Position pos) throws ParseException, LdapException
attributeType - filter - pos - ParseExceptionLdapExceptionprivate static ExprNode parseItem(SchemaManager schemaManager, byte[] filter, org.apache.directory.api.util.Position pos, byte b, boolean relaxed) throws ParseException, LdapException
ParseExceptionLdapExceptionprivate static ExprNode parseBranchNode(SchemaManager schemaManager, ExprNode node, byte[] filter, org.apache.directory.api.util.Position pos, boolean relaxed) throws ParseException, LdapException
ParseExceptionLdapExceptionprivate static ExprNode parseFilterComp(SchemaManager schemaManager, byte[] filter, org.apache.directory.api.util.Position pos, boolean relaxed) throws ParseException, LdapException
ParseExceptionLdapExceptionprivate static void skipWhiteSpaces(byte[] filter,
org.apache.directory.api.util.Position pos)
filter - pos - private static ExprNode parseFilterInternal(SchemaManager schemaManager, byte[] filter, org.apache.directory.api.util.Position pos, boolean relaxed) throws ParseException, LdapException
ParseExceptionLdapExceptionpublic static ExprNode parse(String filter) throws ParseException
filter - the search filter in it's string representationParseException - If the filter is invalidpublic static ExprNode parse(byte[] filter) throws ParseException
filter - the search filter in it's string representationParseException - If the filter is invalidparse(String)public static ExprNode parse(SchemaManager schemaManager, String filter) throws ParseException
schemaManager - The SchemaManagerfilter - the search filter in it's string representationParseException - If the filter is invalidparse(String)public static ExprNode parse(SchemaManager schemaManager, byte[] filter) throws ParseException
schemaManager - The SchemaManagerfilter - the search filter in it's string representationParseException - If the filter is invalidparse(String)private static ExprNode parse(SchemaManager schemaManager, byte[] filter, boolean relaxed) throws ParseException
ParseExceptionpublic static ExprNode parse(SchemaManager schemaManager, String filter, org.apache.directory.api.util.Position pos) throws ParseException
schemaManager - The SchemaManagerfilter - the search filter in it's string representationpos - The position in the filterParseException - If the filter is invalidparse(String)public static ExprNode parse(String filter, boolean relaxed) throws ParseException
relaxed mode the filter may violate RFC 4515, e.g. the underscore in attribute names is allowed.filter - the search filter in it's string representationrelaxed - true to parse the filter in relaxed modeParseException - If the filter is invalidCopyright © 2003–2017 The Apache Software Foundation. All rights reserved.