Skip to content
Snippets Groups Projects

Full schema support

Files

@@ -59,6 +59,31 @@ class StringMatchingRule(MatchingRule):
@@ -59,6 +59,31 @@ class StringMatchingRule(MatchingRule):
else:
else:
return FilterResult.FALSE
return FilterResult.FALSE
 
def match_substr(self, attribute_value, inital_substring, any_substrings, final_substring):
 
try:
 
attribute_value = rfc4518_stringprep.prepare(attribute_value, self.matching_type)
 
if inital_substring:
 
inital_substring = rfc4518_stringprep.prepare(inital_substring, self.matching_type, rfc4518_stringprep.SubstringType.INITIAL)
 
any_substrings = [rfc4518_stringprep.prepare(substring, self.matching_type, rfc4518_stringprep.SubstringType.ANY) for substring in any_substrings]
 
if final_substring:
 
final_substring = rfc4518_stringprep.prepare(final_substring, self.matching_type, rfc4518_stringprep.SubstringType.FINAL)
 
except ValueError:
 
return FilterResult.UNDEFINED
 
if inital_substring:
 
if not attribute_value.startswith(inital_substring):
 
return FilterResult.FALSE
 
attribute_value = attribute_value[len(inital_substring):]
 
if final_substring:
 
if not attribute_value.endswith(final_substring):
 
return FilterResult.FALSE
 
attribute_value = attribute_value[:-len(final_substring)]
 
for substring in any_substrings:
 
index = attribute_value.find(substring)
 
if index == -1:
 
return FilterResult.FALSE
 
attribute_value = attribute_value[index+len(substring):]
 
return FilterResult.TRUE
 
class StringListMatchingRule(MatchingRule):
class StringListMatchingRule(MatchingRule):
def __init__(self, oid, name, syntax, matching_type=rfc4518_stringprep.MatchingType.EXACT_STRING):
def __init__(self, oid, name, syntax, matching_type=rfc4518_stringprep.MatchingType.EXACT_STRING):
super().__init__(oid, name, syntax)
super().__init__(oid, name, syntax)
@@ -132,7 +157,7 @@ ALL = (
@@ -132,7 +157,7 @@ ALL = (
integerFirstComponentMatch,
integerFirstComponentMatch,
integerMatch,
integerMatch,
integerOrderingMatch,
integerOrderingMatch,
keywordMatch,
#keywordMatch,
numericStringMatch,
numericStringMatch,
numericStringOrderingMatch,
numericStringOrderingMatch,
numericStringSubstringsMatch,
numericStringSubstringsMatch,
@@ -143,5 +168,5 @@ ALL = (
@@ -143,5 +168,5 @@ ALL = (
telephoneNumberMatch,
telephoneNumberMatch,
telephoneNumberSubstringsMatch,
telephoneNumberSubstringsMatch,
uniqueMemberMatch,
uniqueMemberMatch,
wordMatch,
#wordMatch,
)
)
Loading