diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:41:01 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:41:01 +0200 |
commit | 477d7014edc787ba9a977acd19fcbfc55531768b (patch) | |
tree | ac8b65be8634fa9526cd727da60893244d11e88a /goldap/intermediate_response.go | |
parent | a53641e773730ba171df2602c8d199968d6e6447 (diff) | |
download | bottin-477d7014edc787ba9a977acd19fcbfc55531768b.tar.gz bottin-477d7014edc787ba9a977acd19fcbfc55531768b.zip |
Vendor goldap
Diffstat (limited to 'goldap/intermediate_response.go')
-rw-r--r-- | goldap/intermediate_response.go | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/goldap/intermediate_response.go b/goldap/intermediate_response.go new file mode 100644 index 0000000..90bf188 --- /dev/null +++ b/goldap/intermediate_response.go @@ -0,0 +1,89 @@ +package message + +import "fmt" + +// +// IntermediateResponse ::= [APPLICATION 25] SEQUENCE { +// responseName [0] LDAPOID OPTIONAL, +// responseValue [1] OCTET STRING OPTIONAL } +func readIntermediateResponse(bytes *Bytes) (ret IntermediateResponse, err error) { + err = bytes.ReadSubBytes(classApplication, TagIntermediateResponse, ret.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readIntermediateResponse:\n%s", err.Error())} + return + } + return +} +func (bytes *Bytes) PreviewTagAndLength() (tagAndLength TagAndLength, err error) { + previousOffset := bytes.offset // Save offset + tagAndLength, err = bytes.ParseTagAndLength() + bytes.offset = previousOffset // Restore offset + return +} +func (res *IntermediateResponse) readComponents(bytes *Bytes) (err error) { + 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 == TagIntermediateResponseName { + var oid LDAPOID + oid, err = readTaggedLDAPOID(bytes, classContextSpecific, TagIntermediateResponseName) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + res.responseName = oid.Pointer() + } + } + 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 == TagIntermediateResponseValue { + var str OCTETSTRING + str, err = readTaggedOCTETSTRING(bytes, classContextSpecific, TagIntermediateResponseValue) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + res.responseValue = str.Pointer() + } + } + return +} + +// +// IntermediateResponse ::= [APPLICATION 25] SEQUENCE { +// responseName [0] LDAPOID OPTIONAL, +// responseValue [1] OCTET STRING OPTIONAL } +func (i IntermediateResponse) write(bytes *Bytes) (size int) { + if i.responseValue != nil { + size += i.responseValue.writeTagged(bytes, classContextSpecific, TagIntermediateResponseValue) + } + if i.responseName != nil { + size += i.responseName.writeTagged(bytes, classContextSpecific, TagIntermediateResponseName) + } + size += bytes.WriteTagAndLength(classApplication, isCompound, TagIntermediateResponse, size) + return +} + +// +// IntermediateResponse ::= [APPLICATION 25] SEQUENCE { +// responseName [0] LDAPOID OPTIONAL, +// responseValue [1] OCTET STRING OPTIONAL } +func (i IntermediateResponse) size() (size int) { + if i.responseName != nil { + size += i.responseName.sizeTagged(TagIntermediateResponseName) + } + if i.responseValue != nil { + size += i.responseValue.sizeTagged(TagIntermediateResponseValue) + } + size += sizeTagAndLength(TagIntermediateResponse, size) + return +} |