summaryrefslogtreecommitdiff
path: root/ebics/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'ebics/src/main/kotlin')
-rw-r--r--ebics/src/main/kotlin/Ebics.kt245
-rw-r--r--ebics/src/main/kotlin/EbicsOrderUtil.kt88
-rw-r--r--ebics/src/main/kotlin/XMLUtil.kt570
-rw-r--r--ebics/src/main/kotlin/ebics_h004/EbicsKeyManagementResponse.kt102
-rw-r--r--ebics/src/main/kotlin/ebics_h004/EbicsNpkdRequest.kt135
-rw-r--r--ebics/src/main/kotlin/ebics_h004/EbicsRequest.kt504
-rw-r--r--ebics/src/main/kotlin/ebics_h004/EbicsResponse.kt348
-rw-r--r--ebics/src/main/kotlin/ebics_h004/EbicsTypes.kt402
-rw-r--r--ebics/src/main/kotlin/ebics_h004/EbicsUnsecuredRequest.kt223
-rw-r--r--ebics/src/main/kotlin/ebics_h004/HIARequestOrderData.kt33
-rw-r--r--ebics/src/main/kotlin/ebics_h004/HKDResponseOrderData.kt14
-rw-r--r--ebics/src/main/kotlin/ebics_h004/HPBResponseOrderData.kt21
-rw-r--r--ebics/src/main/kotlin/ebics_h004/HTDResponseOrderData.kt14
-rw-r--r--ebics/src/main/kotlin/ebics_h004/package-info.java13
-rw-r--r--ebics/src/main/kotlin/ebics_hev/EbicsMessages.kt92
-rw-r--r--ebics/src/main/kotlin/ebics_hev/package-info.java13
-rw-r--r--ebics/src/main/kotlin/ebics_s001/SignatureTypes.kt92
-rw-r--r--ebics/src/main/kotlin/ebics_s001/UserSignatureData.kt27
-rw-r--r--ebics/src/main/kotlin/ebics_s001/package-info.java13
-rw-r--r--ebics/src/main/kotlin/ebics_s002/SignatureTypes.kt91
-rw-r--r--ebics/src/main/kotlin/ebics_s002/UserSignatureDataEbics3.kt27
-rw-r--r--ebics/src/main/kotlin/ebics_s002/package-info.java13
22 files changed, 189 insertions, 2891 deletions
diff --git a/ebics/src/main/kotlin/Ebics.kt b/ebics/src/main/kotlin/Ebics.kt
index d0679c37..d9639ff5 100644
--- a/ebics/src/main/kotlin/Ebics.kt
+++ b/ebics/src/main/kotlin/Ebics.kt
@@ -28,11 +28,6 @@ import io.ktor.http.*
import org.w3c.dom.Document
import tech.libeufin.common.crypto.CryptoUtil
import tech.libeufin.common.*
-import tech.libeufin.ebics.ebics_h004.EbicsRequest
-import tech.libeufin.ebics.ebics_h004.EbicsResponse
-import tech.libeufin.ebics.ebics_h004.EbicsTypes
-import tech.libeufin.ebics.ebics_h004.HPBResponseOrderData
-import tech.libeufin.ebics.ebics_s001.UserSignatureData
import java.io.InputStream
import java.security.SecureRandom
import java.security.interfaces.RSAPrivateCrtKey
@@ -40,7 +35,6 @@ import java.security.interfaces.RSAPublicKey
import java.time.Instant
import java.time.ZoneId
import java.time.ZonedDateTime
-import javax.xml.bind.JAXBElement
import javax.xml.datatype.DatatypeFactory
import javax.xml.datatype.XMLGregorianCalendar
@@ -56,45 +50,6 @@ data class EbicsProtocolError(
val ebicsTechnicalCode: EbicsReturnCode? = null
) : Exception(reason)
-data class EbicsDateRange(
- val start: Instant,
- val end: Instant
-)
-
-sealed interface EbicsOrderParams
-data class EbicsStandardOrderParams(
- val dateRange: EbicsDateRange? = null
-) : EbicsOrderParams
-
-data class EbicsGenericOrderParams(
- val params: Map<String, String> = mapOf()
-) : EbicsOrderParams
-
-enum class EbicsInitState {
- SENT, NOT_SENT, UNKNOWN
-}
-
-/**
- * This class is a mere container that keeps data found
- * in the database and that is further needed to sign / verify
- * / make messages. And not all the values are needed all
- * the time.
- */
-data class EbicsClientSubscriberDetails(
- val partnerId: String,
- val userId: String,
- var bankAuthPub: RSAPublicKey?,
- var bankEncPub: RSAPublicKey?,
- val ebicsUrl: String,
- val hostId: String,
- val customerEncPriv: RSAPrivateCrtKey,
- val customerAuthPriv: RSAPrivateCrtKey,
- val customerSignPriv: RSAPrivateCrtKey,
- val ebicsIniState: EbicsInitState,
- val ebicsHiaState: EbicsInitState,
- var dialect: String? = null
-)
-
/**
* @param size in bits
*/
@@ -105,70 +60,6 @@ fun getNonce(size: Int): ByteArray {
return ret
}
-fun getXmlDate(i: Instant): XMLGregorianCalendar {
- val zonedTimestamp = ZonedDateTime.ofInstant(i, ZoneId.of("UTC"))
- return getXmlDate(zonedTimestamp)
-}
-fun getXmlDate(d: ZonedDateTime): XMLGregorianCalendar {
- return DatatypeFactory.newInstance()
- .newXMLGregorianCalendar(
- d.year,
- d.monthValue,
- d.dayOfMonth,
- 0,
- 0,
- 0,
- 0,
- d.offset.totalSeconds / 60
- )
-}
-
-fun signOrder(
- orderBlob: ByteArray,
- signKey: RSAPrivateCrtKey,
- partnerId: String,
- userId: String
-): UserSignatureData {
- val ES_signature = CryptoUtil.signEbicsA006(
- CryptoUtil.digestEbicsOrderA006(orderBlob),
- signKey
- )
- val userSignatureData = UserSignatureData().apply {
- orderSignatureList = listOf(
- UserSignatureData.OrderSignatureData().apply {
- signatureVersion = "A006"
- signatureValue = ES_signature
- partnerID = partnerId
- userID = userId
- }
- )
- }
- return userSignatureData
-}
-
-fun signOrderEbics3(
- orderBlob: ByteArray,
- signKey: RSAPrivateCrtKey,
- partnerId: String,
- userId: String
-): tech.libeufin.ebics.ebics_s002.UserSignatureDataEbics3 {
- val ES_signature = CryptoUtil.signEbicsA006(
- CryptoUtil.digestEbicsOrderA006(orderBlob),
- signKey
- )
- val userSignatureData = tech.libeufin.ebics.ebics_s002.UserSignatureDataEbics3().apply {
- orderSignatureList = listOf(
- tech.libeufin.ebics.ebics_s002.UserSignatureDataEbics3.OrderSignatureData().apply {
- signatureVersion = "A006"
- signatureValue = ES_signature
- partnerID = partnerId
- userID = userId
- }
- )
- }
- return userSignatureData
-}
-
data class PreparedUploadData(
val transactionKey: ByteArray,
val userSignatureDataEncrypted: ByteArray,
@@ -259,6 +150,27 @@ enum class EbicsReturnCode(val errorCode: String) {
}
}
+
+fun signOrderEbics3(
+ orderBlob: ByteArray,
+ signKey: RSAPrivateCrtKey,
+ partnerId: String,
+ userId: String
+): ByteArray {
+ return XmlBuilder.toString("UserSignatureData") {
+ attr("xmlns", "http://www.ebics.org/S002")
+ el("OrderSignatureData") {
+ el("SignatureVersion", "A006")
+ el("SignatureValue", CryptoUtil.signEbicsA006(
+ CryptoUtil.digestEbicsOrderA006(orderBlob),
+ signKey
+ ).encodeBase64())
+ el("PartnerID", partnerId)
+ el("UserID", userId)
+ }
+ }.toByteArray()
+}
+
data class EbicsResponseContent(
val transactionID: String?,
val orderID: String?,
@@ -287,28 +199,6 @@ class HpbResponseData(
val authenticationVersion: String
)
-fun parseEbicsHpbOrder(orderDataRaw: InputStream): HpbResponseData {
- val resp = try {
- XMLUtil.convertToJaxb<HPBResponseOrderData>(orderDataRaw)
- } catch (e: Exception) {
- throw EbicsProtocolError(HttpStatusCode.InternalServerError, "Invalid XML (as HPB response) received from bank")
- }
- val encPubKey = CryptoUtil.loadRsaPublicKeyFromComponents(
- resp.value.encryptionPubKeyInfo.pubKeyValue.rsaKeyValue.modulus,
- resp.value.encryptionPubKeyInfo.pubKeyValue.rsaKeyValue.exponent
- )
- val authPubKey = CryptoUtil.loadRsaPublicKeyFromComponents(
- resp.value.authenticationPubKeyInfo.pubKeyValue.rsaKeyValue.modulus,
- resp.value.authenticationPubKeyInfo.pubKeyValue.rsaKeyValue.exponent
- )
- return HpbResponseData(
- hostID = resp.value.hostID,
- encryptionPubKey = encPubKey,
- encryptionVersion = resp.value.encryptionPubKeyInfo.encryptionVersion,
- authenticationPubKey = authPubKey,
- authenticationVersion = resp.value.authenticationPubKeyInfo.authenticationVersion
- )
-}
fun ebics3toInternalRepr(response: Document): EbicsResponseContent {
// TODO better ebics response type
@@ -360,65 +250,38 @@ fun ebics3toInternalRepr(response: Document): EbicsResponseContent {
}
}
-fun ebics25toInternalRepr(response: Document): EbicsResponseContent {
- val resp: JAXBElement<EbicsResponse> = try {
- XMLUtil.convertDomToJaxb(response)
- } catch (e: Exception) {
- throw EbicsProtocolError(
- HttpStatusCode.InternalServerError,
- "Could not transform string-response from bank into JAXB"
- )
- }
- val bankReturnCodeStr = resp.value.body.returnCode.value
- val bankReturnCode = EbicsReturnCode.lookup(bankReturnCodeStr)
-
- val techReturnCodeStr = resp.value.header.mutable.returnCode
- val techReturnCode = EbicsReturnCode.lookup(techReturnCodeStr)
-
- val reportText = resp.value.header.mutable.reportText
-
- val daeXml = resp.value.body.dataTransfer?.dataEncryptionInfo
- val dataEncryptionInfo = if (daeXml == null) {
- null
- } else {
- DataEncryptionInfo(daeXml.transactionKey, daeXml.encryptionPubKeyDigest.value)
- }
-
- return EbicsResponseContent(
- transactionID = resp.value.header._static.transactionID,
- orderID = resp.value.header.mutable.orderID,
- bankReturnCode = bankReturnCode,
- technicalReturnCode = techReturnCode,
- reportText = reportText,
- orderDataEncChunk = resp.value.body.dataTransfer?.orderData?.value,
- dataEncryptionInfo = dataEncryptionInfo,
- numSegments = resp.value.header._static.numSegments?.toInt(),
- segmentNumber = resp.value.header.mutable.segmentNumber?.value?.toInt()
- )
-}
+fun parseEbicsHpbOrder(orderDataRaw: InputStream): HpbResponseData {
+ return XmlDestructor.fromStream(orderDataRaw, "HPBResponseOrderData") {
+ val (authenticationPubKey, authenticationVersion) = one("AuthenticationPubKeyInfo") {
+ Pair(
+ one("PubKeyValue").one("RSAKeyValue") {
+ CryptoUtil.loadRsaPublicKeyFromComponents(
+ one("Modulus").text().decodeBase64(),
+ one("Exponent").text().decodeBase64(),
+ )
+ },
+ one("AuthenticationVersion").text()
+ )
+ }
+ val (encryptionPubKey, encryptionVersion) = one("EncryptionPubKeyInfo") {
+ Pair(
+ one("PubKeyValue").one("RSAKeyValue") {
+ CryptoUtil.loadRsaPublicKeyFromComponents(
+ one("Modulus").text().decodeBase64(),
+ one("Exponent").text().decodeBase64(),
+ )
+ },
+ one("EncryptionVersion").text()
+ )
-/**
- * Get the private key that matches the given public key digest.
- */
-fun getDecryptionKey(subscriberDetails: EbicsClientSubscriberDetails, pubDigest: ByteArray): RSAPrivateCrtKey {
- val authPub = CryptoUtil.getRsaPublicFromPrivate(subscriberDetails.customerAuthPriv)
- val encPub = CryptoUtil.getRsaPublicFromPrivate(subscriberDetails.customerEncPriv)
- val authPubDigest = CryptoUtil.getEbicsPublicKeyHash(authPub)
- val encPubDigest = CryptoUtil.getEbicsPublicKeyHash(encPub)
- if (pubDigest.contentEquals(authPubDigest)) {
- return subscriberDetails.customerAuthPriv
- }
- if (pubDigest.contentEquals(encPubDigest)) {
- return subscriberDetails.customerEncPriv
+ }
+ val hostID: String = one("HostID").text()
+ HpbResponseData(
+ hostID = hostID,
+ encryptionPubKey = encryptionPubKey,
+ encryptionVersion = encryptionVersion,
+ authenticationPubKey = authenticationPubKey,
+ authenticationVersion = authenticationVersion
+ )
}
- throw EbicsProtocolError(HttpStatusCode.NotFound, "Could not find customer's public key")
-}
-
-data class EbicsVersionSpec(
- val protocol: String,
- val version: String
-)
-
-data class EbicsHevDetails(
- val versions: List<EbicsVersionSpec>
-) \ No newline at end of file
+} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/EbicsOrderUtil.kt b/ebics/src/main/kotlin/EbicsOrderUtil.kt
deleted file mode 100644
index 79c78a29..00000000
--- a/ebics/src/main/kotlin/EbicsOrderUtil.kt
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.ebics
-
-import tech.libeufin.common.deflate
-import tech.libeufin.common.inflate
-import tech.libeufin.common.toHexString
-import java.security.SecureRandom
-
-/**
- * Helpers for dealing with order compression, encryption, decryption, chunking and re-assembly.
- */
-object EbicsOrderUtil {
-
- inline fun <reified T> decodeOrderDataXml(encodedOrderData: ByteArray): T {
- return encodedOrderData.inputStream().inflate().use {
- XMLUtil.convertToJaxb<T>(it).value
- }
- }
-
- inline fun <reified T> encodeOrderDataXml(obj: T): ByteArray {
- val bytes = XMLUtil.convertJaxbToBytes(obj)
- return bytes.inputStream().deflate().readAllBytes()
- }
-
- @ExperimentalStdlibApi
- fun generateTransactionId(): String {
- val rng = SecureRandom()
- val res = ByteArray(16)
- rng.nextBytes(res)
- return res.toHexString().uppercase()
- }
-
- /**
- * Calculate the resulting size of base64-encoding data of the given length,
- * including padding.
- */
- fun calculateBase64EncodedLength(dataLength: Int): Int {
- val blocks = (dataLength + 3 - 1) / 3
- return blocks * 4
- }
-
- fun checkOrderIDOverflow(n: Int): Boolean {
- if (n <= 0)
- throw IllegalArgumentException()
- val base = 10 + 26
- return n >= base * base
- }
-
- private fun getDigitChar(x: Int): Char {
- if (x < 10) {
- return '0' + x
- }
- return 'A' + (x - 10)
- }
-
- fun computeOrderIDFromNumber(n: Int): String {
- if (n <= 0)
- throw IllegalArgumentException()
- if (checkOrderIDOverflow(n))
- throw IllegalArgumentException()
- var ni = n
- val base = 10 + 26
- val x1 = ni % base
- ni = ni / base
- val x2 = ni % base
- val c1 = getDigitChar(x1)
- val c2 = getDigitChar(x2)
- return String(charArrayOf('O', 'R', c2, c1))
- }
-}
diff --git a/ebics/src/main/kotlin/XMLUtil.kt b/ebics/src/main/kotlin/XMLUtil.kt
index 3af1cd8c..b602adc0 100644
--- a/ebics/src/main/kotlin/XMLUtil.kt
+++ b/ebics/src/main/kotlin/XMLUtil.kt
@@ -19,7 +19,6 @@
package tech.libeufin.ebics
-import com.sun.xml.bind.marshaller.NamespacePrefixMapper
import io.ktor.http.*
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -32,15 +31,11 @@ import org.xml.sax.ErrorHandler
import org.xml.sax.InputSource
import org.xml.sax.SAXException
import org.xml.sax.SAXParseException
-import tech.libeufin.ebics.ebics_h004.EbicsResponse
import java.io.*
import java.security.PrivateKey
import java.security.PublicKey
import java.security.interfaces.RSAPrivateCrtKey
import javax.xml.XMLConstants
-import javax.xml.bind.JAXBContext
-import javax.xml.bind.JAXBElement
-import javax.xml.bind.Marshaller
import javax.xml.crypto.*
import javax.xml.crypto.dom.DOMURIReference
import javax.xml.crypto.dsig.*
@@ -64,449 +59,154 @@ import javax.xml.xpath.XPathFactory
private val logger: Logger = LoggerFactory.getLogger("libeufin-xml")
-class DefaultNamespaces : NamespacePrefixMapper() {
- override fun getPreferredPrefix(namespaceUri: String?, suggestion: String?, requirePrefix: Boolean): String? {
- if (namespaceUri == "http://www.w3.org/2000/09/xmldsig#") return "ds"
- if (namespaceUri == XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI) return "xsi"
- return null
- }
-}
-
-class DOMInputImpl : LSInput {
- var fPublicId: String? = null
- var fSystemId: String? = null
- var fBaseSystemId: String? = null
- var fByteStream: InputStream? = null
- var fCharStream: Reader? = null
- var fData: String? = null
- var fEncoding: String? = null
- var fCertifiedText = false
-
- override fun getByteStream(): InputStream? {
- return fByteStream
- }
-
- override fun setByteStream(byteStream: InputStream) {
- fByteStream = byteStream
- }
-
- override fun getCharacterStream(): Reader? {
- return fCharStream
- }
-
- override fun setCharacterStream(characterStream: Reader) {
- fCharStream = characterStream
- }
-
- override fun getStringData(): String? {
- return fData
- }
-
- override fun setStringData(stringData: String) {
- fData = stringData
- }
-
- override fun getEncoding(): String? {
- return fEncoding
- }
-
- override fun setEncoding(encoding: String) {
- fEncoding = encoding
- }
-
- override fun getPublicId(): String? {
- return fPublicId
- }
-
- override fun setPublicId(publicId: String) {
- fPublicId = publicId
- }
-
- override fun getSystemId(): String? {
- return fSystemId
- }
-
- override fun setSystemId(systemId: String) {
- fSystemId = systemId
- }
-
- override fun getBaseURI(): String? {
- return fBaseSystemId
- }
-
- override fun setBaseURI(baseURI: String) {
- fBaseSystemId = baseURI
- }
-
- override fun getCertifiedText(): Boolean {
- return fCertifiedText
- }
-
- override fun setCertifiedText(certifiedText: Boolean) {
- fCertifiedText = certifiedText
+/**
+ * This URI dereferencer allows handling the resource reference used for
+ * XML signatures in EBICS.
+ */
+private class EbicsSigUriDereferencer : URIDereferencer {
+ override fun dereference(myRef: URIReference?, myCtx: XMLCryptoContext?): Data {
+ if (myRef !is DOMURIReference)
+ throw Exception("invalid type")
+ if (myRef.uri != "#xpointer(//*[@authenticate='true'])")
+ throw Exception("invalid EBICS XML signature URI: '${myRef.uri}'")
+ val xp: XPath = XPathFactory.newInstance().newXPath()
+ val nodeSet = xp.compile("//*[@authenticate='true']/descendant-or-self::node()").evaluate(
+ myRef.here.ownerDocument, XPathConstants.NODESET
+ )
+ if (nodeSet !is NodeList)
+ throw Exception("invalid type")
+ if (nodeSet.length <= 0) {
+ throw Exception("no nodes to sign")
+ }
+ val nodeList = ArrayList<Node>()
+ for (i in 0 until nodeSet.length) {
+ val node = nodeSet.item(i)
+ nodeList.add(node)
+ }
+ return NodeSetData { nodeList.iterator() }
}
}
-
/**
* Helpers for dealing with XML in EBICS.
*/
-class XMLUtil private constructor() {
+object XMLUtil {
+ fun convertDomToBytes(document: Document): ByteArray {
+ val w = ByteArrayOutputStream()
+ val transformer = TransformerFactory.newInstance().newTransformer()
+ transformer.setOutputProperty(OutputKeys.STANDALONE, "yes")
+ transformer.transform(DOMSource(document), StreamResult(w))
+ return w.toByteArray()
+ }
+
/**
- * This URI dereferencer allows handling the resource reference used for
- * XML signatures in EBICS.
+ * Convert a node to a string without the XML declaration or
+ * indentation.
*/
- private class EbicsSigUriDereferencer : URIDereferencer {
- override fun dereference(myRef: URIReference?, myCtx: XMLCryptoContext?): Data {
- if (myRef !is DOMURIReference)
- throw Exception("invalid type")
- if (myRef.uri != "#xpointer(//*[@authenticate='true'])")
- throw Exception("invalid EBICS XML signature URI: '${myRef.uri}'")
- val xp: XPath = XPathFactory.newInstance().newXPath()
- val nodeSet = xp.compile("//*[@authenticate='true']/descendant-or-self::node()").evaluate(
- myRef.here.ownerDocument, XPathConstants.NODESET
- )
- if (nodeSet !is NodeList)
- throw Exception("invalid type")
- if (nodeSet.length <= 0) {
- throw Exception("no nodes to sign")
- }
- val nodeList = ArrayList<Node>()
- for (i in 0 until nodeSet.length) {
- val node = nodeSet.item(i)
- nodeList.add(node)
- }
- return NodeSetData { nodeList.iterator() }
- }
+ fun convertNodeToString(node: Node): String {
+ /* Make Transformer. */
+ val tf = TransformerFactory.newInstance()
+ val t = tf.newTransformer()
+ t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes")
+ /* Make string writer. */
+ val sw = StringWriter()
+ /* Extract string. */
+ t.transform(DOMSource(node), StreamResult(sw))
+ return sw.toString()
}
- companion object {
- private var cachedEbicsValidator: Validator? = null
- private fun getEbicsValidator(): Validator {
- val currentValidator = cachedEbicsValidator
- if (currentValidator != null)
- return currentValidator
- val classLoader = ClassLoader.getSystemClassLoader()
- val sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
- sf.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "file")
- sf.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "")
- sf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
- sf.errorHandler = object : ErrorHandler {
- override fun warning(p0: SAXParseException?) {
- println("Warning: $p0")
- }
-
- override fun error(p0: SAXParseException?) {
- println("Error: $p0")
- }
-
- override fun fatalError(p0: SAXParseException?) {
- println("Fatal error: $p0")
- }
- }
- sf.resourceResolver = object : LSResourceResolver {
- override fun resolveResource(
- type: String?,
- namespaceURI: String?,
- publicId: String?,
- systemId: String?,
- baseUri: String?
- ): LSInput? {
- if (type != "http://www.w3.org/2001/XMLSchema") {
- return null
- }
- val res = classLoader.getResourceAsStream("xsd/$systemId") ?: return null
- return DOMInputImpl().apply {
- fPublicId = publicId
- fSystemId = systemId
- fBaseSystemId = baseUri
- fByteStream = res
- fEncoding = "UTF-8"
- }
- }
- }
- val schemaInputs: Array<Source> = listOf(
- "xsd/ebics_H004.xsd",
- "xsd/ebics_H005.xsd",
- "xsd/ebics_hev.xsd",
- "xsd/camt.052.001.02.xsd",
- "xsd/camt.053.001.02.xsd",
- "xsd/camt.054.001.02.xsd",
- "xsd/pain.001.001.03.xsd",
- // "xsd/pain.001.001.03.ch.02.xsd", // Swiss 2013 version.
- "xsd/pain.001.001.09.ch.03.xsd" // Swiss 2019 version.
- ).map {
- val stream =
- classLoader.getResourceAsStream(it) ?: throw FileNotFoundException("Schema file $it not found.")
- StreamSource(stream)
- }.toTypedArray()
- val bundle = sf.newSchema(schemaInputs)
- val newValidator = bundle.newValidator()
- cachedEbicsValidator = newValidator
- return newValidator
+ /** Parse [xml] into a XML DOM */
+ fun parseIntoDom(xml: InputStream): Document {
+ val factory = DocumentBuilderFactory.newInstance().apply {
+ isNamespaceAware = true
}
-
- /**
- *
- * @param xmlDoc the XML document to validate
- * @return true when validation passes, false otherwise
- */
- @Synchronized fun validate(xmlDoc: StreamSource): Boolean {
- try {
- getEbicsValidator().validate(xmlDoc)
- } catch (e: Exception) {
- /**
- * Would be convenient to return also the error
- * message to the caller, so that it can link it
- * to a document ID in the logs.
- */
- logger.warn("Validation failed: ${e}")
- return false
- }
- return true
- }
-
- /**
- * Validates the DOM against the Schema(s) of this object.
- * @param domDocument DOM to validate
- * @return true/false if the document is valid/invalid
- */
- @Synchronized fun validateFromDom(domDocument: Document): Boolean {
- try {
- getEbicsValidator().validate(DOMSource(domDocument))
- } catch (e: SAXException) {
- e.printStackTrace()
- return false
- }
- return true
- }
-
- /**
- * Craft object to be passed to the XML validator.
- * @param xmlString XML body, as read from the POST body.
- * @return InputStream object, as wanted by the validator.
- */
- fun validateFromBytes(xml: ByteArray): Boolean {
- return validate(StreamSource(xml.inputStream()))
- }
-
- inline fun <reified T> convertJaxbToBytes(
- obj: T,
- withSchemaLocation: String? = null
- ): ByteArray {
- val w = ByteArrayOutputStream()
- val jc = JAXBContext.newInstance(T::class.java)
- val m = jc.createMarshaller()
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true)
- if (withSchemaLocation != null) {
- m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, withSchemaLocation)
- }
- m.setProperty("com.sun.xml.bind.namespacePrefixMapper", DefaultNamespaces())
- m.marshal(obj, w)
- return w.toByteArray()
- }
-
- inline fun <reified T> convertJaxbToDocument(
- obj: T,
- withSchemaLocation: String? = null
- ): Document {
- val dbf: DocumentBuilderFactory = DocumentBuilderFactory.newInstance()
- dbf.isNamespaceAware = true
- val doc = dbf.newDocumentBuilder().newDocument()
- val jc = JAXBContext.newInstance(T::class.java)
- val m = jc.createMarshaller()
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true)
- if (withSchemaLocation != null) {
- m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, withSchemaLocation)
- }
- m.setProperty("com.sun.xml.bind.namespacePrefixMapper", DefaultNamespaces())
- m.marshal(obj, doc)
- return doc
- }
-
- /**
- * Convert XML bytes to the JAXB representation.
- *
- * @param documentBytes the bytes to convert into JAXB.
- * @return the JAXB object reflecting the original XML document.
- */
- inline fun <reified T> convertToJaxb(documentBytes: InputStream): JAXBElement<T> {
- val jc = JAXBContext.newInstance(T::class.java)
- val u = jc.createUnmarshaller()
- return u.unmarshal( /* Marshalling the object into the document. */
- StreamSource(documentBytes),
- T::class.java
- )
- }
-
- fun convertDomToBytes(document: Document): ByteArray {
- val w = ByteArrayOutputStream()
- val transformer = TransformerFactory.newInstance().newTransformer()
- transformer.setOutputProperty(OutputKeys.STANDALONE, "yes")
- transformer.transform(DOMSource(document), StreamResult(w))
- return w.toByteArray()
- }
-
- /**
- * Convert a node to a string without the XML declaration or
- * indentation.
- */
- fun convertNodeToString(node: Node): String {
- /* Make Transformer. */
- val tf = TransformerFactory.newInstance()
- val t = tf.newTransformer()
- t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes")
- /* Make string writer. */
- val sw = StringWriter()
- /* Extract string. */
- t.transform(DOMSource(node), StreamResult(sw))
- return sw.toString()
- }
-
- /**
- * Convert a DOM document to the JAXB representation.
- *
- * @param document the document to convert into JAXB.
- * @return the JAXB object reflecting the original XML document.
- */
- inline fun <reified T> convertDomToJaxb(document: Document): JAXBElement<T> {
- val jc = JAXBContext.newInstance(T::class.java)
- /* Marshalling the object into the document. */
- val m = jc.createUnmarshaller()
- return m.unmarshal(document, T::class.java) // document "went" into Jaxb
- }
-
- /** Parse [xml] into a XML DOM */
- fun parseIntoDom(xml: InputStream): Document {
- val factory = DocumentBuilderFactory.newInstance().apply {
- isNamespaceAware = true
- }
- val builder = factory.newDocumentBuilder()
- return xml.use {
- builder.parse(InputSource(it))
- }
- }
-
- fun signEbicsResponse(ebicsResponse: EbicsResponse, privateKey: RSAPrivateCrtKey): ByteArray {
- val doc = convertJaxbToDocument(ebicsResponse)
- signEbicsDocument(doc, privateKey)
- val signedDoc = convertDomToBytes(doc)
- // logger.debug("response: $signedDoc")
- return signedDoc
- }
-
- /**
- * Sign an EBICS document with the authentication and identity signature.
- */
- fun signEbicsDocument(
- doc: Document,
- signingPriv: PrivateKey,
- withEbics3: Boolean = false
- ) {
- val ns = if (withEbics3) "urn:org:ebics:H005" else "urn:org:ebics:H004"
- val authSigNode = XPathFactory.newInstance().newXPath()
- .evaluate("/*[1]/$ns:AuthSignature", doc, XPathConstants.NODE)
- if (authSigNode !is Node)
- throw java.lang.Exception("no AuthSignature")
- val fac = XMLSignatureFactory.getInstance("DOM")
- val c14n = fac.newTransform(CanonicalizationMethod.INCLUSIVE, null as TransformParameterSpec?)
- val ref: Reference =
- fac.newReference(
- "#xpointer(//*[@authenticate='true'])",
- fac.newDigestMethod(DigestMethod.SHA256, null),
- listOf(c14n),
- null,
- null
- )
- val canon: CanonicalizationMethod =
- fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE, null as C14NMethodParameterSpec?)
- val signatureMethod = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null)
- val si: SignedInfo = fac.newSignedInfo(canon, signatureMethod, listOf(ref))
- val sig: XMLSignature = fac.newXMLSignature(si, null)
- val dsc = DOMSignContext(signingPriv, authSigNode)
- dsc.defaultNamespacePrefix = "ds"
- dsc.uriDereferencer = EbicsSigUriDereferencer()
- dsc.setProperty("javax.xml.crypto.dsig.cacheReference", true)
- sig.sign(dsc)
- val innerSig = authSigNode.firstChild
- while (innerSig.hasChildNodes()) {
- authSigNode.appendChild(innerSig.firstChild)
- }
- authSigNode.removeChild(innerSig)
- }
-
- fun verifyEbicsDocument(
- doc: Document,
- signingPub: PublicKey,
- withEbics3: Boolean = false
- ): Boolean {
- val doc2: Document = doc.cloneNode(true) as Document
- val ns = if (withEbics3) "urn:org:ebics:H005" else "urn:org:ebics:H004"
- val authSigNode = XPathFactory.newInstance().newXPath()
- .evaluate("/*[1]/$ns:AuthSignature", doc2, XPathConstants.NODE)
- if (authSigNode !is Node)
- throw java.lang.Exception("no AuthSignature")
- val sigEl = doc2.createElementNS("http://www.w3.org/2000/09/xmldsig#", "ds:Signature")
- authSigNode.parentNode.insertBefore(sigEl, authSigNode)
- while (authSigNode.hasChildNodes()) {
- sigEl.appendChild(authSigNode.firstChild)
- }
- authSigNode.parentNode.removeChild(authSigNode)
- val fac = XMLSignatureFactory.getInstance("DOM")
- val dvc = DOMValidateContext(signingPub, sigEl)
- dvc.setProperty("javax.xml.crypto.dsig.cacheReference", true)
- dvc.uriDereferencer = EbicsSigUriDereferencer()
- val sig = fac.unmarshalXMLSignature(dvc)
- // FIXME: check that parameters are okay!
- val valResult = sig.validate(dvc)
- sig.signedInfo.references[0].validate(dvc)
- return valResult
- }
-
- fun getNodeFromXpath(doc: Document, query: String): Node {
- val xpath = XPathFactory.newInstance().newXPath()
- val ret = xpath.evaluate(query, doc, XPathConstants.NODE)
- ?: throw EbicsProtocolError(HttpStatusCode.NotFound, "Unsuccessful XPath query string: $query")
- return ret as Node
- }
-
- fun getStringFromXpath(doc: Document, query: String): String {
- val xpath = XPathFactory.newInstance().newXPath()
- val ret = xpath.evaluate(query, doc, XPathConstants.STRING) as String
- if (ret.isEmpty()) {
- throw EbicsProtocolError(HttpStatusCode.NotFound, "Unsuccessful XPath query string: $query")
- }
- return ret
+ val builder = factory.newDocumentBuilder()
+ return xml.use {
+ builder.parse(InputSource(it))
}
}
-}
-fun Document.pickString(xpath: String): String {
- return XMLUtil.getStringFromXpath(this, xpath)
-}
-
-fun Document.pickStringWithRootNs(xpathQuery: String): String {
- val doc = this
- val xpath = XPathFactory.newInstance().newXPath()
- xpath.namespaceContext = object : NamespaceContext {
- override fun getNamespaceURI(p0: String?): String {
- return when (p0) {
- "root" -> doc.documentElement.namespaceURI
- else -> throw IllegalArgumentException()
- }
- }
-
- override fun getPrefix(p0: String?): String {
- throw UnsupportedOperationException()
- }
-
- override fun getPrefixes(p0: String?): MutableIterator<String> {
- throw UnsupportedOperationException()
- }
- }
- val ret = xpath.evaluate(xpathQuery, this, XPathConstants.STRING) as String
- if (ret.isEmpty()) {
- throw EbicsProtocolError(HttpStatusCode.NotFound, "Unsuccessful XPath query string: $xpathQuery")
+ /**
+ * Sign an EBICS document with the authentication and identity signature.
+ */
+ fun signEbicsDocument(
+ doc: Document,
+ signingPriv: PrivateKey,
+ withEbics3: Boolean = false
+ ) {
+ val ns = if (withEbics3) "urn:org:ebics:H005" else "urn:org:ebics:H004"
+ val authSigNode = XPathFactory.newInstance().newXPath()
+ .evaluate("/*[1]/$ns:AuthSignature", doc, XPathConstants.NODE)
+ if (authSigNode !is Node)
+ throw java.lang.Exception("no AuthSignature")
+ val fac = XMLSignatureFactory.getInstance("DOM")
+ val c14n = fac.newTransform(CanonicalizationMethod.INCLUSIVE, null as TransformParameterSpec?)
+ val ref: Reference =
+ fac.newReference(
+ "#xpointer(//*[@authenticate='true'])",
+ fac.newDigestMethod(DigestMethod.SHA256, null),
+ listOf(c14n),
+ null,
+ null
+ )
+ val canon: CanonicalizationMethod =
+ fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE, null as C14NMethodParameterSpec?)
+ val signatureMethod = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null)
+ val si: SignedInfo = fac.newSignedInfo(canon, signatureMethod, listOf(ref))
+ val sig: XMLSignature = fac.newXMLSignature(si, null)
+ val dsc = DOMSignContext(signingPriv, authSigNode)
+ dsc.defaultNamespacePrefix = "ds"
+ dsc.uriDereferencer = EbicsSigUriDereferencer()
+ dsc.setProperty("javax.xml.crypto.dsig.cacheReference", true)
+ sig.sign(dsc)
+ val innerSig = authSigNode.firstChild
+ while (innerSig.hasChildNodes()) {
+ authSigNode.appendChild(innerSig.firstChild)
+ }
+ authSigNode.removeChild(innerSig)
+ }
+
+ fun verifyEbicsDocument(
+ doc: Document,
+ signingPub: PublicKey,
+ withEbics3: Boolean = false
+ ): Boolean {
+ val doc2: Document = doc.cloneNode(true) as Document
+ val ns = if (withEbics3) "urn:org:ebics:H005" else "urn:org:ebics:H004"
+ val authSigNode = XPathFactory.newInstance().newXPath()
+ .evaluate("/*[1]/$ns:AuthSignature", doc2, XPathConstants.NODE)
+ if (authSigNode !is Node)
+ throw java.lang.Exception("no AuthSignature")
+ val sigEl = doc2.createElementNS("http://www.w3.org/2000/09/xmldsig#", "ds:Signature")
+ authSigNode.parentNode.insertBefore(sigEl, authSigNode)
+ while (authSigNode.hasChildNodes()) {
+ sigEl.appendChild(authSigNode.firstChild)
+ }
+ authSigNode.parentNode.removeChild(authSigNode)
+ val fac = XMLSignatureFactory.getInstance("DOM")
+ val dvc = DOMValidateContext(signingPub, sigEl)
+ dvc.setProperty("javax.xml.crypto.dsig.cacheReference", true)
+ dvc.uriDereferencer = EbicsSigUriDereferencer()
+ val sig = fac.unmarshalXMLSignature(dvc)
+ // FIXME: check that parameters are okay!
+ val valResult = sig.validate(dvc)
+ sig.signedInfo.references[0].validate(dvc)
+ return valResult
+ }
+
+ fun getNodeFromXpath(doc: Document, query: String): Node {
+ val xpath = XPathFactory.newInstance().newXPath()
+ val ret = xpath.evaluate(query, doc, XPathConstants.NODE)
+ ?: throw EbicsProtocolError(HttpStatusCode.NotFound, "Unsuccessful XPath query string: $query")
+ return ret as Node
+ }
+
+ fun getStringFromXpath(doc: Document, query: String): String {
+ val xpath = XPathFactory.newInstance().newXPath()
+ val ret = xpath.evaluate(query, doc, XPathConstants.STRING) as String
+ if (ret.isEmpty()) {
+ throw EbicsProtocolError(HttpStatusCode.NotFound, "Unsuccessful XPath query string: $query")
+ }
+ return ret
}
- return ret
} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_h004/EbicsKeyManagementResponse.kt b/ebics/src/main/kotlin/ebics_h004/EbicsKeyManagementResponse.kt
deleted file mode 100644
index 74d99c94..00000000
--- a/ebics/src/main/kotlin/ebics_h004/EbicsKeyManagementResponse.kt
+++ /dev/null
@@ -1,102 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.NormalizedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["header", "body"])
-@XmlRootElement(name = "ebicsKeyManagementResponse")
-class EbicsKeyManagementResponse {
- @get:XmlElement(required = true)
- lateinit var header: Header
-
- @get:XmlElement(required = true)
- lateinit var body: Body
-
- @get:XmlAttribute(name = "Version", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var version: String
-
- @get:XmlAttribute(name = "Revision")
- var revision: Int? = null
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["_static", "mutable"])
- class Header {
- @get:XmlElement(name = "static", required = true)
- lateinit var _static: EmptyStaticHeader
-
- @get:XmlElement(required = true)
- lateinit var mutable: MutableHeaderType
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["orderID", "returnCode", "reportText"])
- class MutableHeaderType {
- @get:XmlElement(name = "OrderID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- var orderID: String? = null
-
- @get:XmlElement(name = "ReturnCode", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var returnCode: String
-
- @get:XmlElement(name = "ReportText", required = true)
- @get:XmlJavaTypeAdapter(NormalizedStringAdapter::class)
- @get:XmlSchemaType(name = "normalizedString")
- lateinit var reportText: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "")
- class EmptyStaticHeader
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["dataTransfer", "returnCode", "timestampBankParameter"])
- class Body {
- @get:XmlElement(name = "DataTransfer")
- var dataTransfer: DataTransfer? = null
-
- @get:XmlElement(name = "ReturnCode", required = true)
- lateinit var returnCode: ReturnCode
-
- @get:XmlElement(name = "TimestampBankParameter")
- var timestampBankParameter: EbicsTypes.TimestampBankParameter? = null
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- class ReturnCode {
- @get:XmlValue
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var value: String
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["dataEncryptionInfo", "orderData"])
- class DataTransfer {
- @get:XmlElement(name = "DataEncryptionInfo")
- var dataEncryptionInfo: EbicsTypes.DataEncryptionInfo? = null
-
- @get:XmlElement(name = "OrderData", required = true)
- lateinit var orderData: OrderData
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class OrderData {
- @get:XmlValue
- lateinit var value: String
- }
-}
diff --git a/ebics/src/main/kotlin/ebics_h004/EbicsNpkdRequest.kt b/ebics/src/main/kotlin/ebics_h004/EbicsNpkdRequest.kt
deleted file mode 100644
index 2330ca0b..00000000
--- a/ebics/src/main/kotlin/ebics_h004/EbicsNpkdRequest.kt
+++ /dev/null
@@ -1,135 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import org.apache.xml.security.binding.xmldsig.SignatureType
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.HexBinaryAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-import javax.xml.datatype.XMLGregorianCalendar
-
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["header", "authSignature", "body"])
-@XmlRootElement(name = "ebicsNoPubKeyDigestsRequest")
-class EbicsNpkdRequest {
- @get:XmlAttribute(name = "Version", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var version: String
-
- @get:XmlAttribute(name = "Revision")
- var revision: Int? = null
-
- @get:XmlElement(name = "header", required = true)
- lateinit var header: Header
-
- @get:XmlElement(name = "AuthSignature", required = true)
- lateinit var authSignature: SignatureType
-
- @get:XmlElement(required = true)
- lateinit var body: EmptyBody
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["static", "mutable"])
- class Header {
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
-
- @get:XmlElement(name = "static", required = true)
- lateinit var static: StaticHeaderType
-
- @get:XmlElement(required = true)
- lateinit var mutable: EmptyMutableHeader
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "StaticHeader",
- propOrder = ["hostID", "nonce", "timestamp", "partnerID", "userID", "systemID", "product", "orderDetails", "securityMedium"]
- )
- class StaticHeaderType {
- @get:XmlElement(name = "HostID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var hostID: String
-
- @get:XmlElement(name = "Nonce", type = String::class)
- @get:XmlJavaTypeAdapter(HexBinaryAdapter::class)
- @get:XmlSchemaType(name = "hexBinary")
- lateinit var nonce: ByteArray
-
- @get:XmlElement(name = "Timestamp")
- @get:XmlSchemaType(name = "dateTime")
- var timestamp: XMLGregorianCalendar? = null
-
- @get:XmlElement(name = "PartnerID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var partnerID: String
-
- @get:XmlElement(name = "UserID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var userID: String
-
- @get:XmlElement(name = "SystemID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var systemID: String? = null
-
- @get:XmlElement(name = "Product")
- val product: EbicsTypes.Product? = null
-
- @get:XmlElement(name = "OrderDetails", required = true)
- lateinit var orderDetails: OrderDetails
-
- @get:XmlElement(name = "SecurityMedium", required = true)
- lateinit var securityMedium: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["orderType", "orderAttribute"])
- class OrderDetails {
- @get:XmlElement(name = "OrderType", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var orderType: String
-
- @get:XmlElement(name = "OrderAttribute", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var orderAttribute: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "")
- class EmptyMutableHeader
-
- @XmlAccessorType(XmlAccessType.NONE)
- class EmptyBody
-
- companion object {
- fun createRequest(
- hostId: String,
- partnerId: String,
- userId: String,
- aNonce: ByteArray,
- date: XMLGregorianCalendar
- ): EbicsNpkdRequest {
- return EbicsNpkdRequest().apply {
- version = "H004"
- revision = 1
- header = Header().apply {
- authenticate = true
- mutable = EmptyMutableHeader()
- static = StaticHeaderType().apply {
- hostID = hostId
- partnerID = partnerId
- userID = userId
- securityMedium = "0000"
- orderDetails = OrderDetails()
- orderDetails.orderType = "HPB"
- orderDetails.orderAttribute = "DZHNN"
- nonce = aNonce
- timestamp = date
- }
- }
- body = EmptyBody()
- authSignature = SignatureType()
- }
- }
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_h004/EbicsRequest.kt b/ebics/src/main/kotlin/ebics_h004/EbicsRequest.kt
deleted file mode 100644
index 7ca7c6b9..00000000
--- a/ebics/src/main/kotlin/ebics_h004/EbicsRequest.kt
+++ /dev/null
@@ -1,504 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import org.apache.xml.security.binding.xmldsig.SignatureType
-import tech.libeufin.common.crypto.CryptoUtil
-import java.math.BigInteger
-import java.security.interfaces.RSAPublicKey
-import java.util.*
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.HexBinaryAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-import javax.xml.datatype.XMLGregorianCalendar
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["header", "authSignature", "body"])
-@XmlRootElement(name = "ebicsRequest")
-class EbicsRequest {
- @get:XmlAttribute(name = "Version", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var version: String
-
- @get:XmlAttribute(name = "Revision")
- var revision: Int? = null
-
- @get:XmlElement(name = "header", required = true)
- lateinit var header: Header
-
- @get:XmlElement(name = "AuthSignature", required = true)
- lateinit var authSignature: SignatureType
-
- @get:XmlElement(name = "body")
- lateinit var body: Body
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["static", "mutable"])
- class Header {
- @get:XmlElement(name = "static", required = true)
- lateinit var static: StaticHeaderType
-
- @get:XmlElement(required = true)
- lateinit var mutable: MutableHeader
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = [
- "hostID", "nonce", "timestamp", "partnerID", "userID", "systemID",
- "product", "orderDetails", "bankPubKeyDigests", "securityMedium",
- "numSegments", "transactionID"
- ]
- )
- class StaticHeaderType {
- @get:XmlElement(name = "HostID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var hostID: String
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "Nonce", type = String::class)
- @get:XmlJavaTypeAdapter(HexBinaryAdapter::class)
- @get:XmlSchemaType(name = "hexBinary")
- var nonce: ByteArray? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "Timestamp")
- @get:XmlSchemaType(name = "dateTime")
- var timestamp: XMLGregorianCalendar? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "PartnerID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var partnerID: String? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "UserID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var userID: String? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "SystemID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var systemID: String? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "Product")
- var product: EbicsTypes.Product? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "OrderDetails")
- var orderDetails: OrderDetails? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "BankPubKeyDigests")
- var bankPubKeyDigests: BankPubKeyDigests? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "SecurityMedium")
- var securityMedium: String? = null
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElement(name = "NumSegments")
- var numSegments: BigInteger? = null
-
- /**
- * Present only in the transaction / finalization phase.
- */
- @get:XmlElement(name = "TransactionID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var transactionID: String? = null
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["transactionPhase", "segmentNumber"])
- class MutableHeader {
- @get:XmlElement(name = "TransactionPhase", required = true)
- @get:XmlSchemaType(name = "token")
- lateinit var transactionPhase: EbicsTypes.TransactionPhaseType
-
- /**
- * Number of the currently transmitted segment, if this message
- * contains order data.
- */
- @get:XmlElement(name = "SegmentNumber")
- var segmentNumber: EbicsTypes.SegmentNumber? = null
-
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = ["orderType", "orderID", "orderAttribute", "orderParams"]
- )
- class OrderDetails {
- @get:XmlElement(name = "OrderType", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var orderType: String
-
- /**
- * Only present if this ebicsRequest is an upload order
- * relating to an already existing order.
- */
- @get:XmlElement(name = "OrderID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var orderID: String? = null
-
- @get:XmlElement(name = "OrderAttribute", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var orderAttribute: String
-
- /**
- * Present only in the initialization phase.
- */
- @get:XmlElements(
- XmlElement(
- name = "StandardOrderParams",
- type = StandardOrderParams::class
- ),
- XmlElement(
- name = "GenericOrderParams",
- type = GenericOrderParams::class
- )
- )
- var orderParams: OrderParams? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(propOrder = ["preValidation", "dataTransfer", "transferReceipt"])
- class Body {
- @get:XmlElement(name = "PreValidation")
- var preValidation: PreValidation? = null
-
- @get:XmlElement(name = "DataTransfer")
- var dataTransfer: DataTransfer? = null
-
- @get:XmlElement(name = "TransferReceipt")
- var transferReceipt: TransferReceipt? = null
- }
-
- /**
- * FIXME: not implemented yet
- */
- @XmlAccessorType(XmlAccessType.NONE)
- class PreValidation {
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class SignatureData {
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
-
- @get:XmlValue
- var value: ByteArray? = null
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(propOrder = ["dataEncryptionInfo", "signatureData", "orderData", "hostId"])
- class DataTransfer {
-
- @get:XmlElement(name = "DataEncryptionInfo")
- var dataEncryptionInfo: EbicsTypes.DataEncryptionInfo? = null
-
- @get:XmlElement(name = "SignatureData")
- var signatureData: SignatureData? = null
-
- @get:XmlElement(name = "OrderData")
- var orderData: String? = null
-
- @get:XmlElement(name = "HostID")
- var hostId: String? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["receiptCode"])
- class TransferReceipt {
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
-
- @get:XmlElement(name = "ReceiptCode")
- var receiptCode: Int? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- abstract class OrderParams
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["dateRange"])
- class StandardOrderParams : OrderParams() {
- @get:XmlElement(name = "DateRange")
- var dateRange: DateRange? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["parameterList"])
- class GenericOrderParams : OrderParams() {
- @get:XmlElement(type = EbicsTypes.Parameter::class)
- var parameterList: List<EbicsTypes.Parameter> = LinkedList()
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["start", "end"])
- class DateRange {
- @get:XmlElement(name = "Start")
- @get:XmlSchemaType(name = "date")
- lateinit var start: XMLGregorianCalendar
-
- @get:XmlElement(name = "End")
- @get:XmlSchemaType(name = "date")
- lateinit var end: XMLGregorianCalendar
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["authentication", "encryption"])
- class BankPubKeyDigests {
- @get:XmlElement(name = "Authentication")
- lateinit var authentication: EbicsTypes.PubKeyDigest
-
- @get:XmlElement(name = "Encryption")
- lateinit var encryption: EbicsTypes.PubKeyDigest
- }
-
- companion object {
- fun createForDownloadReceiptPhase(
- transactionId: String,
- hostId: String,
- success: Boolean
- ): EbicsRequest {
- return EbicsRequest().apply {
- header = Header().apply {
- version = "H004"
- revision = 1
- authenticate = true
- static = StaticHeaderType().apply {
- hostID = hostId
- transactionID = transactionId
- }
- mutable = MutableHeader().apply {
- transactionPhase = EbicsTypes.TransactionPhaseType.RECEIPT
- }
- }
- authSignature = SignatureType()
-
- body = Body().apply {
- transferReceipt = TransferReceipt().apply {
- authenticate = true
- receiptCode = if (success) 0 else 1
- }
- }
- }
- }
-
- fun createForDownloadInitializationPhase(
- userId: String,
- partnerId: String,
- hostId: String,
- nonceArg: ByteArray,
- date: XMLGregorianCalendar,
- bankEncPub: RSAPublicKey,
- bankAuthPub: RSAPublicKey,
- myOrderType: String,
- myOrderParams: OrderParams
- ): EbicsRequest {
- return EbicsRequest().apply {
- version = "H004"
- revision = 1
- authSignature = SignatureType()
- body = Body()
- header = Header().apply {
- authenticate = true
- static = StaticHeaderType().apply {
- userID = userId
- partnerID = partnerId
- hostID = hostId
- nonce = nonceArg
- timestamp = date
- partnerID = partnerId
- orderDetails = OrderDetails().apply {
- orderType = myOrderType
- orderAttribute = "DZHNN"
- orderParams = myOrderParams
- }
- bankPubKeyDigests = BankPubKeyDigests().apply {
- authentication = EbicsTypes.PubKeyDigest().apply {
- algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
- version = "X002"
- value = CryptoUtil.getEbicsPublicKeyHash(bankAuthPub)
- }
- encryption = EbicsTypes.PubKeyDigest().apply {
- algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
- version = "E002"
- value = CryptoUtil.getEbicsPublicKeyHash(bankEncPub)
- }
- securityMedium = "0000"
- }
- }
- mutable = MutableHeader().apply {
- transactionPhase =
- EbicsTypes.TransactionPhaseType.INITIALISATION
- }
- }
- }
- }
-
- fun createForUploadInitializationPhase(
- encryptedTransactionKey: ByteArray,
- encryptedSignatureData: ByteArray,
- hostId: String,
- nonceArg: ByteArray,
- partnerId: String,
- userId: String,
- date: XMLGregorianCalendar,
- bankAuthPub: RSAPublicKey,
- bankEncPub: RSAPublicKey,
- segmentsNumber: BigInteger,
- aOrderType: String,
- aOrderParams: OrderParams
- ): EbicsRequest {
-
- return EbicsRequest().apply {
- header = Header().apply {
- version = "H004"
- revision = 1
- authenticate = true
- static = StaticHeaderType().apply {
- hostID = hostId
- nonce = nonceArg
- timestamp = date
- partnerID = partnerId
- userID = userId
- orderDetails = OrderDetails().apply {
- orderType = aOrderType
- orderAttribute = "OZHNN"
- orderParams = aOrderParams
- }
- bankPubKeyDigests = BankPubKeyDigests().apply {
- authentication = EbicsTypes.PubKeyDigest().apply {
- algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
- version = "X002"
- value = CryptoUtil.getEbicsPublicKeyHash(bankAuthPub)
- }
- encryption = EbicsTypes.PubKeyDigest().apply {
- algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
- version = "E002"
- value = CryptoUtil.getEbicsPublicKeyHash(bankEncPub)
- }
- }
- securityMedium = "0000"
- numSegments = segmentsNumber
- }
- mutable = MutableHeader().apply {
- transactionPhase =
- EbicsTypes.TransactionPhaseType.INITIALISATION
- }
- }
- authSignature = SignatureType()
- body = Body().apply {
- dataTransfer = DataTransfer().apply {
- signatureData = SignatureData().apply {
- authenticate = true
- value = encryptedSignatureData
- }
- dataEncryptionInfo = EbicsTypes.DataEncryptionInfo().apply {
- transactionKey = encryptedTransactionKey
- authenticate = true
- encryptionPubKeyDigest = EbicsTypes.PubKeyDigest().apply {
- algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
- version = "E002"
- value = CryptoUtil.getEbicsPublicKeyHash(bankEncPub)
- }
- }
- }
- }
- }
- }
-
- fun createForUploadTransferPhase(
- hostId: String,
- transactionId: String?,
- segNumber: BigInteger,
- encryptedData: String
- ): EbicsRequest {
- return EbicsRequest().apply {
- header = Header().apply {
- version = "H004"
- revision = 1
- authenticate = true
- static = StaticHeaderType().apply {
- hostID = hostId
- transactionID = transactionId
- }
- mutable = MutableHeader().apply {
- transactionPhase = EbicsTypes.TransactionPhaseType.TRANSFER
- segmentNumber = EbicsTypes.SegmentNumber().apply {
- lastSegment = true
- value = segNumber
- }
- }
- }
-
- authSignature = SignatureType()
- body = Body().apply {
- dataTransfer = DataTransfer().apply {
- orderData = encryptedData
- }
- }
- }
- }
-
- fun createForDownloadTransferPhase(
- hostID: String,
- transactionID: String?,
- segmentNumber: Int,
- numSegments: Int
- ): EbicsRequest {
- return EbicsRequest().apply {
- version = "H004"
- revision = 1
- authSignature = SignatureType()
- body = Body()
- header = Header().apply {
- authenticate = true
- static = StaticHeaderType().apply {
- this.hostID = hostID
- this.transactionID = transactionID
- }
- mutable = MutableHeader().apply {
- transactionPhase =
- EbicsTypes.TransactionPhaseType.TRANSFER
- this.segmentNumber = EbicsTypes.SegmentNumber().apply {
- this.value = BigInteger.valueOf(segmentNumber.toLong())
- this.lastSegment = segmentNumber == numSegments
- }
- }
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_h004/EbicsResponse.kt b/ebics/src/main/kotlin/ebics_h004/EbicsResponse.kt
deleted file mode 100644
index 373bb8f3..00000000
--- a/ebics/src/main/kotlin/ebics_h004/EbicsResponse.kt
+++ /dev/null
@@ -1,348 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import org.apache.xml.security.binding.xmldsig.SignatureType
-import tech.libeufin.common.crypto.CryptoUtil
-import java.math.BigInteger
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.NormalizedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-import kotlin.math.min
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["header", "authSignature", "body"])
-@XmlRootElement(name = "ebicsResponse")
-class EbicsResponse {
- @get:XmlAttribute(name = "Version", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var version: String
-
- @get:XmlAttribute(name = "Revision")
- var revision: Int? = null
-
- @get:XmlElement(required = true)
- lateinit var header: Header
-
- @get:XmlElement(name = "AuthSignature", required = true)
- lateinit var authSignature: SignatureType
-
- @get:XmlElement(required = true)
- lateinit var body: Body
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["_static", "mutable"])
- class Header {
- @get:XmlElement(name = "static", required = true)
- lateinit var _static: StaticHeaderType
-
- @get:XmlElement(required = true)
- lateinit var mutable: MutableHeaderType
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["dataTransfer", "returnCode", "timestampBankParameter"])
- class Body {
- @get:XmlElement(name = "DataTransfer")
- var dataTransfer: DataTransferResponseType? = null
-
- @get:XmlElement(name = "ReturnCode", required = true)
- lateinit var returnCode: ReturnCode
-
- @get:XmlElement(name = "TimestampBankParameter")
- var timestampBankParameter: EbicsTypes.TimestampBankParameter? = null
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = ["transactionPhase", "segmentNumber", "orderID", "returnCode", "reportText"]
- )
- class MutableHeaderType {
- @get:XmlElement(name = "TransactionPhase", required = true)
- @get:XmlSchemaType(name = "token")
- lateinit var transactionPhase: EbicsTypes.TransactionPhaseType
-
- @get:XmlElement(name = "SegmentNumber")
- var segmentNumber: EbicsTypes.SegmentNumber? = null
-
- @get:XmlElement(name = "OrderID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- var orderID: String? = null
-
- @get:XmlElement(name = "ReturnCode", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var returnCode: String
-
- @get:XmlElement(name = "ReportText", required = true)
- @get:XmlJavaTypeAdapter(NormalizedStringAdapter::class)
- @get:XmlSchemaType(name = "normalizedString")
- lateinit var reportText: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class OrderData {
- @get:XmlValue
- lateinit var value: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class ReturnCode {
- @get:XmlValue
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var value: String
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "DataTransferResponseType", propOrder = ["dataEncryptionInfo", "orderData"])
- class DataTransferResponseType {
- @get:XmlElement(name = "DataEncryptionInfo")
- var dataEncryptionInfo: EbicsTypes.DataEncryptionInfo? = null
-
- @get:XmlElement(name = "OrderData", required = true)
- lateinit var orderData: OrderData
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "ResponseStaticHeaderType", propOrder = ["transactionID", "numSegments"])
- class StaticHeaderType {
- @get:XmlElement(name = "TransactionID")
- var transactionID: String? = null
-
- @get:XmlElement(name = "NumSegments")
- @get:XmlSchemaType(name = "positiveInteger")
- var numSegments: BigInteger? = null
- }
-
- companion object {
-
- fun createForUploadWithError(
- errorText: String, errorCode: String, phase: EbicsTypes.TransactionPhaseType
- ): EbicsResponse {
- val resp = EbicsResponse().apply {
- this.version = "H004"
- this.revision = 1
- this.header = Header().apply {
- this.authenticate = true
- this.mutable = MutableHeaderType().apply {
- this.reportText = errorText
- this.returnCode = errorCode
- this.transactionPhase = phase
- }
- _static = StaticHeaderType()
- }
- this.authSignature = SignatureType()
- this.body = Body().apply {
- this.returnCode = ReturnCode().apply {
- this.authenticate = true
- this.value = errorCode
- }
- }
- }
- return resp
- }
-
- fun createForUploadInitializationPhase(transactionID: String, orderID: String): EbicsResponse {
- return EbicsResponse().apply {
- this.version = "H004"
- this.revision = 1
- this.header = Header().apply {
- this.authenticate = true
- this._static = StaticHeaderType().apply {
- this.transactionID = transactionID
- }
- this.mutable = MutableHeaderType().apply {
- this.transactionPhase =
- EbicsTypes.TransactionPhaseType.INITIALISATION
- this.orderID = orderID
- this.reportText = "[EBICS_OK] OK"
- this.returnCode = "000000"
- }
- }
- this.authSignature = SignatureType()
- this.body = Body().apply {
- this.returnCode = ReturnCode().apply {
- this.authenticate = true
- this.value = "000000"
- }
- }
- }
- }
-
- fun createForDownloadReceiptPhase(transactionID: String, positiveAck: Boolean): EbicsResponse {
- return EbicsResponse().apply {
- this.version = "H004"
- this.revision = 1
- this.header = Header().apply {
- this.authenticate = true
- this._static = StaticHeaderType().apply {
- this.transactionID = transactionID
- }
- this.mutable = MutableHeaderType().apply {
- this.transactionPhase =
- EbicsTypes.TransactionPhaseType.RECEIPT
- if (positiveAck) {
- this.reportText = "[EBICS_DOWNLOAD_POSTPROCESS_DONE] Received positive receipt"
- this.returnCode = "011000"
- } else {
- this.reportText = "[EBICS_DOWNLOAD_POSTPROCESS_SKIPPED] Received negative receipt"
- this.returnCode = "011001"
- }
- }
- }
- this.authSignature = SignatureType()
- this.body = Body().apply {
- this.returnCode = ReturnCode().apply {
- this.authenticate = true
- this.value = "000000"
- }
- }
- }
- }
-
- fun createForUploadTransferPhase(
- transactionID: String,
- segmentNumber: Int,
- lastSegment: Boolean,
- orderID: String
- ): EbicsResponse {
- return EbicsResponse().apply {
- this.version = "H004"
- this.revision = 1
- this.header = Header().apply {
- this.authenticate = true
- this._static = StaticHeaderType().apply {
- this.transactionID = transactionID
- }
- this.mutable = MutableHeaderType().apply {
- this.transactionPhase =
- EbicsTypes.TransactionPhaseType.TRANSFER
- this.segmentNumber = EbicsTypes.SegmentNumber().apply {
- this.value = BigInteger.valueOf(segmentNumber.toLong())
- if (lastSegment) {
- this.lastSegment = true
- }
- }
- this.orderID = orderID
- this.reportText = "[EBICS_OK] OK"
- this.returnCode = "000000"
- }
- }
- this.authSignature = SignatureType()
- this.body = Body().apply {
- this.returnCode = ReturnCode().apply {
- this.authenticate = true
- this.value = "000000"
- }
- }
- }
- }
-
- /**
- * @param requestedSegment requested segment as a 1-based index
- */
- fun createForDownloadTransferPhase(
- transactionID: String,
- numSegments: Int,
- segmentSize: Int,
- encodedData: String,
- requestedSegment: Int
- ): EbicsResponse {
- return EbicsResponse().apply {
- this.version = "H004"
- this.revision = 1
- this.header = Header().apply {
- this.authenticate = true
- this._static = StaticHeaderType().apply {
- this.transactionID = transactionID
- this.numSegments = BigInteger.valueOf(numSegments.toLong())
- }
- this.mutable = MutableHeaderType().apply {
- this.transactionPhase =
- EbicsTypes.TransactionPhaseType.TRANSFER
- this.segmentNumber = EbicsTypes.SegmentNumber().apply {
- this.lastSegment = numSegments == requestedSegment
- this.value = BigInteger.valueOf(requestedSegment.toLong())
- }
- this.reportText = "[EBICS_OK] OK"
- this.returnCode = "000000"
- }
- }
- this.authSignature = SignatureType()
- this.body = Body().apply {
- this.returnCode = ReturnCode().apply {
- this.authenticate = true
- this.value = "000000"
- }
- this.dataTransfer = DataTransferResponseType().apply {
- this.orderData = OrderData().apply {
- val start = segmentSize * (requestedSegment - 1)
- this.value = encodedData.substring(start, min(start + segmentSize, encodedData.length))
- }
- }
- }
- }
- }
-
- fun createForDownloadInitializationPhase(
- transactionID: String,
- numSegments: Int,
- segmentSize: Int,
- enc: CryptoUtil.EncryptionResult,
- encodedData: String
- ): EbicsResponse {
- return EbicsResponse().apply {
- this.version = "H004"
- this.revision = 1
- this.header = Header().apply {
- this.authenticate = true
- this._static = StaticHeaderType().apply {
- this.transactionID = transactionID
- this.numSegments = BigInteger.valueOf(numSegments.toLong())
- }
- this.mutable = MutableHeaderType().apply {
- this.transactionPhase =
- EbicsTypes.TransactionPhaseType.INITIALISATION
- this.segmentNumber = EbicsTypes.SegmentNumber().apply {
- this.lastSegment = (numSegments == 1)
- this.value = BigInteger.valueOf(1)
- }
- this.reportText = "[EBICS_OK] OK"
- this.returnCode = "000000"
- }
- }
- this.authSignature = SignatureType()
- this.body = Body().apply {
- this.returnCode = ReturnCode().apply {
- this.authenticate = true
- this.value = "000000"
- }
- this.dataTransfer = DataTransferResponseType().apply {
- this.dataEncryptionInfo = EbicsTypes.DataEncryptionInfo().apply {
- this.authenticate = true
- this.encryptionPubKeyDigest = EbicsTypes.PubKeyDigest()
- .apply {
- this.algorithm = "http://www.w3.org/2001/04/xmlenc#sha256"
- this.version = "E002"
- this.value = enc.pubKeyDigest
- }
- this.transactionKey = enc.encryptedTransactionKey
- }
- this.orderData = OrderData().apply {
- this.value = encodedData.substring(0, min(segmentSize, encodedData.length))
- }
- }
- }
- }
- }
- }
-}
diff --git a/ebics/src/main/kotlin/ebics_h004/EbicsTypes.kt b/ebics/src/main/kotlin/ebics_h004/EbicsTypes.kt
deleted file mode 100644
index a2486408..00000000
--- a/ebics/src/main/kotlin/ebics_h004/EbicsTypes.kt
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * This file is part of LibEuFin.
- * Copyright (C) 2019 Stanisci and Dold.
-
- * 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.ebics.ebics_h004
-
-import org.apache.xml.security.binding.xmldsig.RSAKeyValueType
-import org.w3c.dom.Element
-import java.math.BigInteger
-import java.util.*
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.NormalizedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-import javax.xml.datatype.XMLGregorianCalendar
-
-
-/**
- * EBICS type definitions that are shared between other requests / responses / order types.
- */
-object EbicsTypes {
- /**
- * EBICS client product. Identifies the software that accesses the EBICS host.
- */
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "Product", propOrder = ["value"])
- class Product {
- @get:XmlValue
- @get:XmlJavaTypeAdapter(NormalizedStringAdapter::class)
- lateinit var value: String
-
- @get:XmlAttribute(name = "Language", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var language: String
-
- @get:XmlAttribute(name = "InstituteID")
- @get:XmlJavaTypeAdapter(NormalizedStringAdapter::class)
- var instituteID: String? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["value"])
- class SegmentNumber {
- @XmlValue
- lateinit var value: BigInteger
-
- @XmlAttribute(name = "lastSegment")
- var lastSegment: Boolean? = null
- }
-
-
- @XmlType(name = "", propOrder = ["encryptionPubKeyDigest", "transactionKey"])
- @XmlAccessorType(XmlAccessType.NONE)
- class DataEncryptionInfo {
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
-
- @get:XmlElement(name = "EncryptionPubKeyDigest", required = true)
- lateinit var encryptionPubKeyDigest: PubKeyDigest
-
- @get:XmlElement(name = "TransactionKey", required = true)
- lateinit var transactionKey: ByteArray
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["value"])
- class PubKeyDigest {
- /**
- * Version of the *digest* of the public key.
- */
- @get:XmlAttribute(name = "Version", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var version: String
-
- @XmlAttribute(name = "Algorithm", required = true)
- @XmlSchemaType(name = "anyURI")
- lateinit var algorithm: String
-
- @get:XmlValue
- lateinit var value: ByteArray
- }
-
- @Suppress("UNUSED_PARAMETER")
- enum class TransactionPhaseType(value: String) {
- @XmlEnumValue("Initialisation")
- INITIALISATION("Initialisation"),
-
- /**
- * Auftragsdatentransfer
- *
- */
- @XmlEnumValue("Transfer")
- TRANSFER("Transfer"),
-
- /**
- * Quittungstransfer
- *
- */
- @XmlEnumValue("Receipt")
- RECEIPT("Receipt");
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "")
- class TimestampBankParameter {
- @get:XmlValue
- lateinit var value: XMLGregorianCalendar
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
-
-
- @XmlType(
- name = "PubKeyValueType", propOrder = [
- "rsaKeyValue",
- "timeStamp"
- ]
- )
- @XmlAccessorType(XmlAccessType.NONE)
- class PubKeyValueType {
- @get:XmlElement(name = "RSAKeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
- lateinit var rsaKeyValue: RSAKeyValueType
-
- @get:XmlElement(name = "TimeStamp", required = false)
- @get:XmlSchemaType(name = "dateTime")
- var timeStamp: XMLGregorianCalendar? = null
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "AuthenticationPubKeyInfoType", propOrder = [
- "x509Data",
- "pubKeyValue",
- "authenticationVersion"
- ]
- )
- class AuthenticationPubKeyInfoType {
- @get:XmlAnyElement()
- var x509Data: Element? = null
-
- @get:XmlElement(name = "PubKeyValue", required = true)
- lateinit var pubKeyValue: PubKeyValueType
-
- @get:XmlElement(name = "AuthenticationVersion", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var authenticationVersion: String
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "EncryptionPubKeyInfoType", propOrder = [
- "x509Data",
- "pubKeyValue",
- "encryptionVersion"
- ]
- )
- class EncryptionPubKeyInfoType {
- @get:XmlAnyElement()
- var x509Data: Element? = null
-
- @get:XmlElement(name = "PubKeyValue", required = true)
- lateinit var pubKeyValue: PubKeyValueType
-
- @get:XmlElement(name = "EncryptionVersion", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var encryptionVersion: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class FileFormatType {
- @get:XmlAttribute(name = "CountryCode")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var language: String
-
- @get:XmlValue
- @get:XmlJavaTypeAdapter(NormalizedStringAdapter::class)
- lateinit var value: String
- }
-
- /**
- * Generic key-value pair.
- */
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["name", "value"])
- class Parameter {
- @get:XmlAttribute(name = "Type", required = true)
- lateinit var type: String
-
- @get:XmlElement(name = "Name", required = true)
- lateinit var name: String
-
- @get:XmlElement(name = "Value", required = true)
- lateinit var value: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["addressInfo", "bankInfo", "accountInfoList", "orderInfoList"])
- class PartnerInfo {
- @get:XmlElement(name = "AddressInfo", required = true)
- lateinit var addressInfo: AddressInfo
-
- @get:XmlElement(name = "BankInfo", required = true)
- lateinit var bankInfo: BankInfo
-
- @get:XmlElement(name = "AccountInfo", type = AccountInfo::class)
- var accountInfoList: List<AccountInfo>? = LinkedList<AccountInfo>()
-
- @get:XmlElement(name = "OrderInfo", type = AuthOrderInfoType::class)
- var orderInfoList: List<AuthOrderInfoType> = LinkedList<AuthOrderInfoType>()
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = ["orderType", "fileFormat", "transferType", "orderFormat", "description", "numSigRequired"]
- )
- class AuthOrderInfoType {
- @get:XmlElement(name = "OrderType")
- lateinit var orderType: String
-
- @get:XmlElement(name = "FileFormat")
- val fileFormat: FileFormatType? = null
-
- @get:XmlElement(name = "TransferType")
- lateinit var transferType: String
-
- @get:XmlElement(name = "OrderFormat", required = false)
- var orderFormat: String? = null
-
- @get:XmlElement(name = "Description")
- lateinit var description: String
-
- @get:XmlElement(name = "NumSigRequired")
- var numSigRequired: Int? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class UserIDType {
- @get:XmlValue
- lateinit var value: String
-
- @get:XmlAttribute(name = "Status")
- var status: Int? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["userID", "name", "permissionList"])
- class UserInfo {
- @get:XmlElement(name = "UserID", required = true)
- lateinit var userID: UserIDType
-
- @get:XmlElement(name = "Name")
- var name: String? = null
-
- @get:XmlElement(name = "Permission", type = UserPermission::class)
- var permissionList: List<UserPermission>? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["orderTypes", "fileFormat", "accountID", "maxAmount"])
- class UserPermission {
- @get:XmlAttribute(name = "AuthorizationLevel")
- var authorizationLevel: String? = null
-
- @get:XmlElement(name = "OrderTypes")
- var orderTypes: String? = null
-
- @get:XmlElement(name = "FileFormat")
- val fileFormat: FileFormatType? = null
-
- @get:XmlElement(name = "AccountID")
- val accountID: String? = null
-
- @get:XmlElement(name = "MaxAmount")
- val maxAmount: String? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["name", "street", "postCode", "city", "region", "country"])
- class AddressInfo {
- @get:XmlElement(name = "Name")
- var name: String? = null
-
- @get:XmlElement(name = "Street")
- var street: String? = null
-
- @get:XmlElement(name = "PostCode")
- var postCode: String? = null
-
- @get:XmlElement(name = "City")
- var city: String? = null
-
- @get:XmlElement(name = "Region")
- var region: String? = null
-
- @get:XmlElement(name = "Country")
- var country: String? = null
- }
-
-
- @XmlAccessorType(XmlAccessType.NONE)
- class BankInfo {
- @get:XmlElement(name = "HostID")
- lateinit var hostID: String
-
- @get:XmlElement(type = Parameter::class)
- var parameters: List<Parameter>? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["accountNumberList", "bankCodeList", "accountHolder"])
- class AccountInfo {
- @get:XmlAttribute(name = "Currency")
- var currency: String? = null
-
- @get:XmlAttribute(name = "ID")
- lateinit var id: String
-
- @get:XmlAttribute(name = "Description")
- var description: String? = null
-
- @get:XmlElements(
- XmlElement(name = "AccountNumber", type = GeneralAccountNumber::class),
- XmlElement(name = "NationalAccountNumber", type = NationalAccountNumber::class)
- )
- var accountNumberList: List<AbstractAccountNumber>? = LinkedList<AbstractAccountNumber>()
-
- @get:XmlElements(
- XmlElement(name = "BankCode", type = GeneralBankCode::class),
- XmlElement(name = "NationalBankCode", type = NationalBankCode::class)
- )
- var bankCodeList: List<AbstractBankCode>? = LinkedList<AbstractBankCode>()
-
- @get:XmlElement(name = "AccountHolder")
- var accountHolder: String? = null
- }
-
- interface AbstractAccountNumber
-
- @XmlAccessorType(XmlAccessType.NONE)
- class GeneralAccountNumber : AbstractAccountNumber {
- @get:XmlAttribute(name = "international")
- var international: Boolean = true
-
- @get:XmlValue
- lateinit var value: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class NationalAccountNumber : AbstractAccountNumber {
- @get:XmlAttribute(name = "format")
- lateinit var format: String
-
- @get:XmlValue
- lateinit var value: String
- }
-
- interface AbstractBankCode
-
- @XmlAccessorType(XmlAccessType.NONE)
- class GeneralBankCode : AbstractBankCode {
- @get:XmlAttribute(name = "prefix")
- var prefix: String? = null
-
- @get:XmlAttribute(name = "international")
- var international: Boolean = true
-
- @get:XmlValue
- lateinit var value: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- class NationalBankCode : AbstractBankCode {
- @get:XmlValue
- lateinit var value: String
-
- @get:XmlAttribute(name = "format")
- lateinit var format: String
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_h004/EbicsUnsecuredRequest.kt b/ebics/src/main/kotlin/ebics_h004/EbicsUnsecuredRequest.kt
deleted file mode 100644
index 3269f70c..00000000
--- a/ebics/src/main/kotlin/ebics_h004/EbicsUnsecuredRequest.kt
+++ /dev/null
@@ -1,223 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import org.apache.xml.security.binding.xmldsig.RSAKeyValueType
-import tech.libeufin.ebics.EbicsOrderUtil
-import tech.libeufin.ebics.ebics_s001.SignatureTypes
-import java.security.interfaces.RSAPrivateCrtKey
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["header", "body"])
-@XmlRootElement(name = "ebicsUnsecuredRequest")
-class EbicsUnsecuredRequest {
- @get:XmlAttribute(name = "Version", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var version: String
-
- @get:XmlAttribute(name = "Revision")
- var revision: Int? = null
-
- @get:XmlElement(name = "header", required = true)
- lateinit var header: Header
-
- @get:XmlElement(required = true)
- lateinit var body: Body
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["static", "mutable"])
- class Header {
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "")
- class EmptyMutableHeader
-
- @get:XmlElement(name = "static", required = true)
- lateinit var static: StaticHeaderType
-
- @get:XmlElement(required = true)
- lateinit var mutable: EmptyMutableHeader
-
- @get:XmlAttribute(name = "authenticate", required = true)
- var authenticate: Boolean = false
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["dataTransfer"])
- class Body {
- @get:XmlElement(name = "DataTransfer", required = true)
- lateinit var dataTransfer: UnsecuredDataTransfer
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["orderData"])
- class UnsecuredDataTransfer {
- @get:XmlElement(name = "OrderData", required = true)
- lateinit var orderData: OrderData
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "")
- class OrderData {
- @get:XmlValue
- lateinit var value: ByteArray
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = ["hostID", "partnerID", "userID", "systemID", "product", "orderDetails", "securityMedium"]
- )
- class StaticHeaderType {
- @get:XmlElement(name = "HostID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var hostID: String
-
- @get:XmlElement(name = "PartnerID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var partnerID: String
-
- @get:XmlElement(name = "UserID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var userID: String
-
- @get:XmlElement(name = "SystemID")
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- var systemID: String? = null
-
- @get:XmlElement(name = "Product")
- val product: EbicsTypes.Product? = null
-
- @get:XmlElement(name = "OrderDetails", required = true)
- lateinit var orderDetails: OrderDetails
-
- @get:XmlElement(name = "SecurityMedium", required = true)
- lateinit var securityMedium: String
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["orderType", "orderAttribute"])
- class OrderDetails {
- @get:XmlElement(name = "OrderType", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var orderType: String
-
- @get:XmlElement(name = "OrderAttribute", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var orderAttribute: String
- }
-
- companion object {
-
- fun createHia(
- hostId: String,
- userId: String,
- partnerId: String,
- authKey: RSAPrivateCrtKey,
- encKey: RSAPrivateCrtKey
-
- ): EbicsUnsecuredRequest {
-
- return EbicsUnsecuredRequest().apply {
-
- version = "H004"
- revision = 1
- header = Header().apply {
- authenticate = true
- static = StaticHeaderType().apply {
- orderDetails = OrderDetails().apply {
- orderAttribute = "DZNNN"
- orderType = "HIA"
- securityMedium = "0000"
- hostID = hostId
- userID = userId
- partnerID = partnerId
- }
- }
- mutable = Header.EmptyMutableHeader()
- }
- body = Body().apply {
- dataTransfer = UnsecuredDataTransfer().apply {
- orderData = OrderData().apply {
- value = EbicsOrderUtil.encodeOrderDataXml(
- HIARequestOrderData().apply {
- authenticationPubKeyInfo = EbicsTypes.AuthenticationPubKeyInfoType()
- .apply {
- pubKeyValue = EbicsTypes.PubKeyValueType().apply {
- rsaKeyValue = RSAKeyValueType().apply {
- exponent = authKey.publicExponent.toByteArray()
- modulus = authKey.modulus.toByteArray()
- }
- }
- authenticationVersion = "X002"
- }
- encryptionPubKeyInfo = EbicsTypes.EncryptionPubKeyInfoType()
- .apply {
- pubKeyValue = EbicsTypes.PubKeyValueType().apply {
- rsaKeyValue = RSAKeyValueType().apply {
- exponent = encKey.publicExponent.toByteArray()
- modulus = encKey.modulus.toByteArray()
- }
- }
- encryptionVersion = "E002"
-
- }
- partnerID = partnerId
- userID = userId
- }
- )
- }
- }
- }
- }
- }
-
- fun createIni(
- hostId: String,
- userId: String,
- partnerId: String,
- signKey: RSAPrivateCrtKey
-
- ): EbicsUnsecuredRequest {
- return EbicsUnsecuredRequest().apply {
- version = "H004"
- revision = 1
- header = Header().apply {
- authenticate = true
- static = StaticHeaderType().apply {
- orderDetails = OrderDetails().apply {
- orderAttribute = "DZNNN"
- orderType = "INI"
- securityMedium = "0000"
- hostID = hostId
- userID = userId
- partnerID = partnerId
- }
- }
- mutable = Header.EmptyMutableHeader()
- }
- body = Body().apply {
- dataTransfer = UnsecuredDataTransfer().apply {
- orderData = OrderData().apply {
- value = EbicsOrderUtil.encodeOrderDataXml(
- SignatureTypes.SignaturePubKeyOrderData().apply {
- signaturePubKeyInfo = SignatureTypes.SignaturePubKeyInfoType().apply {
- signatureVersion = "A006"
- pubKeyValue = SignatureTypes.PubKeyValueType().apply {
- rsaKeyValue = RSAKeyValueType().apply {
- exponent = signKey.publicExponent.toByteArray()
- modulus = signKey.modulus.toByteArray()
- }
- }
- }
- userID = userId
- partnerID = partnerId
- }
- )
- }
- }
- }
- }
- }
- }
-}
diff --git a/ebics/src/main/kotlin/ebics_h004/HIARequestOrderData.kt b/ebics/src/main/kotlin/ebics_h004/HIARequestOrderData.kt
deleted file mode 100644
index 6268099b..00000000
--- a/ebics/src/main/kotlin/ebics_h004/HIARequestOrderData.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(
- name = "HIARequestOrderDataType",
- propOrder = ["authenticationPubKeyInfo", "encryptionPubKeyInfo", "partnerID", "userID", "any"]
-)
-@XmlRootElement(name = "HIARequestOrderData")
-class HIARequestOrderData {
- @get:XmlElement(name = "AuthenticationPubKeyInfo", required = true)
- lateinit var authenticationPubKeyInfo: EbicsTypes.AuthenticationPubKeyInfoType
-
- @get:XmlElement(name = "EncryptionPubKeyInfo", required = true)
- lateinit var encryptionPubKeyInfo: EbicsTypes.EncryptionPubKeyInfoType
-
- @get:XmlElement(name = "PartnerID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var partnerID: String
-
- @get:XmlElement(name = "UserID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var userID: String
-
- @get:XmlAnyElement(lax = true)
- var any: List<Any>? = null
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_h004/HKDResponseOrderData.kt b/ebics/src/main/kotlin/ebics_h004/HKDResponseOrderData.kt
deleted file mode 100644
index 92930155..00000000
--- a/ebics/src/main/kotlin/ebics_h004/HKDResponseOrderData.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import javax.xml.bind.annotation.*
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["partnerInfo", "userInfoList"])
-@XmlRootElement(name = "HTDResponseOrderData")
-class HKDResponseOrderData {
- @get:XmlElement(name = "PartnerInfo", required = true)
- lateinit var partnerInfo: EbicsTypes.PartnerInfo
-
- @get:XmlElement(name = "UserInfo", type = EbicsTypes.UserInfo::class, required = true)
- lateinit var userInfoList: List<EbicsTypes.UserInfo>
-}
diff --git a/ebics/src/main/kotlin/ebics_h004/HPBResponseOrderData.kt b/ebics/src/main/kotlin/ebics_h004/HPBResponseOrderData.kt
deleted file mode 100644
index 65b4098b..00000000
--- a/ebics/src/main/kotlin/ebics_h004/HPBResponseOrderData.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["authenticationPubKeyInfo", "encryptionPubKeyInfo", "hostID"])
-@XmlRootElement(name = "HPBResponseOrderData")
-class HPBResponseOrderData {
- @get:XmlElement(name = "AuthenticationPubKeyInfo", required = true)
- lateinit var authenticationPubKeyInfo: EbicsTypes.AuthenticationPubKeyInfoType
-
- @get:XmlElement(name = "EncryptionPubKeyInfo", required = true)
- lateinit var encryptionPubKeyInfo: EbicsTypes.EncryptionPubKeyInfoType
-
- @get:XmlElement(name = "HostID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var hostID: String
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_h004/HTDResponseOrderData.kt b/ebics/src/main/kotlin/ebics_h004/HTDResponseOrderData.kt
deleted file mode 100644
index 46954355..00000000
--- a/ebics/src/main/kotlin/ebics_h004/HTDResponseOrderData.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package tech.libeufin.ebics.ebics_h004
-
-import javax.xml.bind.annotation.*
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = ["partnerInfo", "userInfo"])
-@XmlRootElement(name = "HTDResponseOrderData")
-class HTDResponseOrderData {
- @get:XmlElement(name = "PartnerInfo", required = true)
- lateinit var partnerInfo: EbicsTypes.PartnerInfo
-
- @get:XmlElement(name = "UserInfo", required = true)
- lateinit var userInfo: EbicsTypes.UserInfo
-}
diff --git a/ebics/src/main/kotlin/ebics_h004/package-info.java b/ebics/src/main/kotlin/ebics_h004/package-info.java
deleted file mode 100644
index a16e907c..00000000
--- a/ebics/src/main/kotlin/ebics_h004/package-info.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * This package-info.java file defines the default namespace for the JAXB bindings
- * defined in the package.
- */
-
-@XmlSchema(
- namespace = "urn:org:ebics:H004",
- elementFormDefault = XmlNsForm.QUALIFIED
-)
-package tech.libeufin.ebics.ebics_h004;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_hev/EbicsMessages.kt b/ebics/src/main/kotlin/ebics_hev/EbicsMessages.kt
deleted file mode 100644
index 506ba9fa..00000000
--- a/ebics/src/main/kotlin/ebics_hev/EbicsMessages.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of LibEuFin.
- * Copyright (C) 2019 Stanisci and Dold.
-
- * 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.ebics.ebics_hev
-
-import java.util.*
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.NormalizedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(
- name = "HEVRequestDataType"
-)
-@XmlRootElement(name = "ebicsHEVRequest")
-class HEVRequest{
- @get:XmlElement(name = "HostID", required = true)
- lateinit var hostId: String
-}
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(
- name = "HEVResponseDataType",
- propOrder = ["systemReturnCode", "versionNumber", "any"]
-)
-@XmlRootElement(name = "ebicsHEVResponse")
-class HEVResponse {
- @get:XmlElement(name = "SystemReturnCode", required = true)
- lateinit var systemReturnCode: SystemReturnCodeType
-
- @get:XmlElement(name = "VersionNumber", namespace = "http://www.ebics.org/H000")
- var versionNumber: List<VersionNumber> = LinkedList()
-
- @get:XmlAnyElement(lax = true)
- var any: List<Any>? = null
-
- @XmlAccessorType(XmlAccessType.NONE)
- class VersionNumber {
- @get:XmlValue
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var value: String
-
- @get:XmlAttribute(name = "ProtocolVersion", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var protocolVersion: String
-
- companion object {
- fun create(protocolVersion: String, versionNumber: String): VersionNumber {
- return VersionNumber().apply {
- this.protocolVersion = protocolVersion
- this.value = versionNumber
- }
- }
- }
- }
-}
-
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlType(
- name = "SystemReturnCodeType",
- propOrder = [
- "returnCode",
- "reportText"
- ]
-)
-class SystemReturnCodeType {
- @get:XmlElement(name = "ReturnCode", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var returnCode: String
-
- @get:XmlElement(name = "ReportText", required = true)
- @get:XmlJavaTypeAdapter(NormalizedStringAdapter::class)
- lateinit var reportText: String
-}
diff --git a/ebics/src/main/kotlin/ebics_hev/package-info.java b/ebics/src/main/kotlin/ebics_hev/package-info.java
deleted file mode 100644
index 8d2c7b54..00000000
--- a/ebics/src/main/kotlin/ebics_hev/package-info.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * This package-info.java file defines the default namespace for the JAXB bindings
- * defined in the package.
- */
-
-@XmlSchema(
- namespace = "http://www.ebics.org/H000",
- elementFormDefault = XmlNsForm.QUALIFIED
-)
-package tech.libeufin.ebics.ebics_hev;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/ebics/src/main/kotlin/ebics_s001/SignatureTypes.kt b/ebics/src/main/kotlin/ebics_s001/SignatureTypes.kt
deleted file mode 100644
index 4781ba26..00000000
--- a/ebics/src/main/kotlin/ebics_s001/SignatureTypes.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of LibEuFin.
- * Copyright (C) 2019 Stanisci and Dold.
-
- * 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.ebics.ebics_s001
-
-import org.apache.xml.security.binding.xmldsig.RSAKeyValueType
-import org.apache.xml.security.binding.xmldsig.X509DataType
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-import javax.xml.datatype.XMLGregorianCalendar
-
-
-object SignatureTypes {
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "PubKeyValueType", namespace = "http://www.ebics.org/S001", propOrder = [
- "rsaKeyValue",
- "timeStamp"
- ]
- )
- class PubKeyValueType {
- @get:XmlElement(name = "RSAKeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
- lateinit var rsaKeyValue: RSAKeyValueType
-
- @get:XmlElement(name = "TimeStamp")
- @get:XmlSchemaType(name = "dateTime")
- var timeStamp: XMLGregorianCalendar? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = [
- "x509Data",
- "pubKeyValue",
- "signatureVersion"
- ]
- )
- class SignaturePubKeyInfoType {
- @get:XmlElement(name = "X509Data")
- var x509Data: X509DataType? = null
-
- @get:XmlElement(name = "PubKeyValue", required = true)
- lateinit var pubKeyValue: PubKeyValueType
-
- @get:XmlElement(name = "SignatureVersion", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var signatureVersion: String
- }
-
- /**
- * EBICS INI payload.
- */
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = ["signaturePubKeyInfo", "partnerID", "userID"]
- )
- @XmlRootElement(name = "SignaturePubKeyOrderData")
- class SignaturePubKeyOrderData {
- @get:XmlElement(name = "SignaturePubKeyInfo", required = true)
- lateinit var signaturePubKeyInfo: SignaturePubKeyInfoType
-
- @get:XmlElement(name = "PartnerID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var partnerID: String
-
- @get:XmlElement(name = "UserID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var userID: String
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_s001/UserSignatureData.kt b/ebics/src/main/kotlin/ebics_s001/UserSignatureData.kt
deleted file mode 100644
index 7eb5e0ed..00000000
--- a/ebics/src/main/kotlin/ebics_s001/UserSignatureData.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package tech.libeufin.ebics.ebics_s001
-
-import javax.xml.bind.annotation.*
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlRootElement(name = "UserSignatureData")
-@XmlType(name = "", propOrder = ["orderSignatureList"])
-class UserSignatureData {
- @XmlElement(name = "OrderSignatureData", type = OrderSignatureData::class)
- var orderSignatureList: List<OrderSignatureData>? = null
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["signatureVersion", "signatureValue", "partnerID", "userID"])
- class OrderSignatureData {
- @XmlElement(name = "SignatureVersion")
- lateinit var signatureVersion: String
-
- @XmlElement(name = "SignatureValue")
- lateinit var signatureValue: ByteArray
-
- @XmlElement(name = "PartnerID")
- lateinit var partnerID: String
-
- @XmlElement(name = "UserID")
- lateinit var userID: String
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_s001/package-info.java b/ebics/src/main/kotlin/ebics_s001/package-info.java
deleted file mode 100644
index adda5875..00000000
--- a/ebics/src/main/kotlin/ebics_s001/package-info.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * This package-info.java file defines the default namespace for the JAXB bindings
- * defined in the package.
- */
-
-@XmlSchema(
- namespace = "http://www.ebics.org/S001",
- elementFormDefault = XmlNsForm.QUALIFIED
-)
-package tech.libeufin.ebics.ebics_s001;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_s002/SignatureTypes.kt b/ebics/src/main/kotlin/ebics_s002/SignatureTypes.kt
deleted file mode 100644
index c1d48e9b..00000000
--- a/ebics/src/main/kotlin/ebics_s002/SignatureTypes.kt
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This file is part of LibEuFin.
- * Copyright (C) 2019 Stanisci and Dold.
-
- * 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.ebics.ebics_s002
-
-import org.apache.xml.security.binding.xmldsig.RSAKeyValueType
-import org.apache.xml.security.binding.xmldsig.X509DataType
-import javax.xml.bind.annotation.*
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
-import javax.xml.datatype.XMLGregorianCalendar
-
-
-object SignatureTypes {
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "PubKeyValueType", namespace = "http://www.ebics.org/S002", propOrder = [
- "rsaKeyValue",
- "timeStamp"
- ]
- )
- class PubKeyValueType {
- @get:XmlElement(name = "RSAKeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
- lateinit var rsaKeyValue: RSAKeyValueType
-
- @get:XmlElement(name = "TimeStamp")
- @get:XmlSchemaType(name = "dateTime")
- var timeStamp: XMLGregorianCalendar? = null
- }
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = [
- "x509Data",
- "pubKeyValue",
- "signatureVersion"
- ]
- )
- class SignaturePubKeyInfoType {
- @get:XmlElement(name = "X509Data")
- var x509Data: X509DataType? = null
-
- @get:XmlElement(name = "PubKeyValue", required = true)
- lateinit var pubKeyValue: PubKeyValueType
-
- @get:XmlElement(name = "SignatureVersion", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- lateinit var signatureVersion: String
- }
-
- /**
- * EBICS INI payload.
- */
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(
- name = "",
- propOrder = ["signaturePubKeyInfo", "partnerID", "userID"]
- )
- @XmlRootElement(name = "SignaturePubKeyOrderData")
- class SignaturePubKeyOrderData {
- @get:XmlElement(name = "SignaturePubKeyInfo", required = true)
- lateinit var signaturePubKeyInfo: SignaturePubKeyInfoType
-
- @get:XmlElement(name = "PartnerID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var partnerID: String
-
- @get:XmlElement(name = "UserID", required = true)
- @get:XmlJavaTypeAdapter(CollapsedStringAdapter::class)
- @get:XmlSchemaType(name = "token")
- lateinit var userID: String
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_s002/UserSignatureDataEbics3.kt b/ebics/src/main/kotlin/ebics_s002/UserSignatureDataEbics3.kt
deleted file mode 100644
index 082d0681..00000000
--- a/ebics/src/main/kotlin/ebics_s002/UserSignatureDataEbics3.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package tech.libeufin.ebics.ebics_s002
-
-import javax.xml.bind.annotation.*
-
-@XmlAccessorType(XmlAccessType.NONE)
-@XmlRootElement(name = "UserSignatureData")
-@XmlType(name = "", propOrder = ["orderSignatureList"])
-class UserSignatureDataEbics3 {
- @XmlElement(name = "OrderSignatureData", type = OrderSignatureData::class)
- var orderSignatureList: List<OrderSignatureData>? = null
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = ["signatureVersion", "signatureValue", "partnerID", "userID"])
- class OrderSignatureData {
- @XmlElement(name = "SignatureVersion")
- lateinit var signatureVersion: String
-
- @XmlElement(name = "SignatureValue")
- lateinit var signatureValue: ByteArray
-
- @XmlElement(name = "PartnerID")
- lateinit var partnerID: String
-
- @XmlElement(name = "UserID")
- lateinit var userID: String
- }
-} \ No newline at end of file
diff --git a/ebics/src/main/kotlin/ebics_s002/package-info.java b/ebics/src/main/kotlin/ebics_s002/package-info.java
deleted file mode 100644
index 5ddb1f77..00000000
--- a/ebics/src/main/kotlin/ebics_s002/package-info.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * This package-info.java file defines the default namespace for the JAXB bindings
- * defined in the package.
- */
-
-@XmlSchema(
- namespace = "http://www.ebics.org/S002",
- elementFormDefault = XmlNsForm.QUALIFIED
-)
-package tech.libeufin.ebics.ebics_s002;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file