epics 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +6 -0
  5. data/CONTRIBUTING.md +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +165 -0
  8. data/README.md +197 -0
  9. data/Rakefile +7 -0
  10. data/epics.gemspec +50 -0
  11. data/lib/epics.rb +35 -0
  12. data/lib/epics/cct.rb +42 -0
  13. data/lib/epics/cd1.rb +42 -0
  14. data/lib/epics/cdd.rb +42 -0
  15. data/lib/epics/client.rb +216 -0
  16. data/lib/epics/error.rb +324 -0
  17. data/lib/epics/generic_request.rb +99 -0
  18. data/lib/epics/generic_upload_request.rb +89 -0
  19. data/lib/epics/haa.rb +40 -0
  20. data/lib/epics/hia.rb +78 -0
  21. data/lib/epics/hpb.rb +29 -0
  22. data/lib/epics/hpd.rb +40 -0
  23. data/lib/epics/htd.rb +40 -0
  24. data/lib/epics/ini.rb +69 -0
  25. data/lib/epics/key.rb +79 -0
  26. data/lib/epics/mgf.rb +41 -0
  27. data/lib/epics/middleware/parse_ebics.rb +15 -0
  28. data/lib/epics/middleware/xmlsig.rb +18 -0
  29. data/lib/epics/ptk.rb +52 -0
  30. data/lib/epics/response.rb +93 -0
  31. data/lib/epics/signer.rb +40 -0
  32. data/lib/epics/sta.rb +52 -0
  33. data/lib/epics/version.rb +3 -0
  34. data/lib/letter/ini.erb +231 -0
  35. data/spec/client_spec.rb +98 -0
  36. data/spec/fixtures/a006.pem +28 -0
  37. data/spec/fixtures/bank_e.pem +6 -0
  38. data/spec/fixtures/e002.pem +28 -0
  39. data/spec/fixtures/x002.pem +28 -0
  40. data/spec/fixtures/xml/cd1.xml +87 -0
  41. data/spec/fixtures/xml/ebics_business_nok.xml +21 -0
  42. data/spec/fixtures/xml/ebics_technical_nok.xml +12 -0
  43. data/spec/fixtures/xml/hia.xml +2 -0
  44. data/spec/fixtures/xml/hia_request_order_data.xml +2 -0
  45. data/spec/fixtures/xml/hpb.xml +34 -0
  46. data/spec/fixtures/xml/hpb_request.xml +34 -0
  47. data/spec/fixtures/xml/hpb_response.xml +21 -0
  48. data/spec/fixtures/xml/hpb_response_order.xml +22 -0
  49. data/spec/fixtures/xml/htd_order_data.xml +153 -0
  50. data/spec/fixtures/xml/ini.xml +2 -0
  51. data/spec/fixtures/xml/signature_pub_key_order_data.xml +2 -0
  52. data/spec/fixtures/xml/upload_init_response.xml +31 -0
  53. data/spec/hpb_spec.rb +15 -0
  54. data/spec/key_spec.rb +35 -0
  55. data/spec/mgf_spec.rb +36 -0
  56. data/spec/middleware/parse_ebics_spec.rb +18 -0
  57. data/spec/orders/cct_spec.rb +17 -0
  58. data/spec/orders/cd1_spec.rb +17 -0
  59. data/spec/orders/cdd_spec.rb +17 -0
  60. data/spec/orders/haa_spec.rb +11 -0
  61. data/spec/orders/hia_spec.rb +34 -0
  62. data/spec/orders/hpb_spec.rb +11 -0
  63. data/spec/orders/hpd_spec.rb +11 -0
  64. data/spec/orders/htd_spec.rb +11 -0
  65. data/spec/orders/ini_spec.rb +36 -0
  66. data/spec/orders/ptk_spec.rb +11 -0
  67. data/spec/orders/sta_spec.rb +11 -0
  68. data/spec/response_spec.rb +34 -0
  69. data/spec/signer_spec.rb +34 -0
  70. data/spec/spec_helper.rb +43 -0
  71. data/spec/support/ebics_matcher.rb +22 -0
  72. data/spec/xsd/ebics_H004.xsd +11 -0
  73. data/spec/xsd/ebics_hev.xsd +135 -0
  74. data/spec/xsd/ebics_keymgmt_request_H004.xsd +543 -0
  75. data/spec/xsd/ebics_keymgmt_response_H004.xsd +137 -0
  76. data/spec/xsd/ebics_orders_H004.xsd +1892 -0
  77. data/spec/xsd/ebics_request_H004.xsd +355 -0
  78. data/spec/xsd/ebics_response_H004.xsd +166 -0
  79. data/spec/xsd/ebics_signature.xsd +217 -0
  80. data/spec/xsd/ebics_types_H004.xsd +2426 -0
  81. data/spec/xsd/xmldsig-core-schema.xsd +318 -0
  82. metadata +319 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 36e7870a631e71236b0c9379770056d5c9c8d08f
