blob: 9c5e4da64e73e9dcfdfb565eae430d11aed67d21 (
plain)
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
|
/*
* 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/>
*/
import org.apache.xml.security.binding.xmldsig.SignatureType
import org.junit.Test
import tech.libeufin.common.crypto.CryptoUtil
import tech.libeufin.ebics.XMLUtil
import tech.libeufin.ebics.ebics_h004.EbicsRequest
import tech.libeufin.ebics.ebics_h004.EbicsTypes
import java.math.BigInteger
import java.util.*
import javax.xml.datatype.DatatypeFactory
class SignatureDataTest {
@Test
fun makeSignatureData() {
val pair = CryptoUtil.generateRsaKeyPair(1024)
val tmp = EbicsRequest().apply {
header = EbicsRequest.Header().apply {
version = "H004"
revision = 1
authenticate = true
static = EbicsRequest.StaticHeaderType().apply {
hostID = "some host ID"
nonce = "nonce".toByteArray()
timestamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar())
partnerID = "some partner ID"
userID = "some user ID"
orderDetails = EbicsRequest.OrderDetails().apply {
orderType = "TST"
orderAttribute = "OZHNN"
}
bankPubKeyDigests = EbicsRequest.BankPubKeyDigests().apply {
authentication = EbicsTypes.PubKeyDigest().apply {
algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
version = "X002"
value = CryptoUtil.getEbicsPublicKeyHash(pair.public)
}
encryption = EbicsTypes.PubKeyDigest().apply {
algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
version = "E002"
value = CryptoUtil.getEbicsPublicKeyHash(pair.public)
}
}
securityMedium = "0000"
numSegments = BigInteger.ONE
authSignature = SignatureType()
}
mutable = EbicsRequest.MutableHeader().apply {
transactionPhase = EbicsTypes.TransactionPhaseType.INITIALISATION
}
body = EbicsRequest.Body().apply {
dataTransfer = EbicsRequest.DataTransfer().apply {
signatureData = EbicsRequest.SignatureData().apply {
authenticate = true
value = "to byte array".toByteArray()
}
dataEncryptionInfo = EbicsTypes.DataEncryptionInfo().apply {
transactionKey = "mock".toByteArray()
authenticate = true
encryptionPubKeyDigest = EbicsTypes.PubKeyDigest().apply {
algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
version = "E002"
value =
CryptoUtil.getEbicsPublicKeyHash(pair.public)
}
}
hostId = "a host ID"
}
}
}
}
println(XMLUtil.convertJaxbToBytes(tmp))
}
}
|