File: signature_fints3.go

package info (click to toggle)
golang-github-mitch000001-go-hbci 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,468 kB
  • sloc: java: 1,092; makefile: 5
file content (50 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (2)
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
package element

import "fmt"

// NewPinTanSecurityProfile returns a new SecurityProfile for the provided
// securityMehtod
func NewPinTanSecurityProfile(securityMethod int) *SecurityProfileDataElement {
	s := &SecurityProfileDataElement{
		SecurityMethod:        NewAlphaNumeric("PIN", 3),
		SecurityMethodVersion: NewNumber(securityMethod, 3),
	}
	s.DataElement = NewDataElementGroup(securityProfileDEG, 2, s)
	return s
}

// SecurityProfileDataElement defines a security method for the dialog flow
type SecurityProfileDataElement struct {
	DataElement
	SecurityMethod        *AlphaNumericDataElement
	SecurityMethodVersion *NumberDataElement
}

// UnmarshalHBCI unmarshals value into the DataElement
func (s *SecurityProfileDataElement) UnmarshalHBCI(value []byte) error {
	s = &SecurityProfileDataElement{}
	elements, err := ExtractElements(value)
	if err != nil {
		return err
	}
	if len(elements) < 2 {
		return fmt.Errorf("Malformed marshaled value")
	}
	s.DataElement = NewDataElementGroup(securityProfileDEG, 5, s)
	s.SecurityMethod = &AlphaNumericDataElement{}
	err = s.SecurityMethod.UnmarshalHBCI(elements[0])
	if err != nil {
		return err
	}
	s.SecurityMethodVersion = &NumberDataElement{}
	err = s.SecurityMethodVersion.UnmarshalHBCI(elements[1])
	return err
}

// GroupDataElements returns the grouped DataElements
func (s *SecurityProfileDataElement) GroupDataElements() []DataElement {
	return []DataElement{
		s.SecurityMethod,
		s.SecurityMethodVersion,
	}
}