diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-07-07 01:49:33 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:09:26 +0200 |
commit | 563fc272a36c8be317fbe95c8308ca2dfa29c3aa (patch) | |
tree | 0b6f9a6a15516e7234fc928ecbebbd32d3154074 /goldap/filter.go | |
parent | aa912b5ceb24cb8772709171ea9589b0771bbe54 (diff) | |
download | bottin-563fc272a36c8be317fbe95c8308ca2dfa29c3aa.tar.gz bottin-563fc272a36c8be317fbe95c8308ca2dfa29c3aa.zip |
Vendor goldap, fix ASN.1 BER integer and length encoding
- Add tests for goldap to prevent regressions
- Disable reconnection for our functional tests
Diffstat (limited to 'goldap/filter.go')
-rw-r--r-- | goldap/filter.go | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/goldap/filter.go b/goldap/filter.go new file mode 100644 index 0000000..ba045ad --- /dev/null +++ b/goldap/filter.go @@ -0,0 +1,70 @@ +package message + +import "fmt" + +// +// Filter ::= CHOICE { +// and [0] SET SIZE (1..MAX) OF filter Filter, +// or [1] SET SIZE (1..MAX) OF filter Filter, +// not [2] Filter, +// equalityMatch [3] AttributeValueAssertion, +// +// +// +//Sermersheim Standards Track [Page 57] +// +// +//RFC 4511 LDAPv3 June 2006 +// +// +// substrings [4] SubstringFilter, +// greaterOrEqual [5] AttributeValueAssertion, +// lessOrEqual [6] AttributeValueAssertion, +// present [7] AttributeDescription, +// approxMatch [8] AttributeValueAssertion, +// extensibleMatch [9] MatchingRuleAssertion, +// ... } + +func readFilter(bytes *Bytes) (filter Filter, err error) { + var tagAndLength TagAndLength + tagAndLength, err = bytes.PreviewTagAndLength() + if err != nil { + err = LdapError{fmt.Sprintf("readFilter:\n%s", err.Error())} + return + } + err = tagAndLength.ExpectClass(classContextSpecific) + if err != nil { + err = LdapError{fmt.Sprintf("readFilter:\n%s", err.Error())} + return + } + switch tagAndLength.Tag { + case TagFilterAnd: + filter, err = readFilterAnd(bytes) + case TagFilterOr: + filter, err = readFilterOr(bytes) + case TagFilterNot: + filter, err = readFilterNot(bytes) + case TagFilterEqualityMatch: + filter, err = readFilterEqualityMatch(bytes) + case TagFilterSubstrings: + filter, err = readFilterSubstrings(bytes) + case TagFilterGreaterOrEqual: + filter, err = readFilterGreaterOrEqual(bytes) + case TagFilterLessOrEqual: + filter, err = readFilterLessOrEqual(bytes) + case TagFilterPresent: + filter, err = readFilterPresent(bytes) + case TagFilterApproxMatch: + filter, err = readFilterApproxMatch(bytes) + case TagFilterExtensibleMatch: + filter, err = readFilterExtensibleMatch(bytes) + default: + err = LdapError{fmt.Sprintf("readFilter: invalid tag value %d for filter", tagAndLength.Tag)} + return + } + if err != nil { + err = LdapError{fmt.Sprintf("readFilter:\n%s", err.Error())} + return + } + return +} |