4
+ data.tar.gz: 59d5dfe38c22a0d71fc1b9a700bb145fa4f1059c
5
+ SHA512:
6
+ metadata.gz: eb1d40e580bf49be94aba0618a2146113cecc2781f60a4a37a79650a5afd479e09ab459568cca018faf7b2adfab741af7f6184c82934d2fb01ac673423cef458
7
+ data.tar.gz: 6d58b9dc15721089a511f908896b5c5b60a9628171fe0edb70f702b53a5a7346d788974c54e2ef50a46434c7906cf5190908ccf0e8d8095256df0221e87026f0
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /ebics_playground
16
+ .DS_Store
17
+ sbk.key
18
+ /mt940
19
+ *.key
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.2
6
+ - jruby
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,5 @@
1
+ # Contributing to Epics
2
+
3
+ ## Before You Start
4
+
5
+ Please contact team@railslove.com before working on Epics!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in epics.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,197 @@
1
+ [![Build Status](https://magnum.travis-ci.com/railslove/epics.svg?token=EhFJyZWe1sxdBDmF2bzC&branch=master)](https://magnum.travis-ci.com/railslove/epics)
2
+
3
+ # Epics
4
+
5
+ EPICS is a ruby implementation of the [EBICS](http://www.ebics.org/) (Electronic Banking Internet Communication Standard)
6
+
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'epics'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install epics
24
+
25
+
26
+ ## Getting started
27
+
28
+ In case you are new to EBICS, you'll have to complete a initialization process with
29
+ your bank. Epics can help you to generate all the necessary keys and directly store
30
+ them for later use, but first you'll have to to lift some contractually work with your
31
+ bank.
32
+
33
+ Once the paperwork is done, your bank should provide you with:
34
+
35
+ * a URL to their EBICS Server
36
+ * a HOST ID
37
+ * a PARTNER ID
38
+ * n User IDs (this depends on the bank and your needs)
39
+
40
+ Take this parameters and start setting up one UserID (repeat this for every user
41
+ you want to initialize):
42
+
43
+ ```ruby
44
+ e = Epics::Client.setup("my-super-secret", "https://ebics.sandbox", "SIZBN001", "EBIX", "EPICS")
45
+ ```
46
+
47
+ To use the keys later, just store them in a file
48
+
49
+ ```ruby
50
+ e.save_keys("/home/epics/my.key")
51
+ # or store the json elsewhere, but store it! for gods sake :D
52
+ ```
53
+
54
+ It is really __important__ to keep your keys around, once your user has been initialized
55
+ you'll have to start over when you loose the keys!
56
+
57
+ Submit the keys to your bank:
58
+
59
+ ```ruby
60
+ e.INI # sends the signature key
61
+
62
+ e.HIA # sends the encryption and authentication keys
63
+ ```
64
+
65
+ The next step is to print the INI letter and post it to your bank:
66
+
67
+ ```ruby
68
+ e.save_ini_letter( 'My Banks Name', "/home/epics/ini.html" )
69
+ ```
70
+
71
+ Open the generated HTML file in your favorite browser and print it out (skipping
72
+ header and footer sounds like a solid setting here ;) In case your having difficulties
73
+ with the encoding, try forcing your browser to use UTF-8.
74
+
75
+ Put the INI letter in a envelope and mail it to your bank!
76
+
77
+ Done! ... Well not completly :)
78
+
79
+ Once the bank confirms that your user is completely initialized. You'll have to
80
+ download the public keys of your bank:
81
+
82
+ ```ruby
83
+ ### see below for client creation
84
+ e.HPB
85
+ ```
86
+
87
+ Then again, save the keys or store the json somewhere safe.
88
+
89
+ You're now ready to go. Maybe try:
90
+
91
+ ```ruby
92
+ e.HAA
93
+ ```
94
+
95
+ To get a list of all supported order types.
96
+
97
+ ## Usage
98
+
99
+ ### Create a client
100
+
101
+ ```ruby
102
+ # read the keys from a file
103
+ e = Epics::Client.new(File.open('/tmp/my.key'), 'passphrase', 'url', 'host', 'user', 'partner')
104
+
105
+ # or provide a string hoding the key data
106
+ keys = File.read('/tmp/my.key')
107
+
108
+ e = Epics::Client.new(keys, 'passphrase', 'url', 'host', 'user', 'partner')
109
+ ```
110
+
111
+ ### Lazy Mode
112
+
113
+ Once you have a client, go ahead and start playing! There are 3 convinence methods
114
+ that are hiding some strange names from you:
115
+
116
+ * debit( _xml_ ) (submits a PAIN.008.003.02 document via CDD)
117
+ * credit( _xml_ ) (submits a pain.001.003.03 document)
118
+ * statements( _from_, _to_ ) (fetches an account statement via STA)
119
+
120
+ If you need more sophisticated EBICS order types, please read the next section
121
+ about the supported functionalities.
122
+
123
+ ## Features
124
+
125
+ ### Initialization
126
+
127
+ * INI (Sends the public key of the electronic signature.)
128
+ * HIA (Sends the public authentication (X002) and encryption (E002) keys.)
129
+
130
+ ### Downloads
131
+
132
+ Currently this EPICS implementation supports the following order types:
133
+
134
+ * HPB (fetch your bank's public keys)
135
+ * STA (statements in MT940 format)
136
+ * HAA (available order types)
137
+ * HTD (user properties and settings)
138
+ * HPD (the available bank parameters)
139
+ * PKT (customer usage report in text format)
140
+ * ... more coming soon
141
+
142
+ Example:
143
+
144
+ ```ruby
145
+ puts e.STA('2014-09-01', '2014-09-11')
146
+ # result is a MT940 feed
147
+
148
+ :20:1
149
+ :25:/PL12124012551111000015237873
150
+ :28C:00152
151
+ :60F:C081130PLN000000002535,03
152
+ :61:0810021002DN000000001273,23N641NONREF
153
+ :86:641^00PRZELEW MI¨DZYBANKOWY BETA/^34000
154
+ ^3019401076^38PL54194010765205871800000000
155
+ ^20wynagrodzenie z tytulu umow^21y o prac e
156
+ ^32BANKA MONIKA
157
+ ^62PODCHORAZYCH 16/1580-298 GD^63ANSK
158
+ :61:0810021002DN000000001287,40N641NONREF
159
+ :86:641^00PRZELEW MI¨DZYBANKOWY BETA/^34000
160
+ ^3010201909^38PL74102019090000310200475772
161
+ ^20wynagrodzenie z tytulu umow^21y o prac e
162
+ ^32SZCZACHOR DOROTA
163
+ ^62RATAJA 13B/1083-032 PSZCZOL^63KI
164
+ ```
165
+
166
+ ### Uploads
167
+
168
+ * CD1 (Uploads a SEPA Direct Debit document of type COR1)
169
+ * CDD (Uploads a SEPA Direct Debit document of type CORE)
170
+ * CCT (Uploads a SEPA Credit document)
171
+ * ... more coming soon
172
+
173
+ Example:
174
+
175
+ ```ruby
176
+ puts e.CD1("i-am-a-PAIN-xml-file")
177
+ # res is a the transaction id of the order
178
+ ```
179
+
180
+ ## Supported Banks
181
+
182
+ * Sofortbank
183
+ * Deutsche Bank
184
+
185
+ ## Contributing
186
+
187
+ 0. Contact team@raislove.com for information about howto CLA
188
+ 1. Fork it ( https://github.com/[my-github-username]/epics/fork )
189
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
190
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
191
+ 4. Push to the branch (`git push origin my-new-feature`)
192
+ 5. Create a new Pull Request
193
+
194
+
195
+
196
+
197
+ made with love by [railslove](http://www.railslove.com)
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
7
+
data/epics.gemspec ADDED
@@ -0,0 +1,50 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'epics/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "epics"
8
+ spec.version = Epics::VERSION
9
+ spec.authors = ["Lars Brillert"]
10
+ spec.email = ["lars@railslove.com"]
11
+ spec.summary = %q{a ruby implementation of the EBICS protocol}
12
+ spec.description = <<-description
13
+ Epics is a ruby implementation of the EBIC standard (H004)
14
+
15
+ It supports the complete initialization process comprising INI, HIA and HPB
16
+ including the INI letter generation.
17
+
18
+ Furthermore it offers support for the most common download types:
19
+ STA HAA HTD HPD PKT
20
+
21
+ And the following upload orders:
22
+ CD1 CDD CCT
23
+ description
24
+
25
+ spec.homepage = "https://github.com/railslove/epics"
26
+ spec.license = "LGPL-3.0"
27
+
28
+ spec.files = `git ls-files -z`.split("\x0")
29
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.post_install_message = "\n\e[32m" + ("*" * 60) + "\n\e[0m"
34
+ spec.post_install_message += "Thanks for using Epics - your epic EBICS client!\n"
35
+ spec.post_install_message += "Epics provides a full production-tested implementation of the Electronic Banking Internet Communication Standard.\n"
36
+ spec.post_install_message += "Railslove as the maintainer is commited to provide extensive developer tools to make integrating financial institutions fun and easy.\n"
37
+ spec.post_install_message += "Please create an issue on github (railslove/epics) if anything does not work as expected. And contact team@railslove.com if you are looking for support with your integration.\n"
38
+ spec.post_install_message += "\e[32m" + ("*" * 60) + "\n\e[0m"
39
+
40
+ spec.add_dependency "nokogiri"
41
+ spec.add_dependency "gyoku"
42
+ spec.add_dependency "faraday"
43
+
44
+ spec.add_development_dependency "bundler", ">= 1.6.2"
45
+ spec.add_development_dependency "rake", "~> 10.0"
46
+ spec.add_development_dependency "rspec"
47
+ spec.add_development_dependency "pry"
48
+ spec.add_development_dependency "webmock"
49
+ spec.add_development_dependency "equivalent-xml"
50
+ end