summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DSIG.go8
-rw-r--r--H005.go77
-rw-r--r--S002.go18
-rw-r--r--order.go144
4 files changed, 128 insertions, 119 deletions
diff --git a/DSIG.go b/DSIG.go
new file mode 100644
index 0000000..8dca0ab
--- /dev/null
+++ b/DSIG.go
@@ -0,0 +1,8 @@
+package libebics
+
+import "encoding/xml"
+
+type DSIGX509Data struct {
+ XMLName xml.Name `xml:"ds:X509Data"`
+ DSIGX509Certificate string `xml:"ds:X509Certificate"` // TODO Properly marshal this
+}
diff --git a/H005.go b/H005.go
new file mode 100644
index 0000000..6f1b3e3
--- /dev/null
+++ b/H005.go
@@ -0,0 +1,77 @@
+package libebics
+
+import "encoding/xml"
+
+type H005UnsecuredRequest struct {
+ XMLName xml.Name `xml:"ebicsUnsecuredRequest"`
+ Xmlns string `xml:"xmlns,attr"`
+ Version string `xml:"Version,attr"`
+ Revision string `xml:"Revision,attr"`
+ Header H005UnsecuredRequestHeader `xml:"header"`
+ Body H005UnsecuredRequestBody `xml:"body"`
+}
+
+type H005UnsecuredRequestHeader struct {
+ XMLName xml.Name `xml:"header"`
+ Authenticate bool `xml:"authenticate,attr"`
+ Static H005UnsecuredRequestStaticHeaderType `xml:"static"`
+ Mutable H005EmptyMutableHeaderType `xml:"mutable"`
+}
+
+type H005UnsecuredRequestStaticHeaderType struct {
+ XMLName xml.Name `xml:"static"`
+ HostID string `xml:"HostID"`
+ PartnerID string `xml:"PartnerID"`
+ UserID string `xml:"UserID"`
+ Product H005ProductElementType `xml:"Product"`
+ OrderDetails H005UnsecuredReqOrderDetailsType `xml:"OrderDetails"`
+ SecurityMedium string `xml:"SecurityMedium"`
+}
+
+type H005ProductElementType struct {
+ XMLName xml.Name `xml:"Product"`
+ Language string `xml:"Language,attr"`
+ Name string `xml:",chardata"`
+}
+
+type H005UnsecuredReqOrderDetailsType struct {
+ XMLName xml.Name `xml:"OrderDetails"`
+ AdminOrderType string `xml:"AdminOrderType"`
+}
+
+type H005EmptyMutableHeaderType struct {
+ XMLName xml.Name `xml:"mutable"`
+}
+
+type H005UnsecuredRequestBody struct {
+ XMLName xml.Name `xml:"body"`
+ DataTransfer H005UnsecuredRequestDataTransfer `xml:"DataTransfer"`
+}
+
+type H005UnsecuredRequestDataTransfer struct {
+ XMLName xml.Name `xml:"DataTransfer"`
+ OrderData string `xml:"OrderData"` // TODO Properly marshal this
+}
+
+type H005HIARequestOrderDataType struct {
+ XMLName xml.Name `xml:"HIARequestOrderData"`
+ Xmlns string `xml:"xmlns,attr"`
+ Esig string `xml:"xmlns:esig,attr"`
+ Ds string `xml:"xmlns:ds,attr"`
+ AuthenticationPubKeyInfo H005AuthenticationPubKeyInfo `xml:"AuthenticationPubKeyInfo"`
+ EncryptionPubKeyInfo H005EncryptionPubKeyInfo `xml:"EncryptionPubKeyInfo"`
+ PartnerID string `xml:"PartnerID"`
+ UserID string `xml:"UserID"`
+}
+
+type H005AuthenticationPubKeyInfo struct {
+ XMLName xml.Name `xml:"AuthenticationPubKeyInfo"`
+ X509Data DSIGX509Data `xml:"ds:X509Data"`
+ AuthenticationVersion string `xml:"AuthenticationVersion"` // TODO Use ENUM
+}
+
+type H005EncryptionPubKeyInfo struct {
+ XMLName xml.Name `xml:"EncryptionPubKeyInfo"`
+ X509Data DSIGX509Data `xml:"ds:X509Data"`
+ EncryptionVersion string `xml:"EncryptionVersion"` // TODO Use ENUM
+}
diff --git a/S002.go b/S002.go
new file mode 100644
index 0000000..a2e4d4b
--- /dev/null
+++ b/S002.go
@@ -0,0 +1,18 @@
+package libebics
+
+import "encoding/xml"
+
+type S002SignaturePubKeyInfoType struct {
+ XMLName xml.Name `xml:"esig:SignaturePubKeyInfo"`
+ X509Data DSIGX509Data `xml:"ds:X509Data"`
+ SignatureVersion string `xml:"esig:SignatureVersion"` // TODO Use ENUM
+}
+
+type S002SignaturePubKeyOrderDataType struct {
+ XMLName xml.Name `xml:"esig:SignaturePubKeyOrderData"`
+ Esig string `xml:"xmlns:esig,attr"`
+ Ds string `xml:"xmlns:ds,attr"`
+ SignaturePubKeyInfo S002SignaturePubKeyInfoType `xml:"esig:SignaturePubKeyInfo"`
+ PartnerID string `xml:"esig:PartnerID"`
+ UserID string `xml:"esig:UserID"`
+}
diff --git a/order.go b/order.go
index 38578a0..f200461 100644
--- a/order.go
+++ b/order.go
@@ -8,100 +8,6 @@ import (
"fmt"
)
-type EbicsUnsecuredRequest struct {
- XMLName xml.Name `xml:"ebicsUnsecuredRequest"`
- Xmlns string `xml:"xmlns,attr"`
- Version string `xml:"Version,attr"`
- Revision string `xml:"Revision,attr"`
- Header EbicsHeader `xml:"header"`
- Body EbicsBody `xml:"body"`
-}
-
-type EbicsHeader struct {
- XMLName xml.Name `xml:"header"`
- Authenticate bool `xml:"authenticate,attr"`
- Static EbicsHeaderStatic `xml:"static"`
- Mutable EbicsHeaderMutable `xml:"mutable"`
-}
-
-type EbicsHeaderStatic struct {
- XMLName xml.Name `xml:"static"`
- HostID string `xml:"HostID"`
- PartnerID string `xml:"PartnerID"`
- UserID string `xml:"UserID"`
- Product EbicsProduct `xml:"Product"`
- OrderDetails EbicsOrderDetails `xml:"OrderDetails"`
- SecurityMedium string `xml:"SecurityMedium"`
-}
-
-type EbicsProduct struct {
- XMLName xml.Name `xml:"Product"`
- Language string `xml:"Language,attr"`
- Name string `xml:",chardata"`
-}
-
-type EbicsOrderDetails struct {
- XMLName xml.Name `xml:"OrderDetails"`
- AdminOrderType string `xml:"AdminOrderType"`
-}
-
-type EbicsHeaderMutable struct {
- XMLName xml.Name `xml:"mutable"`
-}
-
-type EbicsBody struct {
- XMLName xml.Name `xml:"body"`
- DataTransfer EbicsDataTransfer `xml:"DataTransfer"`
-}
-
-type EbicsDataTransfer struct {
- XMLName xml.Name `xml:"DataTransfer"`
- OrderData string `xml:"OrderData"` // TODO Properly marshal this
-}
-
-type EbicsSignaturePubKeyOrderData struct {
- XMLName xml.Name `xml:"esig:SignaturePubKeyOrderData"`
- Esig string `xml:"xmlns:esig,attr"`
- Ds string `xml:"xmlns:ds,attr"`
- SignaturePubKeyInfo EbicsSignaturePubKeyInfo `xml:"esig:SignaturePubKeyInfo"`
- PartnerID string `xml:"esig:PartnerID"`
- UserID string `xml:"esig:UserID"`
-}
-
-type EbicsHiaRequestOrderData struct {
- XMLName xml.Name `xml:"HIARequestOrderData"`
- Xmlns string `xml:"xmlns,attr"`
- Esig string `xml:"xmlns:esig,attr"`
- Ds string `xml:"xmlns:ds,attr"`
- AuthenticationPubKeyInfo EbicsAuthenticationPubKeyInfo `xml:"AuthenticationPubKeyInfo"`
- EncryptionPubKeyInfo EbicsEncryptionPubKeyInfo `xml:"EncryptionPubKeyInfo"`
- PartnerID string `xml:"PartnerID"`
- UserID string `xml:"UserID"`
-}
-
-type EbicsAuthenticationPubKeyInfo struct {
- XMLName xml.Name `xml:"AuthenticationPubKeyInfo"`
- X509Data EbicsX509Data `xml:"ds:X509Data"`
- AuthenticationVersion string `xml:"AuthenticationVersion"` // TODO Use ENUM
-}
-
-type EbicsEncryptionPubKeyInfo struct {
- XMLName xml.Name `xml:"EncryptionPubKeyInfo"`
- X509Data EbicsX509Data `xml:"ds:X509Data"`
- EncryptionVersion string `xml:"EncryptionVersion"` // TODO Use ENUM
-}
-
-type EbicsSignaturePubKeyInfo struct {
- XMLName xml.Name `xml:"esig:SignaturePubKeyInfo"`
- X509Data EbicsX509Data `xml:"ds:X509Data"`
- SignatureVersion string `xml:"esig:SignatureVersion"` // TODO Use ENUM
-}
-
-type EbicsX509Data struct {
- XMLName xml.Name `xml:"ds:X509Data"`
- X509Certificate string `xml:"ds:X509Certificate"` // TODO Properly marshal this
-}
-
func GenerateIniRequest(signatureCertificate EbicsCertificate) (string, error) {
if signatureCertificate.ebicsCertificateType != A005 &&
@@ -112,12 +18,12 @@ func GenerateIniRequest(signatureCertificate EbicsCertificate) (string, error) {
var zlibWriterBuffer bytes.Buffer
zlibWriter := zlib.NewWriter(&zlibWriterBuffer)
- orderData := EbicsSignaturePubKeyOrderData{
+ orderData := S002SignaturePubKeyOrderDataType{
Esig: "http://www.ebics.org/S002",
Ds: "http://www.w3.org/2000/09/xmldsig#",
- SignaturePubKeyInfo: EbicsSignaturePubKeyInfo{
- X509Data: EbicsX509Data{
- X509Certificate: base64.StdEncoding.EncodeToString(
+ SignaturePubKeyInfo: S002SignaturePubKeyInfoType{
+ X509Data: DSIGX509Data{
+ DSIGX509Certificate: base64.StdEncoding.EncodeToString(
signatureCertificate.x509Certificate, // TODO Proper Base64 Marshalling
),
},
@@ -135,28 +41,28 @@ func GenerateIniRequest(signatureCertificate EbicsCertificate) (string, error) {
zlibWriter.Write(orderData_xml)
zlibWriter.Close()
- ini := EbicsUnsecuredRequest{
+ ini := H005UnsecuredRequest{
Xmlns: "urn:org:ebics:H005",
Version: "H005",
Revision: "1",
- Header: EbicsHeader{
+ Header: H005UnsecuredRequestHeader{
Authenticate: true,
- Static: EbicsHeaderStatic{
+ Static: H005UnsecuredRequestStaticHeaderType{
HostID: "MULTIVIA",
PartnerID: "MV008078",
UserID: "SCHOLZ01",
- Product: EbicsProduct{
+ Product: H005ProductElementType{
Language: "en",
Name: "libebics",
},
- OrderDetails: EbicsOrderDetails{
+ OrderDetails: H005UnsecuredReqOrderDetailsType{
AdminOrderType: "INI",
},
SecurityMedium: "0000",
},
},
- Body: EbicsBody{
- DataTransfer: EbicsDataTransfer{
+ Body: H005UnsecuredRequestBody{
+ DataTransfer: H005UnsecuredRequestDataTransfer{
OrderData: base64.StdEncoding.EncodeToString(
zlibWriterBuffer.Bytes(),
),
@@ -182,21 +88,21 @@ func GenerateHiaRequest(authenticationCertificate EbicsCertificate, encryptionCe
var zlibWriterBuffer bytes.Buffer
zlibWriter := zlib.NewWriter(&zlibWriterBuffer)
- orderData := EbicsHiaRequestOrderData{
+ orderData := H005HIARequestOrderDataType{
Xmlns: "urn:org:ebics:H005",
Esig: "http://www.ebics.org/S002",
Ds: "http://www.w3.org/2000/09/xmldsig#",
- AuthenticationPubKeyInfo: EbicsAuthenticationPubKeyInfo{
- X509Data: EbicsX509Data{
- X509Certificate: base64.StdEncoding.EncodeToString(
+ AuthenticationPubKeyInfo: H005AuthenticationPubKeyInfo{
+ X509Data: DSIGX509Data{
+ DSIGX509Certificate: base64.StdEncoding.EncodeToString(
authenticationCertificate.x509Certificate, // TODO Proper Base64 Marshalling
),
},
AuthenticationVersion: authenticationCertificate.ebicsCertificateType.String(),
},
- EncryptionPubKeyInfo: EbicsEncryptionPubKeyInfo{
- X509Data: EbicsX509Data{
- X509Certificate: base64.StdEncoding.EncodeToString(
+ EncryptionPubKeyInfo: H005EncryptionPubKeyInfo{
+ X509Data: DSIGX509Data{
+ DSIGX509Certificate: base64.StdEncoding.EncodeToString(
encryptionCertificate.x509Certificate, // TODO Proper Base64 Marshalling
),
},
@@ -216,28 +122,28 @@ func GenerateHiaRequest(authenticationCertificate EbicsCertificate, encryptionCe
zlibWriter.Write(orderData_xml)
zlibWriter.Close()
- ini := EbicsUnsecuredRequest{
+ ini := H005UnsecuredRequest{
Xmlns: "urn:org:ebics:H005",
Version: "H005",
Revision: "1",
- Header: EbicsHeader{
+ Header: H005UnsecuredRequestHeader{
Authenticate: true,
- Static: EbicsHeaderStatic{
+ Static: H005UnsecuredRequestStaticHeaderType{
HostID: "MULTIVIA",
PartnerID: "MV008078",
UserID: "SCHOLZ01",
- Product: EbicsProduct{
+ Product: H005ProductElementType{
Language: "en",
Name: "libebics",
},
- OrderDetails: EbicsOrderDetails{
+ OrderDetails: H005UnsecuredReqOrderDetailsType{
AdminOrderType: "HIA",
},
SecurityMedium: "0000",
},
},
- Body: EbicsBody{
- DataTransfer: EbicsDataTransfer{
+ Body: H005UnsecuredRequestBody{
+ DataTransfer: H005UnsecuredRequestDataTransfer{
OrderData: base64.StdEncoding.EncodeToString(
zlibWriterBuffer.Bytes(),
),