aboutsummaryrefslogtreecommitdiff
path: root/goldap/extended_request.go
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2021-07-07 01:49:33 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2021-09-16 13:09:26 +0200
commit563fc272a36c8be317fbe95c8308ca2dfa29c3aa (patch)
tree0b6f9a6a15516e7234fc928ecbebbd32d3154074 /goldap/extended_request.go
parentaa912b5ceb24cb8772709171ea9589b0771bbe54 (diff)
downloadbottin-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/extended_request.go')
-rw-r--r--goldap/extended_request.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/goldap/extended_request.go b/goldap/extended_request.go
new file mode 100644
index 0000000..983ebf9
--- /dev/null
+++ b/goldap/extended_request.go
@@ -0,0 +1,69 @@
+package message
+
+import "fmt"
+
+//
+// ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+// requestName [0] LDAPOID,
+// requestValue [1] OCTET STRING OPTIONAL }
+
+func (extended *ExtendedRequest) RequestName() LDAPOID {
+ return extended.requestName
+}
+
+func (extended *ExtendedRequest) RequestValue() *OCTETSTRING {
+ return extended.requestValue
+}
+
+func readExtendedRequest(bytes *Bytes) (ret ExtendedRequest, err error) {
+ err = bytes.ReadSubBytes(classApplication, TagExtendedRequest, ret.readComponents)
+ if err != nil {
+ err = LdapError{fmt.Sprintf("readExtendedRequest:\n%s", err.Error())}
+ return
+ }
+ return
+}
+
+func (extended *ExtendedRequest) readComponents(bytes *Bytes) (err error) {
+ extended.requestName, err = readTaggedLDAPOID(bytes, classContextSpecific, TagExtendedRequestName)
+ if err != nil {
+ err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())}
+ return
+ }
+ if bytes.HasMoreData() {
+ var tag TagAndLength
+ tag, err = bytes.PreviewTagAndLength()
+ if err != nil {
+ err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())}
+ return
+ }
+ if tag.Tag == TagExtendedRequestValue {
+ var requestValue OCTETSTRING
+ requestValue, err = readTaggedOCTETSTRING(bytes, classContextSpecific, TagExtendedRequestValue)
+ if err != nil {
+ err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())}
+ return
+ }
+ extended.requestValue = requestValue.Pointer()
+ }
+ }
+ return
+}
+
+func (extended ExtendedRequest) write(bytes *Bytes) (size int) {
+ if extended.requestValue != nil {
+ size += extended.requestValue.writeTagged(bytes, classContextSpecific, TagExtendedRequestValue)
+ }
+ size += extended.requestName.writeTagged(bytes, classContextSpecific, TagExtendedRequestName)
+ size += bytes.WriteTagAndLength(classApplication, isCompound, TagExtendedRequest, size)
+ return
+}
+
+func (extended ExtendedRequest) size() (size int) {
+ size += extended.requestName.sizeTagged(TagExtendedRequestName)
+ if extended.requestValue != nil {
+ size += extended.requestValue.sizeTagged(TagExtendedRequestValue)
+ }
+ size += sizeTagAndLength(TagExtendedRequest, size)
+ return
+}