epics 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +1,30 @@
1
1
  class Epics::CDB < Epics::GenericUploadRequest
2
-
3
2
  def header
4
- {
5
- :@authenticate => true,
6
- static: {
7
- "HostID" => host_id,
8
- "Nonce" => nonce,
9
- "Timestamp" => timestamp,
10
- "PartnerID" => partner_id,
11
- "UserID" => user_id,
12
- "Product" => {
13
- :@Language => "de",
14
- :content! => "EPICS - a ruby ebics kernel"
15
- },
16
- "OrderDetails" => {
17
- "OrderType" => "CDB",
18
- "OrderAttribute" => "OZHNN",
19
- "StandardOrderParams/" => ""
20
- },
21
- "BankPubKeyDigests" => {
22
- "Authentication" => {
23
- :@Version => "X002",
24
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
25
- :content! => client.bank_x.public_digest
26
- },
27
- "Encryption" => {
28
- :@Version => "E002",
29
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
30
- :content! => client.bank_e.public_digest
3
+ Nokogiri::XML::Builder.new do |xml|
4
+ xml.header(authenticate: true) {
5
+ xml.static {
6
+ xml.HostID host_id
7
+ xml.Nonce nonce
8
+ xml.Timestamp timestamp
9
+ xml.PartnerID partner_id
10
+ xml.UserID user_id
11
+ xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
12
+ xml.OrderDetails {
13
+ xml.OrderType 'CDB'
14
+ xml.OrderAttribute 'OZHNN'
15
+ xml.StandardOrderParams
31
16
  }
32
- },
33
- "SecurityMedium" => "0000",
34
- "NumSegments" => 1
35
- },
36
- "mutable" => {
37
- "TransactionPhase" => "Initialisation"
17
+ xml.BankPubKeyDigests {
18
+ xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
19
+ xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
20
+ }
21
+ xml.SecurityMedium '0000'
22
+ xml.NumSegments 1
23
+ }
24
+ xml.mutable {
25
+ xml.TransactionPhase 'Initialisation'
26
+ }
38
27
  }
39
- }
28
+ end.doc.root
40
29
  end
41
-
42
30
  end
@@ -8,42 +8,31 @@ class Epics::CDD < Epics::GenericUploadRequest
8
8
  end
9
9
 
10
10
  def header
11
- {
12
- :@authenticate => true,
13
- static: {
14
- "HostID" => host_id,
15
- "Nonce" => nonce,
16
- "Timestamp" => timestamp,
17
- "PartnerID" => partner_id,
18
- "UserID" => user_id,
19
- "Product" => {
20
- :@Language => "de",
21
- :content! => "EPICS - a ruby ebics kernel"
22
- },
23
- "OrderDetails" => {
24
- "OrderType" => order_type,
25
- "OrderAttribute" => order_attribute,
26
- "StandardOrderParams/" => ""
27
- },
28
- "BankPubKeyDigests" => {
29
- "Authentication" => {
30
- :@Version => "X002",
31
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
32
- :content! => client.bank_x.public_digest
33
- },
34
- "Encryption" => {
35
- :@Version => "E002",
36
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
37
- :content! => client.bank_e.public_digest
11
+ Nokogiri::XML::Builder.new do |xml|
12
+ xml.header(authenticate: true) {
13
+ xml.static {
14
+ xml.HostID host_id
15
+ xml.Nonce nonce
16
+ xml.Timestamp timestamp
17
+ xml.PartnerID partner_id
18
+ xml.UserID user_id
19
+ xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
20
+ xml.OrderDetails {
21
+ xml.OrderType order_type
22
+ xml.OrderAttribute order_attribute
23
+ xml.StandardOrderParams ''
38
24
  }
39
- },
40
- "SecurityMedium" => "0000",
41
- "NumSegments" => 1
42
- },
43
- "mutable" => {
44
- "TransactionPhase" => "Initialisation"
25
+ xml.BankPubKeyDigests {
26
+ xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
27
+ xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
28
+ }
29
+ xml.SecurityMedium '0000'
30
+ xml.NumSegments 1
31
+ }
32
+ xml.mutable {
33
+ xml.TransactionPhase 'Initialisation'
34
+ }
45
35
  }
46
- }
36
+ end.doc.root
47
37
  end
48
-
49
38
  end
@@ -55,6 +55,10 @@ class Epics::Client
55
55
  @bic ||= (self.HTD; @bic)
56
56
  end
57
57
 
58
+ def order_types
59
+ @order_types ||= (self.HTD; @order_types)
60
+ end
61
+
58
62
  def self.setup(passphrase, url, host_id, user_id, partner_id, keysize = 2048)
59
63
  client = new(nil, passphrase, url, host_id, user_id, partner_id)
60
64
  client.keys = %w(A006 X002 E002).each_with_object({}) do |type, memo|
@@ -165,9 +169,10 @@ class Epics::Client
165
169
 
166
170
  def HTD
167
171
  Nokogiri::XML(download(Epics::HTD)).tap do |htd|
168
- @iban ||= htd.at_xpath("//xmlns:AccountNumber[@international='true']", xmlns: "urn:org:ebics:H004").text
169
- @bic ||= htd.at_xpath("//xmlns:BankCode[@international='true']", xmlns: "urn:org:ebics:H004").text
170
- @name ||= htd.at_xpath("//xmlns:Name", xmlns: "urn:org:ebics:H004").text
172
+ @iban ||= htd.at_xpath("//xmlns:AccountNumber[@international='true']", xmlns: "urn:org:ebics:H004").text
173
+ @bic ||= htd.at_xpath("//xmlns:BankCode[@international='true']", xmlns: "urn:org:ebics:H004").text
174
+ @name ||= htd.at_xpath("//xmlns:Name", xmlns: "urn:org:ebics:H004").text
175
+ @order_types ||= htd.search("//xmlns:OrderTypes", xmlns: "urn:org:ebics:H004").map{|o| o.content.split(/\s/) }.delete_if{|o| o == ""}.flatten
171
176
  end.to_xml
172
177
  end
173
178
 
@@ -22,107 +22,82 @@ class Epics::GenericRequest
22
22
  end
23
23
 
24
24
  def body
25
- ""
25
+ Nokogiri::XML::Builder.new do |xml|
26
+ xml.body
27
+ end.doc.root
26
28
  end
27
29
 
28
30
  def auth_signature
29
- {
30
- "ds:SignedInfo" => {
31
- "ds:CanonicalizationMethod/" => {
32
- :@Algorithm => "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
33
- },
34
- "ds:SignatureMethod/" => {
35
- :@Algorithm => "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
36
- },
37
- "ds:Reference/" => {
38
- :@URI => "#xpointer(//*[@authenticate='true'])",
39
- "ds:Transforms" => {
40
- "ds:Transform/" => {
41
- :@Algorithm => "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
31
+ Nokogiri::XML::Builder.new do |xml|
32
+ xml.AuthSignature{
33
+ xml.send('ds:SignedInfo') {
34
+ xml.send('ds:CanonicalizationMethod', '', Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
35
+ xml.send('ds:SignatureMethod', '', Algorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")
36
+ xml.send('ds:Reference', '', URI: "#xpointer(//*[@authenticate='true'])") {
37
+ xml.send('ds:Transforms') {
38
+ xml.send('ds:Transform', '', Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
42
39
  }
43
- },
44
- "ds:DigestMethod/" => {
45
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256"
46
- },
47
- "ds:DigestValue/" => ""
40
+ xml.send('ds:DigestMethod', '', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
41
+ xml.send('ds:DigestValue', '')
42
+ }
48
43
  }
49
- },
50
- "ds:SignatureValue/" => ""
51
- }
44
+ xml.send('ds:SignatureValue', '')
45
+ }
46
+ end.doc.root
52
47
  end
53
48
 
54
49
  def to_transfer_xml
55
- Nokogiri::XML.parse(Gyoku.xml({
56
- root => {
57
- :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
58
- :@xmlns => "urn:org:ebics:H004",
59
- :@Version => "H004",
60
- :@Revision => "1",
61
- "header" => {
62
- :@authenticate => true,
63
- "static" => {
64
- "HostID" => host_id,
65
- "TransactionID" => transaction_id
66
- },
67
- "mutable" => {
68
- "TransactionPhase" => "Transfer",
69
- "SegmentNumber" => {
70
- :@lastSegment => true,
71
- :content! => 1
72
- }
50
+ Nokogiri::XML::Builder.new do |xml|
51
+ xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'urn:org:ebics:H004', 'Version' => 'H004', 'Revision' => '1') {
52
+ xml.header(authenticate: true) {
53
+ xml.static {
54
+ xml.HostID host_id
55
+ xml.TransactionID transaction_id
73
56
  }
74
- },
75
- "AuthSignature" => auth_signature,
76
- "body" => {
77
- "DataTransfer" => {
78
- "OrderData" => encrypted_order_data
57
+ xml.mutable {
58
+ xml.TransactionPhase 'Transfer'
59
+ xml.SegmentNumber(1, lastSegment: true)
60
+ }
61
+ }
62
+ xml.parent.add_child(auth_signature)
63
+ xml.body {
64
+ xml.DataTransfer {
65
+ xml.OrderData encrypted_order_data
79
66
  }
80
67
  }
81
68
  }
82
- }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
69
+ end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8')
83
70
  end
84
71
 
85
72
  def to_receipt_xml
86
- Nokogiri::XML.parse(Gyoku.xml({
87
- root => {
88
- :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
89
- :@xmlns => "urn:org:ebics:H004",
90
- :@Version => "H004",
91
- :@Revision => "1",
92
- "header" => {
93
- :@authenticate => true,
94
- "static" => {
95
- "HostID" => host_id,
96
- "TransactionID" => transaction_id
97
- },
98
- "mutable" => {
99
- "TransactionPhase" => "Receipt"
73
+ Nokogiri::XML::Builder.new do |xml|
74
+ xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'urn:org:ebics:H004', 'Version' => 'H004', 'Revision' => '1') {
75
+ xml.header(authenticate: true) {
76
+ xml.static {
77
+ xml.HostID host_id
78
+ xml.TransactionID(transaction_id)
100
79
  }
101
- },
102
- "AuthSignature" => auth_signature,
103
- "body" => {
104
- "TransferReceipt" => {
105
- :@authenticate => true,
106
- "ReceiptCode" => 0
80
+ xml.mutable {
81
+ xml.TransactionPhase 'Receipt'
82
+ }
83
+ }
84
+ xml.parent.add_child(auth_signature)
85
+ xml.body {
86
+ xml.TransferReceipt(authenticate: true) {
87
+ xml.ReceiptCode 0
107
88
  }
108
89
  }
109
90
  }
110
- }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
91
+ end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8')
111
92
  end
112
93
 
113
94
  def to_xml
114
- Nokogiri::XML.parse(Gyoku.xml( {
115
- root => {
116
- :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#",
117
- :@xmlns => "urn:org:ebics:H004",
118
- :@Version => "H004",
119
- :@Revision => "1",
120
- :header => header,
121
- "AuthSignature" => auth_signature,
122
- "body" => body
95
+ Nokogiri::XML::Builder.new do |xml|
96
+ xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'urn:org:ebics:H004', 'Version' => 'H004', 'Revision'=> '1') {
97
+ xml.parent.add_child(header)
98
+ xml.parent.add_child(auth_signature)
99
+ xml.parent.add_child(body)
123
100
  }
124
- }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
101
+ end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8')
125
102
  end
126
-
127
-
128
103
  end
@@ -1,5 +1,4 @@
1
1
  class Epics::GenericUploadRequest < Epics::GenericRequest
2
-
3
2
  attr_accessor :key
4
3
  attr_accessor :document
5
4
 
@@ -18,37 +17,30 @@ class Epics::GenericUploadRequest < Epics::GenericRequest
18
17
  end
19
18
 
20
19
  def body
21
- {
22
- "DataTransfer" => {
23
- "DataEncryptionInfo" => {
24
- :@authenticate => true,
25
- "EncryptionPubKeyDigest" => {
26
- :"@Version" => "E002",
27
- :"@Algorithm" => "http://www.w3.org/2001/04/xmlenc#sha256",
28
- :content! => client.bank_e.public_digest
29
- },
30
- "TransactionKey" => Base64.encode64(client.bank_e.key.public_encrypt(self.key)).gsub(/\n/,'')
31
- },
32
- "SignatureData" => {
33
- :@authenticate => true,
34
- :content! => encrypted_order_signature
20
+ Nokogiri::XML::Builder.new do |xml|
21
+ xml.body {
22
+ xml.DataTransfer {
23
+ xml.DataEncryptionInfo(authenticate: true) {
24
+ xml.EncryptionPubKeyDigest(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
25
+ xml.TransactionKey Base64.encode64(client.bank_e.key.public_encrypt(self.key)).gsub(/\n/,'')
26
+ }
27
+ xml.SignatureData(encrypted_order_signature, authenticate: true)
35
28
  }
36
29
  }
37
- }
30
+ end.doc.root
38
31
  end
39
32
 
40
33
  def order_signature
41
- Gyoku.xml("UserSignatureData" => {
42
- :"@xmlns" => "http://www.ebics.org/S001",
43
- :"@xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
44
- :"@xsi:schemaLocation" => "http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd",
45
- "OrderSignatureData" => {
46
- "SignatureVersion" => "A006",
47
- "SignatureValue" => signature_value,
48
- "PartnerID" => partner_id,
49
- "UserID" => user_id
34
+ Nokogiri::XML::Builder.new do |xml|
35
+ xml.UserSignatureData('xmlns' => 'http://www.ebics.org/S001', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd') {
36
+ xml.OrderSignatureData {
37
+ xml.SignatureVersion "A006"
38
+ xml.SignatureValue signature_value
39
+ xml.PartnerID partner_id
40
+ xml.UserID user_id
41
+ }
50
42
  }
51
- })
43
+ end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8')
52
44
  end
53
45
 
54
46
  def signature_value
@@ -83,4 +75,4 @@ class Epics::GenericUploadRequest < Epics::GenericRequest
83
75
  end
84
76
  end
85
77
 
86
- end
78
+ end
@@ -1,40 +1,29 @@
1
1
  class Epics::HAA < Epics::GenericRequest
2
-
3
2
  def header
4
- {
5
- :@authenticate => true,
6
- static: {
7
- "HostID" => host_id,
8
- "Nonce" => nonce,
9
- "Timestamp" => timestamp,
10
- "PartnerID" => partner_id,
11
- "UserID" => user_id,
12
- "Product" => {
13
- :@Language => "de",
14
- :content! => "EPICS - a ruby ebics kernel"
15
- },
16
- "OrderDetails" => {
17
- "OrderType" => "HAA",
18
- "OrderAttribute" => "DZHNN",
19
- "StandardOrderParams/" => ""
20
- },
21
- "BankPubKeyDigests" => {
22
- "Authentication" => {
23
- :@Version => "X002",
24
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
25
- :content! => client.bank_x.public_digest
26
- },
27
- "Encryption" => {
28
- :@Version => "E002",
29
- :@Algorithm => "http://www.w3.org/2001/04/xmlenc#sha256",
30
- :content! => client.bank_e.public_digest
3
+ Nokogiri::XML::Builder.new do |xml|
4
+ xml.header(authenticate: true) {
5
+ xml.static {
6
+ xml.HostID host_id
7
+ xml.Nonce nonce
8
+ xml.Timestamp timestamp
9
+ xml.PartnerID partner_id
10
+ xml.UserID user_id
11
+ xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
12
+ xml.OrderDetails {
13
+ xml.OrderType 'HAA'
14
+ xml.OrderAttribute 'DZHNN'
15
+ xml.StandardOrderParams
31
16
  }
32
- },
33
- "SecurityMedium" => "0000"
34
- },
35
- "mutable" => {
36
- "TransactionPhase" => "Initialisation"
17
+ xml.BankPubKeyDigests {
18
+ xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
19
+ xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
20
+ }
21
+ xml.SecurityMedium '0000'
22
+ }
23
+ xml.mutable {
24
+ xml.TransactionPhase 'Initialisation'
25
+ }
37
26
  }
38
- }
27
+ end.doc.root
39
28
  end
40
29
  end