aboutsummaryrefslogtreecommitdiff
path: root/goldap/attribute_value_assertion.go
blob: bb00cbd1d798773312ea60f2c2a6bf244b967031 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
}