commit 7af5e459bc172aab837b7301a92939cb514d80d2 parent 88a44b7ea06413d0e64322750f1a8ef4152dfea8 Author: Marcello Stanisci <stanisci.m@gmail.com> Date: Thu, 12 Dec 2019 17:17:09 +0100 adjust package-info Diffstat:
38 files changed, 1993 insertions(+), 1992 deletions(-)
diff --git a/nexus/src/main/kotlin/Helpers.kt b/nexus/src/main/kotlin/Helpers.kt @@ -5,8 +5,8 @@ import io.ktor.client.request.post import io.ktor.http.HttpStatusCode import tech.libeufin.util.CryptoUtil import tech.libeufin.util.XMLUtil -import tech.libeufin.util.schema.ebics_h004.EbicsRequest -import tech.libeufin.util.schema.ebics_s001.UserSignatureData +import tech.libeufin.util.ebics_h004.EbicsRequest +import tech.libeufin.util.ebics_s001.UserSignatureData import tech.libeufin.util.toByteArray import java.math.BigInteger import java.security.PrivateKey @@ -185,6 +185,8 @@ fun signOrder( */ suspend inline fun HttpClient.postToBank(url: String, body: String): String { + LOGGER.debug("Posting: $body") + val response = try { this.post<String>( urlString = url, diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt @@ -41,7 +41,7 @@ import org.jetbrains.exposed.sql.transactions.transaction import org.joda.time.DateTime import org.slf4j.Logger import org.slf4j.LoggerFactory -import tech.libeufin.util.schema.ebics_h004.* +import tech.libeufin.util.ebics_h004.* import tech.libeufin.util.* import java.text.DateFormat import javax.sql.rowset.serial.SerialBlob @@ -488,15 +488,13 @@ fun main() { post("/ebics/subscribers/{id}/sendIni") { val id = expectId(call.parameters["id"]) // caught above - val iniRequest = EbicsUnsecuredRequest() - val subscriberData = transaction { containerInit( EbicsSubscriberEntity.findById(id) ?: throw SubscriberNotFoundError(HttpStatusCode.NotFound) ) } - val theRequest = EbicsUnsecuredRequest.createIni( + val iniRequest = EbicsUnsecuredRequest.createIni( subscriberData.hostId, subscriberData.userId, subscriberData.partnerId, @@ -505,7 +503,7 @@ fun main() { val responseJaxb = client.postToBankUnsigned<EbicsUnsecuredRequest, EbicsKeyManagementResponse>( subscriberData.ebicsUrl, - theRequest + iniRequest ) if (responseJaxb.value.body.returnCode.value != "000000") { diff --git a/nexus/src/test/kotlin/SignatureDataTest.kt b/nexus/src/test/kotlin/SignatureDataTest.kt @@ -4,8 +4,8 @@ import tech.libeufin.util.XMLUtil import org.apache.xml.security.binding.xmldsig.SignatureType import org.junit.Test import tech.libeufin.util.CryptoUtil -import tech.libeufin.util.schema.ebics_h004.EbicsRequest -import tech.libeufin.util.schema.ebics_h004.EbicsTypes +import tech.libeufin.util.ebics_h004.EbicsRequest +import tech.libeufin.util.ebics_h004.EbicsTypes import java.math.BigInteger class SignatureDataTest { diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -32,11 +32,11 @@ import org.jetbrains.exposed.sql.stringParam import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.upperCase import org.w3c.dom.Document -import tech.libeufin.util.schema.ebics_h004.* -import tech.libeufin.util.schema.ebics_hev.HEVResponse -import tech.libeufin.util.schema.ebics_hev.SystemReturnCodeType -import tech.libeufin.util.schema.ebics_s001.SignatureTypes -import tech.libeufin.util.schema.ebics_s001.UserSignatureData +import tech.libeufin.util.ebics_h004.* +import tech.libeufin.util.ebics_hev.HEVResponse +import tech.libeufin.util.ebics_hev.SystemReturnCodeType +import tech.libeufin.util.ebics_s001.SignatureTypes +import tech.libeufin.util.ebics_s001.UserSignatureData import tech.libeufin.util.CryptoUtil import tech.libeufin.util.EbicsOrderUtil import tech.libeufin.util.XMLUtil @@ -314,6 +314,7 @@ private suspend fun ApplicationCall.receiveEbicsXml(): Document { LOGGER.debug("Data received: $body") val requestDocument: Document? = XMLUtil.parseStringIntoDom(body) if (requestDocument == null || (!XMLUtil.validateFromDom(requestDocument))) { + println("Problematic document was: $requestDocument") throw EbicsInvalidXmlError() } return requestDocument diff --git a/sandbox/src/test/kotlin/EbicsMessagesTest.kt b/sandbox/src/test/kotlin/EbicsMessagesTest.kt @@ -5,11 +5,12 @@ import org.apache.xml.security.binding.xmldsig.SignatureType import org.junit.Test import org.w3c.dom.Element import tech.libeufin.util.schema.ebics_h004.* -import tech.libeufin.util.schema.ebics_hev.HEVResponse -import tech.libeufin.util.schema.ebics_hev.SystemReturnCodeType -import tech.libeufin.util.schema.ebics_s001.SignatureTypes +import tech.libeufin.util.ebics_hev.HEVResponse +import tech.libeufin.util.ebics_hev.SystemReturnCodeType +import tech.libeufin.util.ebics_s001.SignatureTypes import tech.libeufin.util.CryptoUtil import tech.libeufin.util.XMLUtil +import tech.libeufin.util.ebics_h004.* import javax.xml.datatype.DatatypeFactory import kotlin.test.assertNotNull import kotlin.test.assertTrue diff --git a/sandbox/src/test/kotlin/XmlUtilTest.kt b/sandbox/src/test/kotlin/XmlUtilTest.kt @@ -4,10 +4,10 @@ import org.apache.xml.security.binding.xmldsig.SignatureType import org.junit.Test import org.junit.Assert.* import org.junit.Ignore -import tech.libeufin.util.schema.ebics_h004.EbicsKeyManagementResponse -import tech.libeufin.util.schema.ebics_h004.EbicsResponse -import tech.libeufin.util.schema.ebics_h004.EbicsTypes -import tech.libeufin.util.schema.ebics_h004.HTDResponseOrderData +import tech.libeufin.util.ebics_h004.EbicsKeyManagementResponse +import tech.libeufin.util.ebics_h004.EbicsResponse +import tech.libeufin.util.ebics_h004.EbicsTypes +import tech.libeufin.util.ebics_h004.HTDResponseOrderData import tech.libeufin.util.CryptoUtil import tech.libeufin.util.XMLUtil import java.security.KeyPairGenerator diff --git a/util/src/main/kotlin/ebics_h004/EbicsKeyManagementResponse.kt b/util/src/main/kotlin/ebics_h004/EbicsKeyManagementResponse.kt @@ -0,0 +1,102 @@ +package tech.libeufin.util.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: ByteArray + } +} diff --git a/util/src/main/kotlin/ebics_h004/EbicsNpkdRequest.kt b/util/src/main/kotlin/ebics_h004/EbicsNpkdRequest.kt @@ -0,0 +1,135 @@ +package tech.libeufin.util.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/util/src/main/kotlin/ebics_h004/EbicsRequest.kt b/util/src/main/kotlin/ebics_h004/EbicsRequest.kt @@ -0,0 +1,501 @@ +package tech.libeufin.util.ebics_h004 + +import org.apache.xml.security.binding.xmldsig.SignatureType +import tech.libeufin.util.CryptoUtil +import java.math.BigInteger +import java.security.interfaces.RSAPublicKey +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 a 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 + ) + ) + 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: ByteArray? = 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 = ["start", "end"]) + class DateRange { + @get:XmlElement(name = "Start") + lateinit var start: XMLGregorianCalendar + + @get:XmlElement(name = "End") + 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 + + ): 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 = 0 // always true at this point. + } + } + } + + } + + /* Take a time range (useful for C52 and C53) */ + fun createForDownloadInitializationPhase( + userId: String, + partnerId: String, + hostId: String, + nonceArg: ByteArray, + date: XMLGregorianCalendar, + bankEncPub: RSAPublicKey, + bankAuthPub: RSAPublicKey, + aOrderType: String, + dateStart: XMLGregorianCalendar, + dateEnd: XMLGregorianCalendar + ): EbicsRequest { + + val tmp = createForDownloadInitializationPhase( + userId, + partnerId, + hostId, + nonceArg, + date, + bankEncPub, + bankAuthPub, + aOrderType + ) + + (tmp.header.static.orderDetails?.orderParams as StandardOrderParams).apply { + dateRange?.apply { + start = dateStart + end = dateEnd + } + } + + return tmp + } + + fun createForDownloadInitializationPhase( + userId: String, + partnerId: String, + hostId: String, + nonceArg: ByteArray, + date: XMLGregorianCalendar, + bankEncPub: RSAPublicKey, + bankAuthPub: RSAPublicKey, + aOrderType: String + + ): 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 = aOrderType + orderAttribute = "DZHNN" + orderParams = StandardOrderParams() + } + 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( + cryptoBundle: CryptoUtil.EncryptionResult, + hostId: String, + nonceArg: ByteArray, + partnerId: String, + userId: String, + date: XMLGregorianCalendar, + bankAuthPub: RSAPublicKey, + bankEncPub: RSAPublicKey, + segmentsNumber: BigInteger, + aOrderType: String + ): 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 = StandardOrderParams() + } + 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 = cryptoBundle.encryptedData + } + dataEncryptionInfo = EbicsTypes.DataEncryptionInfo().apply { + transactionKey = cryptoBundle.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: ByteArray + + ): 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 + } + } + } + } + } +} +\ No newline at end of file diff --git a/util/src/main/kotlin/ebics_h004/EbicsResponse.kt b/util/src/main/kotlin/ebics_h004/EbicsResponse.kt @@ -0,0 +1,276 @@ +package tech.libeufin.util.ebics_h004 + +import org.apache.xml.security.binding.xmldsig.SignatureType +import tech.libeufin.util.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 + +@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 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" + } + } + } + } + + 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, Math.min(segmentSize, encodedData.length)) + } + } + } + } + } + } +} diff --git a/util/src/main/kotlin/ebics_h004/EbicsTypes.kt b/util/src/main/kotlin/ebics_h004/EbicsTypes.kt @@ -0,0 +1,402 @@ +/* + * 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.util.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>? = null + + @get:XmlElements( + XmlElement(name = "BankCode", type = GeneralBankCode::class), + XmlElement(name = "NationalBankCode", type = NationalBankCode::class) + ) + var bankCodeList: List<AbstractBankCode>? = null + + @get:XmlElement(name = "AccountHolder") + var accountHolder: String? = null + } + + interface AbstractAccountNumber + + @XmlAccessorType(XmlAccessType.NONE) + class GeneralAccountNumber : AbstractAccountNumber { + @get:XmlAttribute(name = "international") + var international: Boolean = false + + @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 = false + + @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/util/src/main/kotlin/ebics_h004/EbicsUnsecuredRequest.kt b/util/src/main/kotlin/ebics_h004/EbicsUnsecuredRequest.kt @@ -0,0 +1,223 @@ +package tech.libeufin.util.ebics_h004 + +import org.apache.xml.security.binding.xmldsig.RSAKeyValueType +import tech.libeufin.util.EbicsOrderUtil +import tech.libeufin.util.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 = org.apache.xml.security.binding.xmldsig.RSAKeyValueType().apply { + exponent = signKey.publicExponent.toByteArray() + modulus = signKey.modulus.toByteArray() + } + } + } + userID = userId + partnerID = partnerId + } + ) + } + } + } + } + } + } +} diff --git a/util/src/main/kotlin/ebics_h004/HIARequestOrderData.kt b/util/src/main/kotlin/ebics_h004/HIARequestOrderData.kt @@ -0,0 +1,33 @@ +package tech.libeufin.util.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/util/src/main/kotlin/ebics_h004/HKDResponseOrderData.kt b/util/src/main/kotlin/ebics_h004/HKDResponseOrderData.kt @@ -0,0 +1,15 @@ +package tech.libeufin.util.ebics_h004 + +import java.security.Permission +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/util/src/main/kotlin/ebics_h004/HPBResponseOrderData.kt b/util/src/main/kotlin/ebics_h004/HPBResponseOrderData.kt @@ -0,0 +1,21 @@ +package tech.libeufin.util.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/util/src/main/kotlin/ebics_h004/HTDResponseOrderData.kt b/util/src/main/kotlin/ebics_h004/HTDResponseOrderData.kt @@ -0,0 +1,15 @@ +package tech.libeufin.util.ebics_h004 + +import java.security.Permission +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/util/src/main/kotlin/ebics_h004/package-info.java b/util/src/main/kotlin/ebics_h004/package-info.java @@ -0,0 +1,12 @@ +/** + * 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.util.ebics_h004; +import javax.xml.bind.annotation.XmlSchema; +import javax.xml.bind.annotation.XmlNsForm; +\ No newline at end of file diff --git a/util/src/main/kotlin/ebics_hev/EbicsMessages.kt b/util/src/main/kotlin/ebics_hev/EbicsMessages.kt @@ -0,0 +1,81 @@ +/* + * 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.util.ebics_hev + +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 = "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>? = null + + @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/util/src/main/kotlin/ebics_hev/package-info.java b/util/src/main/kotlin/ebics_hev/package-info.java @@ -0,0 +1,13 @@ +/** + * 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.util.ebics_hev; + +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; diff --git a/util/src/main/kotlin/ebics_s001/SignatureTypes.kt b/util/src/main/kotlin/ebics_s001/SignatureTypes.kt @@ -0,0 +1,92 @@ +/* + * 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.util.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/util/src/main/kotlin/ebics_s001/UserSignatureData.kt b/util/src/main/kotlin/ebics_s001/UserSignatureData.kt @@ -0,0 +1,27 @@ +package tech.libeufin.util.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/util/src/main/kotlin/ebics_s001/package-info.java b/util/src/main/kotlin/ebics_s001/package-info.java @@ -0,0 +1,13 @@ +/** + * 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.util.ebics_s001; + +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; +\ No newline at end of file diff --git a/util/src/main/kotlin/schema/ebics_h004/EbicsKeyManagementResponse.kt b/util/src/main/kotlin/schema/ebics_h004/EbicsKeyManagementResponse.kt @@ -1,102 +0,0 @@ -package tech.libeufin.util.schema.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: ByteArray - } -} diff --git a/util/src/main/kotlin/schema/ebics_h004/EbicsNpkdRequest.kt b/util/src/main/kotlin/schema/ebics_h004/EbicsNpkdRequest.kt @@ -1,135 +0,0 @@ -package tech.libeufin.util.schema.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/util/src/main/kotlin/schema/ebics_h004/EbicsRequest.kt b/util/src/main/kotlin/schema/ebics_h004/EbicsRequest.kt @@ -1,501 +0,0 @@ -package tech.libeufin.util.schema.ebics_h004 - -import org.apache.xml.security.binding.xmldsig.SignatureType -import tech.libeufin.util.CryptoUtil -import java.math.BigInteger -import java.security.interfaces.RSAPublicKey -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 a 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 - ) - ) - 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: ByteArray? = 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 = ["start", "end"]) - class DateRange { - @get:XmlElement(name = "Start") - lateinit var start: XMLGregorianCalendar - - @get:XmlElement(name = "End") - 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 - - ): 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 = 0 // always true at this point. - } - } - } - - } - - /* Take a time range (useful for C52 and C53) */ - fun createForDownloadInitializationPhase( - userId: String, - partnerId: String, - hostId: String, - nonceArg: ByteArray, - date: XMLGregorianCalendar, - bankEncPub: RSAPublicKey, - bankAuthPub: RSAPublicKey, - aOrderType: String, - dateStart: XMLGregorianCalendar, - dateEnd: XMLGregorianCalendar - ): EbicsRequest { - - val tmp = createForDownloadInitializationPhase( - userId, - partnerId, - hostId, - nonceArg, - date, - bankEncPub, - bankAuthPub, - aOrderType - ) - - (tmp.header.static.orderDetails?.orderParams as StandardOrderParams).apply { - dateRange?.apply { - start = dateStart - end = dateEnd - } - } - - return tmp - } - - fun createForDownloadInitializationPhase( - userId: String, - partnerId: String, - hostId: String, - nonceArg: ByteArray, - date: XMLGregorianCalendar, - bankEncPub: RSAPublicKey, - bankAuthPub: RSAPublicKey, - aOrderType: String - - ): 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 = aOrderType - orderAttribute = "DZHNN" - orderParams = StandardOrderParams() - } - 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( - cryptoBundle: CryptoUtil.EncryptionResult, - hostId: String, - nonceArg: ByteArray, - partnerId: String, - userId: String, - date: XMLGregorianCalendar, - bankAuthPub: RSAPublicKey, - bankEncPub: RSAPublicKey, - segmentsNumber: BigInteger, - aOrderType: String - ): 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 = StandardOrderParams() - } - 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 = cryptoBundle.encryptedData - } - dataEncryptionInfo = EbicsTypes.DataEncryptionInfo().apply { - transactionKey = cryptoBundle.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: ByteArray - - ): 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 - } - } - } - } - } -} -\ No newline at end of file diff --git a/util/src/main/kotlin/schema/ebics_h004/EbicsResponse.kt b/util/src/main/kotlin/schema/ebics_h004/EbicsResponse.kt @@ -1,276 +0,0 @@ -package tech.libeufin.util.schema.ebics_h004 - -import org.apache.xml.security.binding.xmldsig.SignatureType -import tech.libeufin.util.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 - -@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 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" - } - } - } - } - - 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, Math.min(segmentSize, encodedData.length)) - } - } - } - } - } - } -} diff --git a/util/src/main/kotlin/schema/ebics_h004/EbicsTypes.kt b/util/src/main/kotlin/schema/ebics_h004/EbicsTypes.kt @@ -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.util.schema.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>? = null - - @get:XmlElements( - XmlElement(name = "BankCode", type = GeneralBankCode::class), - XmlElement(name = "NationalBankCode", type = NationalBankCode::class) - ) - var bankCodeList: List<AbstractBankCode>? = null - - @get:XmlElement(name = "AccountHolder") - var accountHolder: String? = null - } - - interface AbstractAccountNumber - - @XmlAccessorType(XmlAccessType.NONE) - class GeneralAccountNumber : AbstractAccountNumber { - @get:XmlAttribute(name = "international") - var international: Boolean = false - - @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 = false - - @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/util/src/main/kotlin/schema/ebics_h004/EbicsUnsecuredRequest.kt b/util/src/main/kotlin/schema/ebics_h004/EbicsUnsecuredRequest.kt @@ -1,223 +0,0 @@ -package tech.libeufin.util.schema.ebics_h004 - -import org.apache.xml.security.binding.xmldsig.RSAKeyValueType -import tech.libeufin.util.EbicsOrderUtil -import tech.libeufin.util.schema.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 = org.apache.xml.security.binding.xmldsig.RSAKeyValueType().apply { - exponent = signKey.publicExponent.toByteArray() - modulus = signKey.modulus.toByteArray() - } - } - } - userID = userId - partnerID = partnerId - } - ) - } - } - } - } - } - } -} diff --git a/util/src/main/kotlin/schema/ebics_h004/HIARequestOrderData.kt b/util/src/main/kotlin/schema/ebics_h004/HIARequestOrderData.kt @@ -1,33 +0,0 @@ -package tech.libeufin.util.schema.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/util/src/main/kotlin/schema/ebics_h004/HKDResponseOrderData.kt b/util/src/main/kotlin/schema/ebics_h004/HKDResponseOrderData.kt @@ -1,15 +0,0 @@ -package tech.libeufin.util.schema.ebics_h004 - -import java.security.Permission -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/util/src/main/kotlin/schema/ebics_h004/HPBResponseOrderData.kt b/util/src/main/kotlin/schema/ebics_h004/HPBResponseOrderData.kt @@ -1,21 +0,0 @@ -package tech.libeufin.util.schema.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/util/src/main/kotlin/schema/ebics_h004/HTDResponseOrderData.kt b/util/src/main/kotlin/schema/ebics_h004/HTDResponseOrderData.kt @@ -1,15 +0,0 @@ -package tech.libeufin.util.schema.ebics_h004 - -import java.security.Permission -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/util/src/main/kotlin/schema/ebics_h004/package-info.java b/util/src/main/kotlin/schema/ebics_h004/package-info.java @@ -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 schema.ebics_h004; - -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; -\ No newline at end of file diff --git a/util/src/main/kotlin/schema/ebics_hev/EbicsMessages.kt b/util/src/main/kotlin/schema/ebics_hev/EbicsMessages.kt @@ -1,81 +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.util.schema.ebics_hev - -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 = "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>? = null - - @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/util/src/main/kotlin/schema/ebics_hev/package-info.java b/util/src/main/kotlin/schema/ebics_hev/package-info.java @@ -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 schema.ebics_hev; - -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; diff --git a/util/src/main/kotlin/schema/ebics_s001/SignatureTypes.kt b/util/src/main/kotlin/schema/ebics_s001/SignatureTypes.kt @@ -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.util.schema.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/util/src/main/kotlin/schema/ebics_s001/UserSignatureData.kt b/util/src/main/kotlin/schema/ebics_s001/UserSignatureData.kt @@ -1,27 +0,0 @@ -package tech.libeufin.util.schema.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/util/src/main/kotlin/schema/ebics_s001/package-info.java b/util/src/main/kotlin/schema/ebics_s001/package-info.java @@ -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 schema.ebics_s001; - -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; -\ No newline at end of file