| 1 |
package element |
| 2 |
|
| 3 |
import ( |
| 4 |
"bytes" |
| 5 |
"fmt" |
| 6 |
|
| 7 |
"github.com/mitch000001/go-hbci/charset" |
| 8 |
"github.com/mitch000001/go-hbci/internal" |
| 9 |
"gopkg.in/yaml.v3" |
| 10 |
) |
| 11 |
|
| 12 |
// Gültigkeitsdatum und –uhrzeit für Challenge |
| 13 |
// |
| 14 |
// Datum und Uhrzeit, bis zu welchem Zeitpunkt eine TAN auf Basis der ge- |
| 15 |
// sendeten Challenge gültig ist. Nach Ablauf der Gültigkeitsdauer wird die ent- |
| 16 |
// sprechende TAN entwertet. |
| 17 |
type TanChallengeExpiryDate struct { |
| 18 |
DataElement |
| 19 |
Date *DateDataElement |
| 20 |
Time *TimeDataElement |
| 21 |
} |
| 22 |
|
| 23 |
// GroupDataElements returns the grouped DataElements |
| 24 |
func (t *TanChallengeExpiryDate) GroupDataElements() []DataElement { |
| 25 |
return []DataElement{ |
| 26 |
t.Date, |
| 27 |
t.Time, |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
// Tan2StepSubmissionParameterV6 |
| 32 |
// |
| 33 |
// Parameter Zwei-Schritt-TAN-Einreichung, Elementversion #6 |
| 34 |
// |
| 35 |
// Auftragsspezifische Bankparameterdaten für den Geschäftsvorfall „Zwei- Schritt-TAN-Einreichung“. |
| 36 |
type Tan2StepSubmissionParameterV6 struct { |
| 37 |
DataElement |
| 38 |
// Ein-Schritt-Verfahren erlaubt |
| 39 |
// |
| 40 |
// Angabe, ob Ein-Schritt-Verfahren erlaubt ist oder nicht. Darüber wird das Kundenprodukt informiert, |
| 41 |
// ob die Einreichung von Aufträgen im Ein-Schritt- Verfahren zusätzlich zu den definierten |
| 42 |
// Zwei-Schritt-Verfahren zugelassen ist. |
| 43 |
OneStepProcessAllowed *BooleanDataElement |
| 44 |
// Mehr als ein TAN-pflichtiger Auftrag pro Nachricht erlaubt |
| 45 |
// |
| 46 |
// Angabe, ob in einer FinTS-Nachricht mehr als ein TAN-pflichtiger Auftrag gesendet werden darf. |
| 47 |
// Bei Angabe von „N“ darf in einer FinTS-Nachricht nur ein TAN-pflichtiger Auftrag enthalten sein. |
| 48 |
// Bei Angabe von „J“ wird die ma- ximale Anzahl der TAN-pflichtigen Aufträge analog dem |
| 49 |
// Geschäftsvorfallparameter „Maximale Anzahl Aufträge“ in der BPD bestimmt (vgl. [Formals], Kapitel D.6). |
| 50 |
// Die Option bezieht sich auf die Anzahl der in der Nachricht ent- haltenen Aufträge, nicht auf die |
| 51 |
// Anzahl der TANs, d. h. es ist pro Signaturab- schluss nur eine TAN erlaubt, die bei Angabe von „J“ |
| 52 |
// aber ggf. für mehrere Aufträge gilt. Dieser Parameter gilt sowohl für das Einschritt- als auch das |
| 53 |
// Zwei-Schritt-Verfahren. |
| 54 |
MoreThanOneObligatoryTanJobAllowed *BooleanDataElement |
| 55 |
// Auftrags-Hashwertverfahren |
| 56 |
// |
| 57 |
// Information, welches Verfahren für die Hashwertbildung über den Kunden- auftrag verwendet werden soll. |
| 58 |
// Es sind nur die in [HBCI] beschriebenen Verfahren und deren Parametrisierung (Initialisierungsvektor, etc.) zulässig. |
| 59 |
// Codierung: |
| 60 |
// 0: Auftrags-Hashwert nicht unterstützt |
| 61 |
// 1: RIPEMD-160 |
| 62 |
// 2: SHA-1 |
| 63 |
JobHashMethod *CodeDataElement |
| 64 |
// FIXME: docs |
| 65 |
ProcessParameters *Tan2StepSubmissionProcessParametersV6 |
| 66 |
} |
| 67 |
|
| 68 |
// Elements returns the elements of this DataElement. |
| 69 |
func (t *Tan2StepSubmissionParameterV6) Elements() []DataElement { |
| 70 |
return []DataElement{ |
| 71 |
t.OneStepProcessAllowed, |
| 72 |
t.MoreThanOneObligatoryTanJobAllowed, |
| 73 |
t.JobHashMethod, |
| 74 |
t.ProcessParameters, |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
// UnmarshalHBCI unmarshals value |
| 79 |
func (t *Tan2StepSubmissionParameterV6) UnmarshalHBCI(value []byte) error { |
| 80 |
elements, err := ExtractElements(value) |
| 81 |
if err != nil { |
| 82 |
return err |
| 83 |
} |
| 84 |
oneStepProcessAllowed := &BooleanDataElement{} |
| 85 |
err = oneStepProcessAllowed.UnmarshalHBCI(elements[0]) |
| 86 |
if err != nil { |
| 87 |
return err |
| 88 |
} |
| 89 |
t.OneStepProcessAllowed = oneStepProcessAllowed |
| 90 |
moreThanOneObligatoryTanJobAllowed := &BooleanDataElement{} |
| 91 |
err = moreThanOneObligatoryTanJobAllowed.UnmarshalHBCI(elements[1]) |
| 92 |
if err != nil { |
| 93 |
return err |
| 94 |
} |
| 95 |
t.MoreThanOneObligatoryTanJobAllowed = moreThanOneObligatoryTanJobAllowed |
| 96 |
t.JobHashMethod = NewCode(charset.ToUTF8(elements[2]), 1, []string{"0", "1", "2"}) |
| 97 |
processParams := &Tan2StepSubmissionProcessParametersV6{} |
| 98 |
err = processParams.UnmarshalHBCI(bytes.Join(elements[3:], []byte(":"))) |
| 99 |
if err != nil { |
| 100 |
return err |
| 101 |
} |
| 102 |
t.ProcessParameters = processParams |
| 103 |
t.DataElement = NewGroupDataElementGroup(tan2StepSubmissionParameterDEG, 4, t) |
| 104 |
return nil |
| 105 |
} |
| 106 |
|
| 107 |
func (t *Tan2StepSubmissionParameterV6) MarshalYAML() (interface{}, error) { |
| 108 |
return map[string]yaml.Marshaler{ |
| 109 |
"OneStepProcessAllowed": t.OneStepProcessAllowed, |
| 110 |
"MoreThanOneObligatoryTanJobAllowed": t.MoreThanOneObligatoryTanJobAllowed, |
| 111 |
"JobHashMethod": t.JobHashMethod, |
| 112 |
"ProcessParameters": t.ProcessParameters, |
| 113 |
}, nil |
| 114 |
} |
| 115 |
|
| 116 |
// Tan2StepSubmissionParametersV6 represents a slice of |
| 117 |
// Tan2StepSubmissionParameterV6 DataElements |
| 118 |
type Tan2StepSubmissionProcessParametersV6 struct { |
| 119 |
*arrayElementGroup |
| 120 |
} |
| 121 |
|
| 122 |
// func (t *Tan2StepSubmissionProcessParametersV6) MarshalYAML() (interface{}, error) { |
| 123 |
// return t.GroupDataElements(), nil |
| 124 |
// } |
| 125 |
|
| 126 |
// // Val returns the underlying Tan2StepSubmissionParameters |
| 127 |
// func (p *Tan2StepSubmissionParameters) Val() []domain.PinTanBusinessTransaction { |
| 128 |
// transactions := make([]domain.PinTanBusinessTransaction, len(p.array)) |
| 129 |
// for i, elem := range p.array { |
| 130 |
// transactions[i] = elem.(*PinTanBusinessTransactionParameter).Val() |
| 131 |
// } |
| 132 |
// return transactions |
| 133 |
// } |
| 134 |
|
| 135 |
// UnmarshalHBCI unmarshals value into the Tan2StepSubmissionParameters |
| 136 |
func (t *Tan2StepSubmissionProcessParametersV6) UnmarshalHBCI(value []byte) error { |
| 137 |
elements, err := ExtractElements(value) |
| 138 |
if err != nil { |
| 139 |
return err |
| 140 |
} |
| 141 |
if len(elements)%21 != 0 { |
| 142 |
return fmt.Errorf("malformed marshaled value: value pairs not even") |
| 143 |
} |
| 144 |
dataElements := make([]DataElement, len(elements)/21) |
| 145 |
for i := 0; i < len(elements); i += 21 { |
| 146 |
elem := bytes.Join(elements[i:i+21], []byte(":")) |
| 147 |
param := &Tan2StepSubmissionProcessParameterV6{} |
| 148 |
err := param.UnmarshalHBCI(elem) |
| 149 |
if err != nil { |
| 150 |
return err |
| 151 |
} |
| 152 |
dataElements[i/21] = param |
| 153 |
} |
| 154 |
t.arrayElementGroup = newArrayElementGroup(tan2StepSubmissionProcessParameterDEG, len(dataElements), len(dataElements), dataElements) |
| 155 |
return nil |
| 156 |
} |
| 157 |
|
| 158 |
type Tan2StepSubmissionProcessParameterV6 struct { |
| 159 |
DataElement |
| 160 |
SecurityFunction *CodeDataElement |
| 161 |
TanProcess *CodeDataElement |
| 162 |
TechnicalIDTanProcess *IdentificationDataElement |
| 163 |
ZKATanProcess *AlphaNumericDataElement |
| 164 |
ZKATanProcessVersion *AlphaNumericDataElement |
| 165 |
TwoStepProcessName *AlphaNumericDataElement |
| 166 |
TwoStepProcessMaxInputValue *NumberDataElement |
| 167 |
TwoStepProcessAllowedFormat *CodeDataElement |
| 168 |
TwoStepProcessReturnValueText *AlphaNumericDataElement |
| 169 |
TwoStepProcessReturnValueTextMaxLength *NumberDataElement |
| 170 |
MultiTANAllowed *BooleanDataElement |
| 171 |
TanTimeAndDialogReference *CodeDataElement |
| 172 |
JobCancellationAllowed *BooleanDataElement |
| 173 |
SMSAccountRequired *CodeDataElement |
| 174 |
IssuerAccountRequired *CodeDataElement |
| 175 |
ChallengeClassRequired *BooleanDataElement |
| 176 |
ChallengeStructured *BooleanDataElement |
| 177 |
InitializationMode *CodeDataElement |
| 178 |
TanMediumDescriptionRequired *CodeDataElement |
| 179 |
HHD_UCResponseRequired *BooleanDataElement |
| 180 |
SupportedActiveTanMedia *NumberDataElement |
| 181 |
} |
| 182 |
|
| 183 |
// Elements returns the elements of this DataElement. |
| 184 |
func (t *Tan2StepSubmissionProcessParameterV6) Elements() []DataElement { |
| 185 |
return []DataElement{ |
| 186 |
t.SecurityFunction, |
| 187 |
t.TanProcess, |
| 188 |
t.TechnicalIDTanProcess, |
| 189 |
t.ZKATanProcess, |
| 190 |
t.ZKATanProcessVersion, |
| 191 |
t.TwoStepProcessName, |
| 192 |
t.TwoStepProcessMaxInputValue, |
| 193 |
t.TwoStepProcessAllowedFormat, |
| 194 |
t.TwoStepProcessReturnValueText, |
| 195 |
t.TwoStepProcessReturnValueTextMaxLength, |
| 196 |
t.MultiTANAllowed, |
| 197 |
t.TanTimeAndDialogReference, |
| 198 |
t.JobCancellationAllowed, |
| 199 |
t.SMSAccountRequired, |
| 200 |
t.IssuerAccountRequired, |
| 201 |
t.ChallengeClassRequired, |
| 202 |
t.ChallengeStructured, |
| 203 |
t.InitializationMode, |
| 204 |
t.TanMediumDescriptionRequired, |
| 205 |
t.HHD_UCResponseRequired, |
| 206 |
t.SupportedActiveTanMedia, |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
// // Val returns the underlying PinTanBusinessTransaction |
| 211 |
// func (t *Tan2StepSubmissionProcessParameterV6) Val() interface{} { |
| 212 |
// return domain.PinTanBusinessTransaction{ |
| 213 |
// } |
| 214 |
// } |
| 215 |
|
| 216 |
// UnmarshalHBCI unmarshals value |
| 217 |
func (t *Tan2StepSubmissionProcessParameterV6) UnmarshalHBCI(value []byte) error { |
| 218 |
elements, err := ExtractElements(value) |
| 219 |
if err != nil { |
| 220 |
return err |
| 221 |
} |
| 222 |
iter := internal.NewIterator(elements) |
| 223 |
t.SecurityFunction = NewCode(iter.NextString(), 3, nil) |
| 224 |
t.TanProcess = NewCode(iter.NextString(), 1, []string{"1", "2"}) |
| 225 |
t.TechnicalIDTanProcess = NewIdentification(iter.NextString()) |
| 226 |
t.ZKATanProcess = NewAlphaNumeric(iter.NextString(), 32) |
| 227 |
t.ZKATanProcessVersion = NewAlphaNumeric(iter.NextString(), 10) |
| 228 |
t.TwoStepProcessName = NewAlphaNumeric(iter.NextString(), 30) |
| 229 |
var twoStepProcessMaxInputValue NumberDataElement |
| 230 |
if err := twoStepProcessMaxInputValue.UnmarshalHBCI(iter.Next()); err != nil { |
| 231 |
return fmt.Errorf("error unmarshaling TwoStepProcessMaxInputValue: %v", err) |
| 232 |
} |
| 233 |
t.TwoStepProcessMaxInputValue = &twoStepProcessMaxInputValue |
| 234 |
t.TwoStepProcessAllowedFormat = NewCode(iter.NextString(), 1, nil) |
| 235 |
t.TwoStepProcessReturnValueText = NewAlphaNumeric(iter.NextString(), 30) |
| 236 |
var TwoStepProcessReturnValueTextMaxLength NumberDataElement |
| 237 |
if err := TwoStepProcessReturnValueTextMaxLength.UnmarshalHBCI(iter.Next()); err != nil { |
| 238 |
return fmt.Errorf("error unmarshaling TwoStepProcessReturnValueTextMaxLength: %v", err) |
| 239 |
} |
| 240 |
t.TwoStepProcessReturnValueTextMaxLength = &TwoStepProcessReturnValueTextMaxLength |
| 241 |
var MultiTANAllowed BooleanDataElement |
| 242 |
if err := MultiTANAllowed.UnmarshalHBCI(iter.Next()); err != nil { |
| 243 |
return fmt.Errorf("error unmarshaling MultiTANAllowed: %v", err) |
| 244 |
} |
| 245 |
t.MultiTANAllowed = &MultiTANAllowed |
| 246 |
t.TanTimeAndDialogReference = NewCode(iter.NextString(), 1, nil) |
| 247 |
var JobCancellationAllowed BooleanDataElement |
| 248 |
if err := JobCancellationAllowed.UnmarshalHBCI(iter.Next()); err != nil { |
| 249 |
return fmt.Errorf("error unmarshaling JobCancellationAllowed: %v", err) |
| 250 |
} |
| 251 |
t.JobCancellationAllowed = &JobCancellationAllowed |
| 252 |
t.SMSAccountRequired = NewCode(iter.NextString(), 1, []string{"0", "1", "2"}) |
| 253 |
t.IssuerAccountRequired = NewCode(iter.NextString(), 1, []string{"0", "2"}) |
| 254 |
var ChallengeClassRequired BooleanDataElement |
| 255 |
if err := ChallengeClassRequired.UnmarshalHBCI(iter.Next()); err != nil { |
| 256 |
return fmt.Errorf("error unmarshaling ChallengeClassRequired: %v", err) |
| 257 |
} |
| 258 |
t.ChallengeClassRequired = &ChallengeClassRequired |
| 259 |
var ChallengeStructured BooleanDataElement |
| 260 |
if err := ChallengeStructured.UnmarshalHBCI(iter.Next()); err != nil { |
| 261 |
return fmt.Errorf("error unmarshaling ChallengeStructured: %v", err) |
| 262 |
} |
| 263 |
t.ChallengeStructured = &ChallengeStructured |
| 264 |
t.InitializationMode = NewCode(iter.NextString(), -1, []string{"00", "01", "02"}) |
| 265 |
t.TanMediumDescriptionRequired = NewCode(iter.NextString(), 1, []string{"0", "1", "2"}) |
| 266 |
var HHD_UCResponseRequired BooleanDataElement |
| 267 |
if err := HHD_UCResponseRequired.UnmarshalHBCI(iter.Next()); err != nil { |
| 268 |
return fmt.Errorf("error unmarshaling HHD_UCResponseRequired: %v", err) |
| 269 |
} |
| 270 |
t.HHD_UCResponseRequired = &HHD_UCResponseRequired |
| 271 |
var SupportedActiveTanMedia NumberDataElement |
| 272 |
if err := SupportedActiveTanMedia.UnmarshalHBCI(iter.Next()); err != nil { |
| 273 |
return fmt.Errorf("error unmarshaling SupportedActiveTanMedia: %v", err) |
| 274 |
} |
| 275 |
t.SupportedActiveTanMedia = &SupportedActiveTanMedia |
| 276 |
t.DataElement = NewGroupDataElementGroup(pinTanBusinessTransactionParameterGDEG, 2, t) |
| 277 |
return nil |
| 278 |
} |
| 279 |
|
| 280 |
func (t Tan2StepSubmissionProcessParameterV6) MarshalYAML() (interface{}, error) { |
| 281 |
return map[string]yaml.Marshaler{ |
| 282 |
"SecurityFunction": t.SecurityFunction, |
| 283 |
"TanProcess": t.TanProcess, |
| 284 |
"TechnicalIDTanProcess": t.TechnicalIDTanProcess, |
| 285 |
"ZKATanProcess": t.ZKATanProcess, |
| 286 |
"ZKATanProcessVersion": t.ZKATanProcessVersion, |
| 287 |
"TwoStepProcessName": t.TwoStepProcessName, |
| 288 |
"TwoStepProcessMaxInputValue": t.TwoStepProcessMaxInputValue, |
| 289 |
"TwoStepProcessAllowedFormat": t.TwoStepProcessAllowedFormat, |
| 290 |
"TwoStepProcessReturnValueText": t.TwoStepProcessReturnValueText, |
| 291 |
"TwoStepProcessReturnValueTextMaxLength": t.TwoStepProcessReturnValueTextMaxLength, |
| 292 |
"MultiTANAllowed": t.MultiTANAllowed, |
| 293 |
"TanTimeAndDialogReference": t.TanTimeAndDialogReference, |
| 294 |
"JobCancellationAllowed": t.JobCancellationAllowed, |
| 295 |
"SMSAccountRequired": t.SMSAccountRequired, |
| 296 |
"IssuerAccountRequired": t.IssuerAccountRequired, |
| 297 |
"ChallengeClassRequired": t.ChallengeClassRequired, |
| 298 |
"ChallengeStructured": t.ChallengeStructured, |
| 299 |
"InitializationMode": t.InitializationMode, |
| 300 |
"TanMediumDescriptionRequired": t.TanMediumDescriptionRequired, |
| 301 |
"HHD_UCResponseRequired": t.HHD_UCResponseRequired, |
| 302 |
"SupportedActiveTanMedia": t.SupportedActiveTanMedia, |
| 303 |
}, nil |
| 304 |
} |