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
|
/*
* This file is part of LibEuFin.
* Copyright (C) 2024 Taler Systems S.A.
* LibEuFin is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3, or
* (at your option) any later version.
* LibEuFin is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
* Public License for more details.
* You should have received a copy of the GNU Affero General Public
* License along with LibEuFin; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>
*/
package tech.libeufin.nexus.ebics
// TODO import missing using a script
@Suppress("SpellCheckingInspection")
enum class EbicsReturnCode(val code: String) {
EBICS_OK("000000"),
EBICS_DOWNLOAD_POSTPROCESS_DONE("011000"),
EBICS_DOWNLOAD_POSTPROCESS_SKIPPED("011001"),
EBICS_TX_SEGMENT_NUMBER_UNDERRUN("011101"),
EBICS_AUTHENTICATION_FAILED("061001"),
EBICS_INVALID_REQUEST("061002"),
EBICS_INTERNAL_ERROR("061099"),
EBICS_TX_RECOVERY_SYNC("061101"),
EBICS_AUTHORISATION_ORDER_IDENTIFIER_FAILED("090003"),
EBICS_INVALID_ORDER_DATA_FORMAT("090004"),
EBICS_NO_DOWNLOAD_DATA_AVAILABLE("090005"),
// Transaction administration
EBICS_INVALID_USER_OR_USER_STATE("091002"),
EBICS_USER_UNKNOWN("091003"),
EBICS_INVALID_USER_STATE("091004"),
EBICS_INVALID_ORDER_IDENTIFIER("091005"),
EBICS_UNSUPPORTED_ORDER_TYPE("091006"),
EBICS_INVALID_XML("091010"),
EBICS_TX_MESSAGE_REPLAY("091103"),
EBICS_TX_SEGMENT_NUMBER_EXCEEDED("091104"),
EBICS_INVALID_REQUEST_CONTENT("091113"),
EBICS_PROCESSING_ERROR("091116"),
// Key-Management errors
EBICS_X509_WRONG_KEY_USAGE("091210"),
EBICS_X509_WRONG_ALGORITHM("091211"),
EBICS_X509_INVALID_THUMBPRINT("091212"),
EBICS_X509_CTL_INVALID("091213"),
EBICS_X509_UNKNOWN_CERTIFICATE_AUTHORITY("091214"),
EBICS_X509_INVALID_POLICY("091215"),
EBICS_X509_INVALID_BASIC_CONSTRAINTS("091216"),
EBICS_ONLY_X509_SUPPORT("091217"),
EBICS_KEYMGMT_DUPLICATE_KEY("091218"),
EBICS_CERTIFICATE_VALIDATION_ERROR("091219"),
// Pre-erification errors
EBICS_SIGNATURE_VERIFICATION_FAILED("091301"),
EBICS_ACCOUNT_AUTHORISATION_FAILED("091302"),
EBICS_AMOUNT_CHECK_FAILED("091303"),
EBICS_SIGNER_UNKNOWN("091304"),
EBICS_INVALID_SIGNER_STATE("091305"),
EBICS_DUPLICATE_SIGNATURE("091306");
enum class Kind {
Information,
Note,
Warning,
Error
}
fun kind(): Kind {
return when (val errorClass = code.substring(0..1)) {
"00" -> Kind.Information
"01" -> Kind.Note
"03" -> Kind.Warning
"06", "09" -> Kind.Error
else -> throw Exception("Unknown EBICS status code error class: $errorClass")
}
}
companion object {
fun lookup(code: String): EbicsReturnCode {
for (x in entries) {
if (x.code == code) {
return x
}
}
throw Exception(
"Unknown EBICS status code: $code"
)
}
}
}
|