hbci4jruby 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/hbci4jruby +35 -0
- data/examples/passport.json +12 -0
- data/examples/test.rb +24 -0
- data/hbci4jruby.gemspec +23 -0
- data/lib/hbci4java.jar +0 -0
- data/lib/hbci4jruby/banking_passport.rb +20 -0
- data/lib/hbci4jruby/hbci_callback.rb +46 -0
- data/lib/hbci4jruby/turnover.rb +37 -0
- data/lib/hbci4jruby/version.rb +3 -0
- data/lib/hbci4jruby.rb +25 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 496b7a0172473d4af8fa080a63bfd472e099a3fc
|
4
|
+
data.tar.gz: 5eb8a0141a8dc30c524a2ce59eab61e49f95c0fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c17b213bb0ac1eb738445477dbad57cf40b08f547e44a73a6d3d2b144d96dd206f5eef6af2f5857c9547534e16c05993f43e438dc03ea3329e69c9589cb23269
|
7
|
+
data.tar.gz: ab12aa6601058748592d8fa1a0d50fa654d76a409c7ed42b4524d5b9c6c35c8e044ff335d985afa58210429f436f9a70e6ac7d7c7bafbc23c59c4c1261d7cbff
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jens Bissinger
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Hbci4jruby
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'hbci4jruby'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install hbci4jruby
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/hbci4jruby/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/hbci4jruby
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'hbci4jruby')
|
5
|
+
|
6
|
+
def usage
|
7
|
+
STDOUT.puts("Usage #{__FILE__} <action> <params-json-string-or-file> <passport-json-string-or-file>")
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_json_arg arg
|
11
|
+
data = File.exists?(arg) ? File.read(arg) : arg
|
12
|
+
JSON.parse(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
if ARGV.size != 3
|
16
|
+
STDERR.puts("Insufficient arguments")
|
17
|
+
usage
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
action = ARGV[0]
|
22
|
+
params = load_json_arg(ARGV[1])
|
23
|
+
passport = load_json_arg(ARGV[2])
|
24
|
+
|
25
|
+
banking_passport = Hbci4Jruby::BankingPassport.new
|
26
|
+
banking_passport.attributes = passport
|
27
|
+
|
28
|
+
if action === 'turnover'
|
29
|
+
list = Hbci4Jruby::Turnover.new.list(banking_passport, params)
|
30
|
+
STDOUT.puts(JSON.dump(list))
|
31
|
+
else
|
32
|
+
STDERR.puts("Unknow action #{action}")
|
33
|
+
usage
|
34
|
+
exit 1
|
35
|
+
end
|
data/examples/test.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'hbci')
|
2
|
+
|
3
|
+
include Hbci4Jruby
|
4
|
+
|
5
|
+
banking_passport = BankingPassport.new
|
6
|
+
banking_passport.hbci_version = '300'
|
7
|
+
banking_passport.host = 'fints.comdirect.de/fints'
|
8
|
+
banking_passport.port = '443'
|
9
|
+
banking_passport.filter = 'Base64'
|
10
|
+
banking_passport.country_code = 'DE'
|
11
|
+
banking_passport.bank_number = 'xx'
|
12
|
+
banking_passport.customer_id = 'xx'
|
13
|
+
banking_passport.user_id = 'xx'
|
14
|
+
banking_passport.account_number = 'xx'
|
15
|
+
banking_passport.pin = 'xx'
|
16
|
+
|
17
|
+
$r = Turnover.new.list(banking_passport, {
|
18
|
+
'start_date' => Time.new(2013),
|
19
|
+
'end_date' => Time.now
|
20
|
+
})
|
21
|
+
p $r[0].to_string
|
22
|
+
|
23
|
+
#require 'irb'
|
24
|
+
#IRB.start
|
data/hbci4jruby.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hbci4jruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hbci4jruby"
|
8
|
+
spec.version = Hbci4Jruby::VERSION
|
9
|
+
spec.authors = ["Jens Bissinger"]
|
10
|
+
spec.email = ["mail@jens-bissinger.de"]
|
11
|
+
spec.summary = %q{HBCI library based on HBCI4Java.}
|
12
|
+
spec.description = %q{HBCI library based on HBCI4Java.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/lib/hbci4java.jar
ADDED
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Hbci4Jruby
|
2
|
+
class BankingPassport
|
3
|
+
attr_accessor :hbci_version, :pin, :user_id, :customer_id,
|
4
|
+
:country_code, :port, :host, :filter,
|
5
|
+
:bank_number, :account_number
|
6
|
+
|
7
|
+
def attributes= hash
|
8
|
+
self.hbci_version = hash['hbci_version']
|
9
|
+
self.pin = hash['pin']
|
10
|
+
self.user_id = hash['user_id']
|
11
|
+
self.customer_id = hash['customer_id']
|
12
|
+
self.country_code = hash['country_code']
|
13
|
+
self.port = hash['port']
|
14
|
+
self.host = hash['host']
|
15
|
+
self.filter = hash['filter']
|
16
|
+
self.bank_number = hash['bank_number']
|
17
|
+
self.account_number = hash['account_number']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Hbci4Jruby
|
2
|
+
class HBCICallback < AbstractHBCICallback
|
3
|
+
@@status_names = {}
|
4
|
+
constants.each { |c| @@status_names[const_get(c)] = c }
|
5
|
+
|
6
|
+
def build_answer banking_passport
|
7
|
+
answer = {}
|
8
|
+
answer[NEED_PT_PIN] = banking_passport.pin
|
9
|
+
answer[NEED_CUSTOMERID] = banking_passport.customer_id
|
10
|
+
answer[NEED_USERID] = banking_passport.user_id
|
11
|
+
answer[NEED_COUNTRY] = banking_passport.country_code
|
12
|
+
answer[NEED_BLZ] = banking_passport.bank_number
|
13
|
+
answer[NEED_FILTER] = banking_passport.filter
|
14
|
+
answer[NEED_HOST] = banking_passport.host
|
15
|
+
answer[NEED_PORT] = banking_passport.port
|
16
|
+
answer
|
17
|
+
end
|
18
|
+
|
19
|
+
def callback(passport, reason, msg, dataType, retData)
|
20
|
+
banking_passport = passport.getClientData('init')
|
21
|
+
|
22
|
+
# for reason enum definitions see HBCICallback.java in hbci4java
|
23
|
+
answer = build_answer(banking_passport)[reason]
|
24
|
+
if answer
|
25
|
+
retData.replace(0, retData.length, answer)
|
26
|
+
else
|
27
|
+
case reason
|
28
|
+
when NEED_PASSPHRASE_LOAD then retData.replace(0, retData.length, passphrase)
|
29
|
+
when NEED_PASSPHRASE_SAVE then retData.replace(0, retData.length, "foo")
|
30
|
+
when NEED_PT_PIN then retData.replace(0, retData.length, pin)
|
31
|
+
when NEED_PT_TAN then retData.replace(0, retData.length, tan)
|
32
|
+
when NEED_CONNECTION, CLOSE_CONNECTION then nil
|
33
|
+
else puts "not implemented #{reason}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def log(msg, level, date, trace)
|
39
|
+
#puts msg
|
40
|
+
end
|
41
|
+
|
42
|
+
def status(passport, statusTag, o)
|
43
|
+
#puts @@status_names[statusTag]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Hbci4Jruby
|
4
|
+
class Turnover
|
5
|
+
# Umsätze von start_date bis end_date abrufen
|
6
|
+
# * passport_type, passphrase, pin und file kommen in dieser Implementation aus der zugrunde liegenden Tabelle.
|
7
|
+
# * Wenn passport_type = "PinTan" ist, wird die pin verwendet.
|
8
|
+
# * Wenn passport_type = "RDHNew" ist, wird die Schlüsseldatei aus filename verwendet und mit der passphrase entschlüsselt.
|
9
|
+
def list(banking_passport, params)
|
10
|
+
passport = AbstractHBCIPassport.getInstance('PinTan', banking_passport)
|
11
|
+
handle = HBCIHandler.new(banking_passport.hbci_version, passport)
|
12
|
+
job = handle.newJob('KUmsAll')
|
13
|
+
my_account = passport.getAccount(banking_passport.account_number)
|
14
|
+
|
15
|
+
job.setParam('my', my_account)
|
16
|
+
|
17
|
+
ruby_startdate = params['start_date'] || (Date.today - 1)
|
18
|
+
job.setParam('startdate', java.util.Date.new(ruby_startdate.year-1900, ruby_startdate.month-1, ruby_startdate.day))
|
19
|
+
|
20
|
+
ruby_enddate = params['end_date'] || (Date.today - 1)
|
21
|
+
job.setParam('enddate', java.util.Date.new(ruby_enddate.year-1900, ruby_enddate.month-1, ruby_enddate.day))
|
22
|
+
|
23
|
+
job.addToQueue
|
24
|
+
|
25
|
+
status = handle.execute
|
26
|
+
|
27
|
+
handle.close
|
28
|
+
|
29
|
+
if status.isOK
|
30
|
+
result = job.getJobResult
|
31
|
+
result.getFlatData.to_a
|
32
|
+
else
|
33
|
+
puts "Fehler: " + status.getErrorString
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/hbci4jruby.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'java'
|
2
|
+
require File.join(File.dirname(__FILE__),'hbci4java.jar')
|
3
|
+
|
4
|
+
import 'org.kapott.hbci.manager.HBCIUtils'
|
5
|
+
import 'org.kapott.hbci.manager.HBCIUtilsInternal'
|
6
|
+
import 'org.kapott.hbci.passport.AbstractHBCIPassport'
|
7
|
+
import 'org.kapott.hbci.callback.AbstractHBCICallback'
|
8
|
+
import 'org.kapott.hbci.manager.HBCIHandler'
|
9
|
+
|
10
|
+
require File.join(File.dirname(__FILE__), 'hbci4jruby', 'banking_passport')
|
11
|
+
require File.join(File.dirname(__FILE__), 'hbci4jruby', 'hbci_callback')
|
12
|
+
require File.join(File.dirname(__FILE__), 'hbci4jruby', 'turnover')
|
13
|
+
|
14
|
+
HBCIUtils.init(nil, Hbci4Jruby::HBCICallback.new)
|
15
|
+
HBCIUtils.setParam("client.product.name","HBCI4Java")
|
16
|
+
HBCIUtils.setParam("client.product.version","2.5")
|
17
|
+
HBCIUtils.setParam("client.passport.default","PinTan")
|
18
|
+
HBCIUtils.setParam("client.retries.passphrase","2")
|
19
|
+
# client.passport.PinTan.certfile=hbcicerts.bin
|
20
|
+
HBCIUtils.setParam("client.passport.PinTan.checkcert","1")
|
21
|
+
HBCIUtils.setParam("client.passport.PinTan.init","1")
|
22
|
+
HBCIUtils.setParam("client.passport.PinTan.filename", 'pintan.dat')
|
23
|
+
|
24
|
+
module Hbci4Jruby
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hbci4jruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jens Bissinger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.7'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: HBCI library based on HBCI4Java.
|
42
|
+
email:
|
43
|
+
- mail@jens-bissinger.de
|
44
|
+
executables:
|
45
|
+
- hbci4jruby
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- .ruby-version
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/hbci4jruby
|
56
|
+
- examples/passport.json
|
57
|
+
- examples/test.rb
|
58
|
+
- hbci4jruby.gemspec
|
59
|
+
- lib/hbci4java.jar
|
60
|
+
- lib/hbci4jruby.rb
|
61
|
+
- lib/hbci4jruby/banking_passport.rb
|
62
|
+
- lib/hbci4jruby/hbci_callback.rb
|
63
|
+
- lib/hbci4jruby/turnover.rb
|
64
|
+
- lib/hbci4jruby/version.rb
|
65
|
+
homepage: ''
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.1.9
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: HBCI library based on HBCI4Java.
|
89
|
+
test_files: []
|