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/attribute_value_assertion.go | |
parent | a53641e773730ba171df2602c8d199968d6e6447 (diff) | |
download | bottin-477d7014edc787ba9a977acd19fcbfc55531768b.tar.gz bottin-477d7014edc787ba9a977acd19fcbfc55531768b.zip |
Vendor goldap
Diffstat (limited to 'goldap/attribute_value_assertion.go')
-rw-r--r-- | goldap/attribute_value_assertion.go | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/goldap/attribute_value_assertion.go b/goldap/attribute_value_assertion.go new file mode 100644 index 0000000..bb00cbd --- /dev/null +++ b/goldap/attribute_value_assertion.go @@ -0,0 +1,77 @@ +package message + +import "fmt" + +// +// AttributeValueAssertion ::= SEQUENCE { +// attributeDesc AttributeDescription, +// assertionValue AssertionValue } + +func (assertion *AttributeValueAssertion) AttributeDesc() AttributeDescription { + return assertion.attributeDesc +} + +func (assertion *AttributeValueAssertion) AssertionValue() AssertionValue { + return assertion.assertionValue +} + +func readAttributeValueAssertion(bytes *Bytes) (ret AttributeValueAssertion, err error) { + err = bytes.ReadSubBytes(classUniversal, tagSequence, ret.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readAttributeValueAssertion:\n%s", err.Error())} + return + } + return + +} + +func readTaggedAttributeValueAssertion(bytes *Bytes, class int, tag int) (ret AttributeValueAssertion, err error) { + err = bytes.ReadSubBytes(class, tag, ret.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readTaggedAttributeValueAssertion:\n%s", err.Error())} + return + } + return +} + +func (assertion *AttributeValueAssertion) readComponents(bytes *Bytes) (err error) { + assertion.attributeDesc, err = readAttributeDescription(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + assertion.assertionValue, err = readAssertionValue(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + return +} + +func (assertion AttributeValueAssertion) write(bytes *Bytes) (size int) { + size += assertion.assertionValue.write(bytes) + size += assertion.attributeDesc.write(bytes) + size += bytes.WriteTagAndLength(classUniversal, isCompound, tagSequence, size) + return +} + +func (assertion AttributeValueAssertion) writeTagged(bytes *Bytes, class int, tag int) (size int) { + size += assertion.assertionValue.write(bytes) + size += assertion.attributeDesc.write(bytes) + size += bytes.WriteTagAndLength(class, isCompound, tag, size) + return +} + +func (assertion AttributeValueAssertion) size() (size int) { + size += assertion.attributeDesc.size() + size += assertion.assertionValue.size() + size += sizeTagAndLength(tagSequence, size) + return +} + +func (assertion AttributeValueAssertion) sizeTagged(tag int) (size int) { + size += assertion.attributeDesc.size() + size += assertion.assertionValue.size() + size += sizeTagAndLength(tag, size) + return +} |