-
Notifications
You must be signed in to change notification settings - Fork 11
/
signature_end.go
104 lines (84 loc) · 2.84 KB
/
signature_end.go
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package segment
import "github.com/mitch000001/go-hbci/element"
type SignatureEnd interface {
SetControlReference(controlReference string)
SetSignature(signature []byte)
SetPinTan(pin, tan string)
}
func NewSignatureEndSegmentV1() *SignatureEndSegment {
s := &SignatureEndV1{}
s.ClientSegment = NewBasicSegment(-1, s)
segment := &SignatureEndSegment{
signatureEndSegment: s,
}
return segment
}
type signatureEndSegment interface {
ClientSegment
SignatureEnd
Unmarshaler
}
//go:generate go run ../cmd/unmarshaler/unmarshaler_generator.go -segment SignatureEndSegment -segment_interface signatureEndSegment -segment_versions="SignatureEndV1:1:ClientSegment,SignatureEndV2:2:ClientSegment"
type SignatureEndSegment struct {
signatureEndSegment
}
type SignatureEndV1 struct {
ClientSegment
SecurityControlRef *element.AlphaNumericDataElement
Signature *element.BinaryDataElement
PinTan *element.PinTanDataElement
}
func (s *SignatureEndV1) Version() int { return 1 }
func (s *SignatureEndV1) ID() string { return "HNSHA" }
func (s *SignatureEndV1) referencedId() string { return "" }
func (s *SignatureEndV1) sender() string { return senderBoth }
func (s *SignatureEndV1) elements() []element.DataElement {
return []element.DataElement{
s.SecurityControlRef,
s.Signature,
s.PinTan,
}
}
func (s *SignatureEndV1) SetControlReference(controlReference string) {
s.SecurityControlRef = element.NewAlphaNumeric(controlReference, 14)
}
func (s *SignatureEndV1) SetSignature(signature []byte) {
s.Signature = element.NewBinary(signature, 512)
}
func (s *SignatureEndV1) SetPinTan(pin, tan string) {
s.PinTan = element.NewPinTan(pin, tan)
}
func NewSignatureEndSegmentV2() *SignatureEndSegment {
s := &SignatureEndV2{}
s.ClientSegment = NewBasicSegment(-1, s)
segment := &SignatureEndSegment{
signatureEndSegment: s,
}
return segment
}
type SignatureEndV2 struct {
ClientSegment
SecurityControlRef *element.AlphaNumericDataElement
Signature *element.BinaryDataElement
CustomSignature *element.CustomSignatureDataElement
}
func (s *SignatureEndV2) Version() int { return 2 }
func (s *SignatureEndV2) ID() string { return "HNSHA" }
func (s *SignatureEndV2) referencedId() string { return "" }
func (s *SignatureEndV2) sender() string { return senderBoth }
func (s *SignatureEndV2) elements() []element.DataElement {
return []element.DataElement{
s.SecurityControlRef,
s.Signature,
s.CustomSignature,
}
}
func (s *SignatureEndV2) SetControlReference(controlReference string) {
s.SecurityControlRef = element.NewAlphaNumeric(controlReference, 14)
}
func (s *SignatureEndV2) SetSignature(signature []byte) {
s.Signature = element.NewBinary(signature, 512)
}
func (s *SignatureEndV2) SetPinTan(pin, tan string) {
s.CustomSignature = element.NewCustomSignature(pin, tan)
}